0

About 6 months ago I installed a newly acquired laptop with kubuntu . I opted for a separate /boot (and accepted the default) now, during the upgrade to the next kubuntu version it runs out of space in /boot (it's cleaned up, it's just too small)

boot=sda5 root=sda7

So I thought, OK I'll drop having a separate /boot and just use /boot as a directory on the root partition . So:

  1. created /newboot (on root filesystem)
  2. cp -a /boot/* /newboot (& rmdir /newboot/lost+found)
  3. umount /boot
  4. mv /boot /oldboot, mv /newboot /boot
  5. edit /etc/fstab (mount old /dev/sd5 as /oldboot)
  6. systemctl daemon-reload
  7. update-initramfs -u

Now I diffed /boot/grub/grub.cfg with /oldboot/grub/grub.cfg

And they were identical...huum I thought , well many of the settings there are "suggestions" grub actually goes looking for files ...problem is, there is for example a "good" grub.cfg on both sda5 (msdos5) and sda7 (msdos7) it could find either. So I hand edited all references to msdos5 to msdos7 in grub.cfg and reran update-initramfs -u, rebooted and it all came up fine......

But I had this doubt ... did it use "/boot" or is it still using "/oldboot" ... so on oldboot there were 2 kernels (and initrd) say vmlinuz-6.2.0-36-generic and vmlinuz-6.2.0-35-generic I renamed one to NOT-vmlinuz-6.2.0-36-generic and rebooted. ... it failed , I selected the "35" version and it came up fine....so it's still reading /oldboot.

So what step am I missing . Do I need to hand edit the UUID? Seems very failure prone...feels like there's some simple "regen the grub.cfg" step I'm missing ...reinstall grub?

1 Answer 1

0

Well I can see why nobody jumped in to give a quick answer ...it's way more complicated.

So the trivial bit was

grub-mkconfig -o /boot/grub/grub.cfg

But that's far from the whole story. First more information was needed:

  1. The system uses (old style) BIOS boot
  2. The laptop has a pre-existing "Doze" installation and uses it's initial bootloader + BCD

So first al the above steps are needed. Then the above grub-mkconfig, this makes changes:

root@ThinkPad:/boot/grub# diff grub.cfg.5nov23 grub.cfg
173c173
<   set root='hd0,msdos5'
---
>   set root='hd0,msdos7'
175c175
<     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos5 --hint-efi=hd0,msdos5 --hint-baremetal=ahci0,msdos5  7094b250-3ccf-436e-af52-6c0d828cc15c
---
>     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos7 --hint-efi=hd0,msdos7 --hint-baremetal=ahci0,msdos7  e8128f48-1ef6-44e6-b95c-1595c6ddf05c
177c177
<     search --no-floppy --fs-uuid --set=root 7094b250-3ccf-436e-af52-6c0d828cc15c
---
>     search --no-floppy --fs-uuid --set=root e8128f48-1ef6-44e6-b95c-1595c6ddf05c
179,180c179,180
<   linux   /vmlinuz-6.2.0-36-generic root=UUID=e8128f48-1ef6-44e6-b95c-1595c6ddf05c ro  quiet splash $vt_handoff
<   initrd  /initrd.img-6.2.0-36-generic
---
>   linux   /boot/vmlinuz-6.2.0-36-generic root=UUID=e8128f48-1ef6-44e6-b95c-1595c6ddf05c ro  quiet splash $vt_handoff
>   initrd  /boot/initrd.img-6.2.0-36-generic
191c191
...

In essence: changing SDA5 to SDA7, changing paths from /grub to /boot/grub and the UUIDs.

But the final step needed (in my case) is grub-install /dev/sda7

The reasons are slightly complex, I'll cover 2 cases 1st mine and 2nd the more common one of the initial bootloader being grub (with or without a Doze partition)

Here was my case:

root@ThinkPad:/boot/grub# grub-mkconfig -o /boot/grub/grub.cfg
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.2.0-36-generic
Found initrd image: /boot/initrd.img-6.2.0-36-generic
Found linux image: /boot/vmlinuz-6.2.0-35-generic
Found initrd image: /boot/initrd.img-6.2.0-35-generic
Found memtest86+x64 image: /boot/memtest86+x64.bin
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows 10 on /dev/sda1
done

root@ThinkPad:/boot/grub# grub-install /dev/sda7
Installing for i386-pc platform.
grub-install: warning: Filesystem `ext2' doesn't support embedding.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists.


root@ThinkPad:/boot/grub# grub-install --force /dev/sda7
Installing for i386-pc platform.
grub-install: warning: Filesystem `ext2' doesn't support embedding.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
Installation finished. No error reported.

In my case the laptop boots using the Doze bootloader, it then uses BCD (a boot utility) to allow selection of boot partition ... it used to allow 1 (Doze) or 5 (Kubuntu) , I added 7 (SDA7=root)

So this means the grub bootloader needs to be on /dev/sda7 and as the warning suggests it cannot be embedded (copy of core.img stored early on in a gap at start of disk) so needs to use an UNRELIABLE method ( Sigh!) this is the same state as before this change BTW.

For many other users, they will have grub installed as the initial bootloader. In this case you can just do:

# grub-install  /dev/sda

This is a more common place for grub (and works better)

So I booted this, selected kubuntu-SDA7 as the boot option, it booted fine. I made the above DEBUGGING change (renaming one to NOT-vmlinuz-6.2.0-36-generic) and it sill booted fine ...so it's no longer using /oldboot.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .