0

I am trying to convert my legacy bios LVM-based Ubuntu 16 installation so that I can run it on a NUC that only supports UEFI. I have been round the houses on this:

Boot-Repair - doesn't work chroot with grub-install - doesn't work

with many variations in between. Here are the details:

three partitions: /dev/sda1 - current /boot partition containing linux images, ext2 /dev/sda2 - current /root partition using LVM /dev/sda3 - new EPS partition formatted using FAT32, boot flag set

I have tried chroot-ing into the root partition, mounting sda1 as /boot and sda3 as /boot/efi and then using grub-install - succeeds but not boot (e.g. exactly this https://www.shellhacks.com/reinstall-grub-from-live-usb-uefi-lvm/)

Questions:

  • my target system is i386 but you can only get UEFI enabled live images for x64 - does this matter?
  • does my target system version need to match my live version?
  • does it matter that I have both a /boot partition and a /boot/efi partition?
  • does it matter that my efi partition is not first?
  • how do I tell what a properly configured system looks like?

any clues as to how to get this working? I have spent hours on this

UPDATE: this is almost certainly because my UEFI firmware only supports 64-bit and the system I am trying to boot is 32-bit. Given that I plan to try and upgrade everything anyway I am first going to try a chroot multiarch upgrade and see if that gets me into a position where I can boot with 64-bit grub EFI

8
  • 1
    Is there a particular reason you’re doing this using a seven-year-old system rather than a more recent version of Ubuntu? Aug 12, 2023 at 21:42
  • It's a mail server on a supported LTS version - never had a reason to upgrade, but I obviously will now if I can get it to boot
    – Andy Piper
    Aug 12, 2023 at 21:45
  • 2
    "i386" usually implies a 32-bit x86 system. UEFI can be either 32- or 64-bit, and modern hardware is usually 64-bit. Even the oldest Intel NUCs seem to be 64-bit. Running a 32-bit OS on 64-bit hardware may be possible, but could be wasteful, as the system has more than 4 GB of memory, so a 32-bit system cannot use all of it efficiently. A 32 -> 64-bit "conversion" is essentially a full reinstallation anyway.
    – telcoM
    Aug 12, 2023 at 23:26
  • 1
    @peterh the literal opposite of what you claim about UEFI and books had been the case in my experience, plus the experience I hear when I talk to people that do bootloaders. UEFI is the modern, unified standard, and bios is a land of tears and bespoke idiocy. Aug 13, 2023 at 5:25
  • 1
    Intel removed BIOS support from all recent NUCs - no chance of using BIOS support
    – Andy Piper
    Aug 13, 2023 at 6:57

1 Answer 1

1

There are several different GRUB versions for different system architectures: for a BIOS-based system, your OS has packages grub-pc and grub-pc-bin installed.

To be able to install the UEFI version of GRUB, you will need to install packages grub-efi-amd64 and grub-efi-amd64-bin if your UEFI firmware is 64-bit (= the usual case), or grub-efi-ia32 and grub-efi-ia32-bin if your UEFI firmware is 32-bit (rarer but possible).

The instructions you linked seem to have a built-in assumption that you are reinstalling the same architecture version of GRUB that was there originally. In your case, that is not true. You might need to specify the architecture explicitly for the grub-install command:

grub-install --force-extra-removable --target=x86_64-efi /dev/sda

assuming that /dev/sda is your system disk (adjust as required).

If you had a 32-bit UEFI firmware, then you should use the option --target=i386-efi instead.

The --force-extra-removable tells grub-install to place a second copy of the bootloader file to a removable media/fallback location on the ESP partition, which simplifies the initial start-up process if grub-install cannot access the UEFI boot variables to program in the real location.

4
  • You say "firmware", this is presumably what is on the motherboard and cannot be changed? Do the grub packages need to be installed on the "live" system I am doing the maintenance with or on the target system. Since the target system is a i386 installation I am thinking it doesn't have the grub x64 packages - I'm presuming this matters.
    – Andy Piper
    Aug 13, 2023 at 7:05
  • And here is a German page possibly telling me how to do this: wiki-ubuntuusers-de.translate.goog/Howto/…
    – Andy Piper
    Aug 13, 2023 at 7:20
  • At least the amd64 architecture includes installable packages of both 32-and 64-bit GRUB. The i386 architecture might too, as it is conceivable that a 32-bit system might sometimes be used to fix errors of a 64-bit system's boot disk. But to minimize future migration pain, you might bite the bullet and install a fresh minimal 64-bit system on the NUC, then add the 64-bit versions of all the same packages you have currently installed on the i386 system, and then migrate configuration files and data over (essentially rsync'ing the /etc of the i386 system over to the NUC and adjusting).
    – telcoM
    Aug 14, 2023 at 12:45
  • ... Then test to your satisfaction, and then switchover (replace the old system with the new one, possibly with a final rsync of data first) at a convenient time.
    – telcoM
    Aug 14, 2023 at 12:46

You must log in to answer this question.

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