I have a laptop computer with the following setup:
- / on a btrfs /dev/sda3 subvolume @
- /home on a btrfs /dev/sda3 subvolume @home
- /boot on an ext4 /dev/sda2
- /boot/efi on a vfat /dev/sda1
- no swap
- /tmp on a tmpfs
Now I got a new solid state disk that I want to use instead of my current setup. Besides dd'ing the whole disk to the SSD (which I don't want to do since it marks all sectors as used), what steps should I do to copy all data in a way that my system still boots afterwards?
Big gotcha: I can't insert both discs at once into my system but I have a sufficiently fast eSATA backup disc that is big enough to store all data from the old HDD.
Personally, I use
tar
for this sort of thing: Create a tarball on your eSATA disk with a command like:You can then boot with an emergency system, create your partitions and filesystems, mount your eSATA disk, and unpack the tarball. You'll also need to do some cleaning up -- most notably, you'll need to adjust your
/etc/fstab
entries for the new system, and probably deal with your boot loader configuration to point it to the new filesystems.You've got "UEFI" and "grub-efi" tags set, so I assume you've got an EFI-based system. One major difference between BIOS systems and EFI systems is that BIOS-based computers rely on boot code tucked away in boot sectors and elsewhere on the hard disk, whereas EFI relies on boot files on the ESP (
/boot/efi
in your installation) along with NVRAM entries. When you swap out one disk for another, the old NVRAM entries will no longer be valid, since the GUID of the disk and the GUID of the ESP will have changed. Thus, you'll need to either move your boot loader to the fallback filename of/boot/efi/EFI/BOOT/bootx64.efi
or create a new NVRAM entry with theefibootmgr
utility, as in:The details depend on where your boot loader is located and what you want to call it. In some cases you may need to add more options, particularly if the ESP isn't
/dev/sda1
. Consult theefibootmgr
man page for details. Also,efibootmgr
must be run from an EFI boot, so it won't work from some emergency disks.