Sector by sector backup from encrypted hdd to ssd

1

I have a 500gb encrypted (LUKS) hdd with linux installed (only 50gb used) and I want to migrate to a 250gb ssd. Installing from scratch to the new drive is something that I want to avoid since I have many configurations that I prefer not to do again...

Since the disk is encrypted I thought of using some software with sector to sector cloning. Now I have two questions:

  1. Is it possible at all to do a sector to sector copy from a bigger to a smaller disk? What if I reduce the size of my partitions on my hdd in order to fit the ssd size? Will the backup software care or it will just copy the whole disk again?
  2. Will I face other problems after the backup? Drive letters, UUIDs... I don't know what else...

Of course if you have a better (simpler) recommendation for what I want to do, feel free.

Cobra Kai Dojo

Posted 2014-05-12T14:07:50.413

Reputation: 163

You will have to shrink the larger partition so it the same size. That is the simplest way to migrate from a larger disk to a smaller disk. Please remove your request for a product recomendation since thats not on topic – Ramhound – 2014-05-12T14:20:28.793

You might find this thread useful. The reason for copying was different but circumstances similar.

– Art Gertner – 2014-05-12T14:32:56.063

Answers

1

In general, the easiest way to migrate an already installed Linux-based OS from one storage device to another is probably to:

  1. Create a new file system on the target device. In your case, this would include creating a LUKS container, unless you want to migrate to unencrypted as well. Because you are creating a new file system, you don't have to worry about file system UUID collisions and similar.
  2. Copy all files from the source to the target device. Do this from a live-CD environment or similar, not from a running system, to ensure that nothing is changed during the process. rsync has several useful options here. Make sure to mount all relevant file systems before starting the copying process.
  3. Adjust the target's /etc/fstab and boot loader configuration to match the new reality. If you're still using /dev/sdXY names for partitions, this would be a good time to migrate to something else (UUIDs, labels, WWN IDs, whatever suits your fancy, just something stable). Then you don't have to worry when you unplug or rearrange the disks so the target device becomes the first one in the eyes of the BIOS.
  4. Still running in the live-CD environment, chroot into the target device root directory, mount all file systems (mount -a), and reinstall the boot loader to the target device.
  5. Reboot, and observe that your system boots from the target device just fine.

Really. I've done something very similar to what's described above a handful of times, and it isn't much more involved than that. You do have to take care while copying files and reinstalling the boot loader, but there's no real magic to it.

a CVn

Posted 2014-05-12T14:07:50.413

Reputation: 26 553

0

I believe since your system hdd is encrypted you can follow the guide here, then simply dd each of the partitions (including the mbr or UEFI, whichever you use) and then clone them onto the ssd. http://help.ubuntu.com/community/ResizeEncryptedPartitions. You would also need to ensure that the partitions are aligned for optimal performance for the ssd.

However another easier method is to simply backup the configuration files, install the OS on the ssd and restore them.

user67350

Posted 2014-05-12T14:07:50.413

Reputation: 26