Migrating from a 480GB SSD to 400GB NVMe SSD
Mar 9, 2016

I’ll be using the Arch Linux Live ISO.

My configuration

  • Intel 730 480GB SSD
  • Intel 750 400GB NVMe SSD
  • /dev/sda1 is /boot
  • /dev/sda2 is LUKS and mounted as / (ext4)
  • No GRUB bootloader - only EFI

Backup your data!

If both drives were exactly the same size you could just use dd and not worry about copying files. I’ve used the dd method many times when migrating between different SSDs of the same or larger size.

  1. fdisk -l

    This shows the 480GB SSD as /dev/sda and the new NVMe device as /dev/nvme0n1.

  2. Decrypt the /dev/sda2 partition use cryptsetup.

    cryptsetup luksOpen /dev/sda2 rootfs

  3. I’m going to check the remaining space on the drive to make sure there’s enough space on the new drive.

    mount /dev/mapper/rootfs /mnt
    df -h
    umount /mnt

    I have 179G used which leaves plenty of room.

  4. Create the partition table on the NVMe SSD.

    fdisk /dev/nvme0n1

    The first partition will be 512M allocated to EFI. The second partition will be for LUKS and will take up the remaining space on the disk.

  5. Use cryptsetup to format the new LUKS partition.

    cryptsetup luksFormat --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 /dev/nvme0n1p2

  6. Open the new encrypted partition.

    cryptsetup luksOpen /dev/nvme0n1p2 rootnew

  7. Format with ext4.

    mkfs.ext4 /dev/mapper/rootnew

  8. Format the EFI partition with FAT32

    mkfs.fat -F32 /dev/nvme0n1p1

  9. Create new folders for mount points.

    mkdir /mnt/old /mnt/new
    mount /dev/mapper/rootfs /mnt/old
    mount /dev/mapper/rootnew /mnt/new
    mount /dev/sda1 /mnt/old/boot
    mount /dev/nvme0n1p1 /mnt/new/boot
  10. Copy the files over to the new drive.

    cp -afv /mnt/old/* /mnt/new/

    Copying took about an hour to complete.

  11. Edit /etc/fstab to contain the new UUID. Use blkid to list block device UUIDs.

  12. Edit /boot/loader/entries/arch.conf to contain the LUKS UUID.

  13. Edit /etc/mkinitcpio.conf. Add nvme to MODULES.

  14. mkinitcpio -p linux

  15. Shutdown and unplug the old SSD.

If you did everything correctly, on boot it will ask you for the password to unlock the device. If not, check your boot devices in the BIOS.