4

Can I move working boot partition / root filesystem to another drive/partition and just boot from there?

Or device names will be changed and prevent from working?

4

Yes it is possible. Also its not easy. If you intent to move separated /boot partition and or / partition you should consider first of all changing the fstab entries.

If you are moving the files to new partition then don't forget to use cp -p while copying to preserve permissions. adjust then your /etc/fstab to the new UUID's of partitions that you will use. YOu can get the partition uuid by running blkid /dev/sdXn where X is name of the drive and n number of partition.

You can also use blkid to attach labels to your partitions and then mount via labels which is much easier read man blkid to learn more.

After you change the partitions and adjust /etc/fstab you should run the update-grub - available on Debian/Ubuntu script or grub-mkconfig -o /boot/grub/grub.cfg to generate a new config file and then reinstall grub into the first hdd that you bot from. grub-install --recheck /dev/sda

Of course do not forget that when copiying mount a new / or /boot partition on /mnt and after copying all of the files mount them as / and /boot chroot and only then run update of the grub if you want things to be done correctly.

| improve this answer | |
  • Thanks, worked like a charm! Instead of copying file contents, I copied the whole /boot partition with dd and changed the new boot partition UUID using GParted. After that, I followed your instructions to change the /etc/fstab boot entry and do update-grub and grub-install. – Tijs Maas Dec 25 '19 at 1:47
1

If you use UUIDs in /etc/fstab (and other related files that may be relevant in your distro), like /dev/disk/by-uuid/57c59366-9196-4613-ba53-5ad24dcecfb9, and adjust your boot loader configuration if you move your kernel boot partition, then it should work.

| improve this answer | |
  • uuid will not help if he is moving a whole partition content. – MarkoShiva Aug 12 '17 at 17:52
  • I meant if he is creating new partition and moving to that new partition content of /boot that new partition will have different UUID its easier to use labels as its easier to keep track of them. – MarkoShiva Aug 12 '17 at 18:01
0

I just like to mention what I did to move Debian Stretch installed in old MBR style disk which is near to dying and moved the OS to new disk with GPT, in my case ESP(EFI system partition) is present in old disk, so I was already booting using UEFI. I followed answer already given above by user in1t3r .

  1. Get gparted live in usb
  2. Boot with gparted live, select old drive select partition, copy partition
    Select new drive paste partition, save changes. Do this for root(& boot) and ESP(EFI system partition)
  3. Boot to OS in old drive as normal.
  4. Run sudo gdisk, go to new /dev/sdX check ESP partition, if incorrect set to type ef00. (use ? or 'help' command)
  5. Check the UUID of partiotions copied n new drive, use command sudo blkid, (blkid is part of the e2fsprogs package)
  6. If UUID is not different than OLD partition change UUID of new partition copied in new drive,
    Use command, tune2fs -U random /dev/sdXy
    if it ask to run, e2fsck -f /dev/sdbXy , run it then run tune2fs.
  7. Create mount point directory '/newpart' to mount new drive partition.
  8. Mount new drive OS root(and boot) partitions,
    a) root drv; sudo mount /dev/sdbXx /newpart
    b) ESP drv; sudo mount /dev/sdbXy /newpart/boot/efi
  9. We need to update and generate new grub, but for that we need to chroot to new partition as root
    mount dev,proc,sys on '/newpart' dev,proc,sys
    sudo mount --rbind /dev /newpart/dev
    sudo mount --rbind /proc /newpart/proc
    sudo mount --rbind /sys /newpart/sys
  10. Change /etc/fstab on both new OS part (/newpart/etc/fstab) and old to point root(/) and boot if exists to new UUID,
    UUID=[new-part-UUID] , comment the old one
  11. chroot to '/newpart', sudo chroot /newpart
  12. Run
    a) grub-install --recheck
    c) update-grub
    b) grub-install --recheck
    d) exit (to exit from chroot)
  13. Unmount dev,proc,sys (mount --make-rslave needed 1st for recursive umount)
    sudo mount --make-rslave /newpart/sys
    sudo mount --make-rslave /newpart/proc
    sudo mount --make-rslave /newpart/dev
    sudo umount -R /newpart/sys
    sudo umount -R /newpart/proc
    sudo umount -R /newpart/dev
    sudo umount /newpart
  14. Correct the old OS /etc/fstab to point root(/) and boot id exists as before, (NOTE don't change in new disk)
  15. Reboot,
  16. GO to UEFI-BIOS, chose new disk as boot priority
  17. ON rebooting with new drive ESP, Grub menu will appear, go to 1st menu wiz. OS on new drive .
    (Second menu is for OS in old drive)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.