Migration from SD Card to Bootable USB (NVMe) vs. Clean Install

Another option.

My favorite imaging program is fsarchiver from the repo. I understand that it is also on the CloneZilla Live.

With dd it wants to clone the whole partition including the free space. I have read that it is possible to elimated the free space but one would have to jump through some hoops. This was problematic for me in many ways with dealing with making compact images for uploading for others to get, making images for backup to save for a quick restore and when restoring I would not be limited to a certain size sdcard.

fsarchiver will create a compressed image saving only the actual data on the partition including data like the partition LABEL like dd. This would allow one to restore the partition to any size sdcard as long as it is bigger than the amount of space the original file system took up. Say you originally had @5G of data on a 32G sdcard It would create a @1.4G compressed image that could be restored to a 8G sdcard.

This would be for the RPi as some devices expect the starting partition position for boot to be different.

Using your desktop…

Back up the sdcard:

Install fsarchiver from the repo
Put the sdcard in your desktop
mkdir xfce-20.08
cd xfce-20.08
mkdir boot
cp -R /path-to your-sdcard-boot(fat32)-partition/* boot/
sudo umount /dev/your-sdcard-root-partition (mine is sdd2)
sudo fsarchiver -v -Z 19 -j 4 savefs root.fsa /dev/your-sdcard-root-partition (adjust the -j value to your # of cores)
Remove the sdcard so there will not be any partition LABEL’s conflict in the next step

Restore to M.2 drive:

Create @150M fat32 partition on your USB M.2 drive with a BOOT_MNJRO LABEL. I use gparted and check the lba flags.
Then create an ext4 partition with a ROOT_MNJRO LABEL filling out the rest of the m.2 drive

cp -R boot/* /path-to-your-M.2/boot-partition/
sudo umount /dev/your-M.2-drive-root partition
sudo fsarchiver -v -j 4 restfs root.fsa id=0,dest=/dev/your-M.2-drive-root partition
sudo sync
unmount your M.2 drive and connect it to your RPi

Now you have a good back up you can restore if something goes amiss. I have been using this for about 5 years to back up my desktop every once in a while also.

2 Likes