Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Moved Linux partition GRUB only booting old partition

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
tomcass
Posts: 21
Joined: 2021-09-18 12:40
Has thanked: 1 time
Been thanked: 2 times

Moved Linux partition GRUB only booting old partition

#1 Post by tomcass »

hey everyone,

I recently just had to move/copy my Linux partition because I was running out of space on the old partition. I used GParted to copy the partition to a new area on the hard drive and gave the partition a new UUID.

I did that using a system rescue USB and then after that I booted into my old Debian partition and ran update-grub (i'm using BIOS boot not EFI) so it could update the boot entries for me. It seemed to find the new Linux partition fine and I ended up with 2 entries on the GRUB screen, one named "Debian GNU/Linux 11 (bullseye) (on /dev/sda4)" , sda4 being where the old partition was, and one just called "Debian GNU/Linux".

Now I've ran into a problem that not matter what entry I select on GRUB, it's only booting into my old Debian partition rather than the new one. Unfortunately I'm not smart enough to figure out where to go from here. I know it's something to do with the grub.cfg entries and set root or whatever but I have no idea what I'm doing.

Is anyone able to help me out here? I'd really appreciate it. The most frustrating thing is I actually had to do this before and ran into this exact problem before but can't remember how I solved it last time.

tomcass
Posts: 21
Joined: 2021-09-18 12:40
Has thanked: 1 time
Been thanked: 2 times

Re: Moved Linux partition GRUB only booting old partition

#2 Post by tomcass »

Here are the contents of both the GRUB boot entries.

Code: Select all

load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd0,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3  688af946-92b8-4422-aee9-9018b50b908d
else
  search --no-floppy --fs-uuid --set=root 688af946-92b8-4422-aee9-9018b50b908d
fi
echo	'Loading Linux 5.10.0-9-amd64 ...'
linux	/boot/vmlinuz-5.10.0-9-amd64 root=UUID=688af946-92b8-4422-aee9-9018b50b908d ro iommu=soft quiet
echo	'Loading initial ramdisk ...'
initrd	/boot/initrd.img-5.10.0-9-amd64

Code: Select all

insmod part_msdos
insmod ext2
set root='hd0,msdos4'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos4 --hint-efi=hd0,msdos4 --hint-baremetal=ahci0,msdos4  949ee53d-f8bd-4ed7-bcbe-ac00b4fe997b
else
  search --no-floppy --fs-uuid --set=root 949ee53d-f8bd-4ed7-bcbe-ac00b4fe997b
fi
linux /boot/vmlinuz-5.10.0-9-amd64 root=UUID=688af946-92b8-4422-aee9-9018b50b908d ro iommu=soft quiet
initrd /boot/initrd.img-5.10.0-9-amd64

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Moved Linux partition GRUB only booting old partition

#3 Post by p.H »

As you can see, the UUID in the root= parameter are the same. This is because update-grub used the grub.cfg file in the new system to build the boot entries for the new system, and this file still contains the UUID of the old system.

You must either
- manually update the UUID in /boot/grub/grub.cfg of the new system before running update-grub from the old system
- or manually change the UUID for the new system in /boot/grub/grub.cfg of the old system, then boot the new system and run update-grub from it

Also, you must update the UUID in /etc/fstab of the new system. If you intend to delete or reformat the old partition, you should also reinstall GRUB from the new system before so that it does not use the old partition any more.

Personnal comment : with LVM or btrfs you would not have to move or copy the system ; you would just extend the existing filesystem with available space located anywhere on the disk.

tomcass
Posts: 21
Joined: 2021-09-18 12:40
Has thanked: 1 time
Been thanked: 2 times

Re: Moved Linux partition GRUB only booting old partition

#4 Post by tomcass »

Ah thank you for pointing that out. I've changed the UUID to the new UUID and I have managed to boot into the new partition. I have also edited the fstab accordingly and installed GRUB from the new partition.

Everything is working as it should now but I do have a question about something I noticed in the grub config. My first menu has the set root to hd0,msdos4. The 4th partition on that drive is my swap partition so I would of thought that it shouldn't of booted with that configuration, but somehow it did. After when I ran update-grub to update the menu list, it correctly added the entry as hd0,msdos2 and that entry on GRUB also boots fine. So I'm confused about whether it should be numbered according to the /dev/sda number or the actual order of the partition on the disc as the GRUB manual says.

Segfault
Posts: 993
Joined: 2005-09-24 12:24
Has thanked: 5 times
Been thanked: 17 times

Re: Moved Linux partition GRUB only booting old partition

#5 Post by Segfault »

You don't need LVM or other voodoo, often cleaning out old deb files is enough. Simple symlinking makes it possible to have directories on other filesystems. Some directories can be moved with changing variables.
In any case, running out of space should begin with investigation why it happened.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Moved Linux partition GRUB only booting old partition

#6 Post by p.H »

tomcass wrote: 2021-12-05 22:40 My first menu has the set root to hd0,msdos4. The 4th partition on that drive is my swap partition so I would of thought that it shouldn't of booted with that configuration, but somehow it did. After when I ran update-grub to update the menu list, it correctly added the entry as hd0,msdos2 and that entry on GRUB also boots fine.
If grub.cfg was generated by update-grub and not manually modified, it is unlikely that it set a swap partition as root. Anyway, the "set root" line is just a sensible preset, and the "search" line eventually sets root to the device matching the UUID.
tomcass wrote: 2021-12-05 22:40 So I'm confused about whether it should be numbered according to the /dev/sda number or the actual order of the partition on the disc as the GRUB manual says.
Partition numbers in GRUB and Linux are the same and based on the partition table entries order. If by "actual order" you mean "physical order", it is irrelevant.

Post Reply