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.
-
fdisk -lThis shows the 480GB SSD as
/dev/sdaand the new NVMe device as/dev/nvme0n1. -
Decrypt the
/dev/sda2partition use cryptsetup.cryptsetup luksOpen /dev/sda2 rootfs -
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 /mntI have 179G used which leaves plenty of room.
-
Create the partition table on the NVMe SSD.
fdisk /dev/nvme0n1The 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.
-
Use cryptsetup to format the new LUKS partition.
cryptsetup luksFormat --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 /dev/nvme0n1p2 -
Open the new encrypted partition.
cryptsetup luksOpen /dev/nvme0n1p2 rootnew -
Format with ext4.
mkfs.ext4 /dev/mapper/rootnew -
Format the EFI partition with FAT32
mkfs.fat -F32 /dev/nvme0n1p1 -
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 -
Copy the files over to the new drive.
cp -afv /mnt/old/* /mnt/new/Copying took about an hour to complete.
-
Edit
/etc/fstabto contain the new UUID. Useblkidto list block device UUIDs. -
Edit
/boot/loader/entries/arch.confto contain the LUKS UUID. -
Edit
/etc/mkinitcpio.conf. AddnvmetoMODULES. -
mkinitcpio -p linux -
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.