Moving a Linux Installation to Another Drive the Ungainly Way

Notes

This is a record of one migration, not a partition layout you should copy. Partitioning and boot repair can destroy data or leave a computer unable to boot. Back up important files first, identify every disk and partition by its current device name, and do not delete or overwrite partitions just because I did so here.

I had Linux on an external drive and wanted to move it to my NVMe drive, which I had been using mostly for Windows. My first instinct was to boot WinPE and copy partitions with a Windows partition tool rather than do everything from Linux. That was not the most elegant route, but it is the one this note documents.

The machine used UEFI and GRUB for a Windows/Linux dual boot.

Copy the partitions

I shrank the Windows partition in WinPE. I also deleted the Windows recovery partition, without knowing what consequences that might have. I deleted the Windows EFI partition too; if you still need GRUB to start Windows, do not do that unless you are prepared to repair Windows Boot Manager afterward.

Using a partition tool such as DiskGenius or AOMEI Partition Assistant, I copied the existing EFI and Linux root partitions into free space on the NVMe drive and created a Linux swap partition. The partition sizes and filesystem layout on your machine may be different. Do not assume that copying this layout is safe for your disks.

After rebooting, GRUB would not start, so I booted a Debian installer USB and entered Rescue Mode. I selected the Linux partition on the NVMe drive and mounted /boot/efi when prompted.

Reinstall GRUB

In the rescue shell, I followed Debian’s GRUB EFI reinstall guide. I mounted efivarfs so that GRUB could access EFI variables:

mount -t efivarfs none /sys/firmware/efi/efivars

Mount the other required filesystems for your installation, following the Debian guide. My setup had only one Linux partition, so I had fewer mounts to handle. Then reinstall GRUB and regenerate its menu:

grub-install /boot/efi
update-grub

If update-grub is skipped, the next boot may open the GRUB command line instead of the menu.

Repair Windows Boot Manager if needed

Because I had deleted the Windows EFI partition, I used a UEFI repair tool in WinPE to restore Windows Boot Manager. This step should not be necessary if you preserve the Windows EFI partition and its boot files.

Add Windows to the GRUB menu

After booting Linux, I checked whether os-prober could see Windows:

sudo os-prober

If it finds Windows, set GRUB_DISABLE_OS_PROBER=false in /etc/default/grub, then rebuild the menu:

sudo update-grub

Reboot and check that both operating systems appear. Your distribution’s GRUB defaults may differ.

A problem I did not solve

After the migration, Linux startup paused for a while after printing logs. Once GDM started, the screen showed only a white text cursor, and the login screen appeared much later. I saw a gnome-shell segmentation fault in dmesg but did not diagnose the cause. Reinstalling might have been simpler; this note does not provide a fix for that issue.