-1

I have a copy of rootfs and boot folders of a raspbian installation sent to me in via dropbox. How do i take a new sdcard and create from it a bootable raspbian?

Also: the folders are in an archive file each.
I have a tar of the rootfs and tar of the boot.

3
  • not sure if you have the full contents of the image or just some parts? But you could flash an sd card from standard images, then mount that card on another machine, and go in a replace the folders that you were send via drop box. Commented Dec 10, 2018 at 17:09
  • actually that's amazing i haven't thought of that....Thank you. Also it's possible to do it with NOOBS. just by replacing the files in os/raspbian folders with my tar.xz files. but i wanted to do it without NOOBS. i'll try what you said. i think i have everything. Commented Dec 10, 2018 at 21:09
  • is it an .img file? Commented Oct 24, 2019 at 9:40

1 Answer 1

0

I see two possibilities to do what you want. You can take a "template" installation how @Chad G suggested in his comment and you can do it all by hand. The former is easier the latter more flexible.

In addition to the suggestion from @Chad G I will explain some details. First download a Raspbian image. The smallest one Raspbian Lite is enough. Flash it to the SD Card and start it at least one time in your RasPi. This will do first bootup initialization and expand the root partition. Then put the SD Card back to the card reader on your management computer. That should have at least a linux operating system, better a debian derivate (debian itself, ubuntu etc.). Otherwise you will have problems to access the needed ext4 filesystem. I use a Debian Stretch installation. Look if you see the SD Card:

mngmt ~$ lsblk -po NAME,SIZE,RM,RO,FSTYPE,TYPE,LABEL,MOUNTPOINT NAME SIZE RM RO FSTYPE TYPE LABEL MOUNTPOINT /dev/sda 167,7G 0 0 disk ├─/dev/sda1 243M 0 0 ext2 part boot ├─/dev/sda2 1K 0 0 part └─/dev/sda5 167,5G 0 0 LVM2_member part /dev/sdb 3,7G 1 0 disk ├─/dev/sdb1 43,9M 1 0 vfat part boot └─/dev/sdb2 1,7G 1 0 ext4 part rootfs 

I find my 4 GB test card with sdb*. Then mount its partitions and clean them up:

mngmt ~$ sudo -Es mngmt ~# mkdir /mnt/sdb1 mngmt ~# mkdir /mnt/sdb2 mngmt ~# mount /dev/sdb1 /mnt/sdb1 mngmt ~# mount /dev/sdb2 /mnt/sdb2 mngmt ~# rm -r /mnt/sdb1/* mngmt ~# rm -r /mnt/sdb2/* 

Restore from tar archives. The -C option depends on how the files in the archive are stored.

mngmt ~# tar -xf boot-partition.tar.gz -C /mnt/sdb1 mngmt ~# tar -xf root-partition.tar.gz -C /mnt/sdb2 

Prepare settings for booting: change device names in /mnt/sdb1/cmdline.txt and in /mnt/sdb2/etc/fstab from PARTUUID=... to /dev/mmcblk0p. This is necessary because you use another SC Card with different PARTUUID. Depending on what is in the tar archive you may have to fix it by hand.

mngmt ~# sed -i 's/ root=PARTUUID=[a-z0-9]*-0/ root=\/dev\/mmcblk0p/' /mnt/sdb1/cmdline.txt mngmt ~# sed -i 's/^PARTUUID=[a-z0-9]*-0/\/dev\/mmcblk0p/' /mnt/sdb2/etc/fstab 

Deleting it and restoring it from the tar destroyed the special qualities of the "lost+found" folder in the root directory of the ext4 file system, so recreate it (there's no corresponding thing in the vfat file system):

mngmt ~# cd /mnt/sdb2 mngmt ~# rm -rf lost+found mngmt ~# mklost+found mngmt ~# cd 

Then, it's time to umount the file systems so that all pending writes will happen and the flags for cleanness of the file systems will be set.

mngmt ~# umount /mnt/sdb1 mngmt ~# umount /mnt/sdb2 mngmt ~# exit mngmt ~$ 

Put the SD Card into the RasPi and boot.

If you want to modify the partition sizes or to understand what's going on you can also prepare the SD Card by hand. Then you can follow this setup from Step 2: partition SD Card: Howto prepare a SD card from a tar archive.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.