- Thread Author
- #1
Migrating The Boot Partition to New Disk
1. Boot from a Live CD- Download any Linux distro (Linux Mint, Kubuntu, Ubuntu... anything. Doesn't have to be the exact copy of the system we are rescuing.) to a USB stick using
You must have 10 posts to see the links. Currently you had 0 posts.
- When booting press F2 (open the boot menu) chose the Live CD and Boot from it.
- Don't install it, chose TRY (safe graphics)
- Use dd to clone your existing boot partition to the new disk.
- Example:
Bash:
sudo dd if=/dev/old_disk_boot_partition of=/dev/new_disk_boot_partition bs=4M
- List your partitions
Bash:lsblk
- Mount the partition that has your Linux installation (nvme0n1p2 in our example)
Bash:mount /dev/nvme0n1p2 /mnt
- Mount the dev, proc, sys and chroot into the system
Bash:mount --bind /dev /mnt/dev mount --bind /proc /mnt/proc mount --bind /sys /mnt/sys chroot /mnt
- After the copy is complete, edit /etc/fstab and replace the old boot partition's UUID with the new one. Find the partition ID with:
Bash:
blkid
- Open the fstab with an editor of your choice nvim/nano/vim
Bash:sudo nano /etc/fstab
- Update GRUB to recognize the changes.
- Example:
Bash:
sudo update-grub
- Use dd or another tool to clone the LUKS partition to the new disk.
- Example:
Bash:
sudo dd if=/dev/old_disk_luks_partition of=/dev/new_disk_luks_partition bs=100M
- After cloning, rename the LUKS device using cryptsetup luksOpen. Make sure to add the same name to /etc/crypttab as used during luksOpen.
Bash:sudo cryptsetup luksOpen /dev/new_disk_luks_partition new_cryptroot
- Open /etc/crypttab and replace the old LUKS device name with the new one.
Bash:sudo nano /etc/crypttab
- Update the initramfs to include the changes.
Bash:sudo update-initramfs -u
Make sure you are chrooted into the system that you are migrating!
Bash:
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub
update-grub
9. Unmount and Verify:
- Unmount everything that we mounted
Bash:umount -l /mnt/sysumount -l /mnt/proc umount -l /mnt/dev umount -l /mnt/boot/efi umount -R /mnt
- Reboot your system and verify that it boots correctly from the new disk.
Bash:reboot
Remove Old Windows Partition (ONLY if needed):
Identify Windows Partition:- Use lsblk or fdisk -l to identify the Windows partition.
-
Bash:
efibootmgr
Bash:efibootmgr -b <Windows_Entry_Number> -B
- While chrooted navigate to your new EFI/BOOT partition (replace /dev/nvme0n1p1 with the actual EFI partition).
Bash:cd /boot/efi/EFI # Remove the Windows folder. rm -r Microsoft
- Update the initramfs to reflect the changes.
Bash:sudo update-initramfs -u
- If dual-booting, remove the Windows entry from GRUB.
Bash:sudo update-grub
- Use fdisk or another partition management tool to remove the Windows partitions.