Chuck Carroll

How to Clone a LUKS Partition to a New Drive

Published: 2022-09-14

I decided to upgrade the SSD in my laptop from a 256gb NVMe to a 1TB NVMe that I inherited. This was one of those projects I kept putting off because it sounded complicated, but after completing it, that couldn't have been further from the truth. Here are the steps to clone an existing LUKS partition to a new drive and extending it.

These steps will require a USB drive with a live Linux distro with gparted installed (I used Manjaro, but I've yet to come across a distro that didn't include gparted). You'll also need an NVMe enclosure for the new drive. For this scenario, I had my old 256gb drive installed in the laptop and the new 1TB drive installed in the NVMe enclosure.

Note that these instructions will destroy all data on the new drive you're copying the data to, so be sure you verify the device names and re-read your command before executing. I also recommend disconnecting any other storage devices from your machine.

  1. Boot into the live USB.
  2. Unlock the drive, then unmount it with sudo umount /path/to/drive or using the graphical file manager.
  3. Run lsblk in a terminal determine how your drives are identified. For example, my old drive if /dev/nvme0p1 and the new drive is /dev/sdb
  4. , whereas my live USB is sda.
  5. We can now clone nvme0p1 (old drive) to sdb (new drive) by running the following command:
    time sudo dd if/dev/nvme0p1 of=/dev/sdb bs=64k conv=sync,noerror status=progress
  6. Once completed, power off your machine, disconnect the USB drive, install the new drive into your machine, then try booting. If everything went smoothly, it will appear identical to that of the old drive.
  7. Now we will have to extend the partition on the new drive by using gparted. At launch, gparted should immediately notify you about extending your existing partition to the unallocated space. Right click on the existing partition and check 'Resize', extent your partition in the following prompt, then click the green check mark to proceed.

Thanks for reading. Feel free to send comments, questions, or recommendations to hey@chuck.is