Return to

HOWTO Clone Fedora 26 from an AHCI SSD to NVMe SSD; TL;DR dracut is your friend



Let’s assume, for the sake of this guide, that you have an AHCI SSD at /dev/sda and a NVMe SSD at /dev/nvme0n1. Commands mentioned here assume you’re running Fedora 26.

Ideally, you’d want to perform the cloning task whilst booted into linux off a Live USB — Ubuntu/Fedora/Debian/<insert your favourite distro here> would work just fine; ideally you’d want to use one that has fairly mature drivers/kernel modules so that you can at least get to a shell and access the two devices listed above.

  • lsblk and blkid are useful to get a mapping of the attached devices and file-system UUIDs.
  • fdisk -l provides a more thorough listing into each device and its partitions etc.

We are going to use dcfldd, although dd will work just as well.

# (Optional) Removing partitions from the M.2 NVMe SSD (data still remains though!)
dd status=progress if=/dev/zero of=/dev/nvme0n1 bs=16M count=1 conv=notrunc

# Clone the AHCI SSD to the NVMe SSD
dcfldd if=/dev/sda of=/dev/nvme0n1 status=on bs=64K
  - or -
dd if=/dev/sda of=/dev/nvme0n1 status=progress bs=64K  

At this point, you may assume that you can remove the AHCI SSD - however, dracut will need configuring to ensure that when the boot loader loads the kernel and initramfs image into memory (and then starts the kernel) that it will load drivers to support nvme.

This needs to be performed first on the AHCI SSD, so we’ll need to re-clone this over to the NVMe SSD afterwards

# Create the following file, with its contents shown below.
[[email protected] ~]# cat /etc/dracut.conf.d/nvme.conf
add_drivers+=" nvme "

# Rebuild the initramfs
[[email protected] ~]# dracut -f

# Clone the AHCI SSD to the NVMe SSD - Once more!
dcfldd if=/dev/sda of=/dev/nvme0n1 status=on bs=64K

That’s it, all you need to do now is issue shutdown -h now, and unplug the AHCI SSD (or wipe it, if that’s your thing…)

Look what.. Look what you just made me do <OH..!>

Hey! I had the same issue a few months ago when I dd’ed from my AHCI SSD to my NVMe SSD, but I didn’t have to dd all over again after generating dracut,by doing the following, and it saved me a good 20 mins:

  1. Turn the computer on with both drives connected (or just dont reboot after dd’ing the ssd→nvme, in which case jump to step 4)
  2. From the GRUB prompt add nvme to modprobe.blacklist
  3. Boot
  4. Backup your current initramfs file by mv’ing it to a safe location e.g. mv /boot/initramfs…{,.bak}
  5. Add the nvme driver to by putting add_drivers+=" nvme" in dracut.conf.d/nvme.conf
  6. Generate the new initramfs file by running dracut (you won’t need to use the -f flag if you backed up initramfs in step 4)
  7. Load the nvme driver (modprobe nvme) and mount your NVMe’s /boot partition e.g. mount /dev/nvme0n1p1 /mnt/alt/boot
  8. Move your newly generated initramfs file from /boot to /mnt/alt/boot
  9. Reboot and disconnect your AHCI drive