How to clone a LUKS-encrypted HDD to a larger SSD

Migrating LUKS-encrypted drive to a larger one is actually quite simple if you have gparted:

  1. If the drive is not unlocked, unlock it as usual.
  2. If the unlocked drive is mounted, unmount it: sudo umount /path/to/unencrypted-volume
  3. Figure out the device name: lsblk, look for type crypt, e.g. /dev/sdb, and check which device name is the last one.
  4. Plug in the new drive and run lsblk again, a new device, e.g. /dev/sdc or simply sdc has been added.
  5. Clone drive sdb to sdc (CAREFUL, ALL DATA WILL BE OVERWRITTEN ON THE TARGET DRIVE!): time sudo dd if=/dev/sdb of=/dev/sdc bs=64K conv=sync,noerror status=progress
  6. Afterwards you will have to resize the larger target drive: sudo gparted will open the partition editor.
  7. Select the target drive that you want to extend. The LUKS partition on that drive will likely have a warning icon right next to the partion name. Using the menu select Partition > Check and click the check mark icon to run the check and repair routines.
  8. After those routines have finished, the partition should be extended.
Jan Beilicke

About the author

Long-time IT professional and full-time nerd. Open source enthusiast, advocating security and privacy. Sees the cloud as other people's computers. Find me on Mastodon or Twitter.