Cloning Encrypted SSD to larger SSD

Solution 1:

Assumptions:

Because I cannot comment on your post I am going to have to assume some things:

  1. Your SSD mount point is located at /dev/sdX
  2. Your bigger SSD mount point is located at /dev/sdY
  3. You are using LUKS full disk encryption
  4. Your encrypted partition is /dev/sdX1
  5. The unecrypted mount point where your file system is located is /dev/mapper/sdX1_crypt and it is using an ext4 file system

Easier Method:

The easiest and slowest way would be to use dd

sudo dd  if=/dev/sdX of=/dev/sdY bs=64k  

to copy every byte from the smaller SSD to the larger SSD. This would give you a fully boot-able system you would have to disconnect the smaller SSD in order to boot because both SSDs share the same UUID which the system uses to identify individual disks. Before booting you would expand the physical partition using fdisk.

sudo fdisk /dev/sdY

fdisk is an interactive tool, you would first delete the partition LUKS is on (because its ending address is shorter than the new bigger SSD), then you would create a new partition (the defaults fdisk uses will fill all unused space), then save (this is how software "extends" a partition). then you would expand the LUKS container using cryptsetup

sudo cryptsetup luksOpen /dev/sdY1 sdY1_crypt
sudo cryptsetup resize /dev/sdY1_crypt

and finally you would expand the files system using resize2fs

sudo resize2fs /dev/mapper/sdY1_crypt

Faster Method:

A faster and more complex method would be to create a new partition sdY1 with fdisk on the bigger SSD for the encrypted volume, then create a new LUKS volume using

sudo cryptsetup luksFormat [OPTIONS] /dev/sdY1

and mount it on sdY1_crypt.

sudo cryptsetup luksOpen /dev/sdY1 sdY1_crypt

then use dd to copy the unencrypted file system from one encryption volume to another.

sudo dd if=/dev/mapper/sdX1_crypt of=/dev/mapper/sdY1_crypt bs=64k

then expand the file system with resize2fs

sudo resize2fs /dev/mapper/sdY1_crypt

In order to be able to boot from the new bigger SSD you would have to install grub in the MBR of the SSD with

grub-install [OPTIONS] /dev/sdY

Note:

All the commands used are highly configurable and you will want to use some of their options because you know your system better than I do, use man <command> or <command> --help to learn about what they can do.

Solution 2:

I'd like to add some information to this thread that could help others.

As of todays date (Oct 27th 2019) I can assert the easiest method for others trying to clone a full disc encrypted system (LVM on LUKS) will be a combination of clonezilla and gparted.

Use a live USB of clonezilla and drop to a shell when first booted, decrypt both disks with cryptsetup -v luksOpen /dev/sdX unique-name for each disk.

Re-enter clonezilla's menu by exiting the shell prompt (Ctrl -D or just exit)

Then start a disk-to-disk transfer, for my 2 SSD's (one hooked up by usb external caddy) of 500Gb and 1Tb it took around 3 hours.

Reboot to the newly cloned disk to check it functions then boot from a gparted live cd / usb. As of Gparted 0.28 it now supports resizing luks partitions, grow the partition after decrypting and voila!

IT JUST WORKS