convert grub2 mbr boot to uefi

This forum is dedicated to advanced help and support :

Ask here your questions about advanced usage of Mageia. For example you may post here all your questions about network and automated installs, complex server configurations, kernel tuning, creating your own Mageia mirrors, and all tasks likely to be touchy even for skilled users.

convert grub2 mbr boot to uefi

Postby jiml8 » Nov 13th, '21, 22:15

A few months back, I posted this topic: viewtopic.php?f=8&t=14149 in which I discussed my plan to move from an old grub mbr boot to a new uefi boot.

Well, since posting that, I have purchased a 2TB Samsung 980 Pro SSD and I have moved all my day to day virtual machines onto it. When I first set it up, I did so planning to move to UEFI boot, so I configured it as follows:
Code: Select all
parted -/dev/nvme0n1
(parted) print
Model: NVMe Device (nvme)
Disk /dev/nvme0n1: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name        Flags
 1      1049kB  269MB   268MB                            bios_grub
 2      269MB   55.8GB  55.6GB  ext4
 3      55.8GB  56.4GB  537MB   fat32        EFI-System  boot, esp
 4      56.4GB  2000GB  1944GB
 


The second partition was targeted to become my new system partition, and the 4th partition is encrypted, holds the VMs and will ultimately also hold most of /home and /var.

So I rolled with this framework for awhile because I was much too busy doing other things.

Today, I decided to make the conversion. So, I rsync'ed my system into the second partition, then mount -o bind all the necessary filesystems onto the mount points in the new system partition (the second partition), then I chrooted into that partition to do the work.

I made the necessary changes to the fstab in the new system partition, specifically, I created these lines:
Code: Select all
#EFI entry
/dev/disk/by-partlabel/EFI-System /boot/efi vfat defaults,umask=000 0 2
# Entry for /dev/nvme0n1p2
LABEL=NEWSYSTEM / ext4 defaults 1 1


Then, I mounted /boot/efi.

After that, I ran this command:
Code: Select all
grub2-install --target=x86_64-efi /dev/nvme0n1


This command ran correctly, reporting the following (expected) errors:
Code: Select all
EFI variables are not supported on this system.


I then exited the chroot and rebooted, entered BIOS and changed the boot setting to UEFI only. Saved the configuration, and tried to boot.

The system did not find any UEFI boot volumes. After some fiddling around, I set the BIOS to accept either UEFI or mbr, and it booted using grub2, though there were no nice skins, screens, or fonts on the boot.

So, at this point I have successfully migrated my system from an old mbr SSD running grub to a new gpt SSD running grub2, but I have not managed to get it to boot as UEFI.

Having hunted around on the internet, I am seeing people claiming there are lots of files in the /boot/efi directory, but I do not have that.

For instance, this link https://www.redhat.com/sysadmin/bios-uefi shows the following:
Code: Select all
[root@localhost ~]# du /boot/efi
8       /boot/efi/System/Library/CoreServices
12      /boot/efi/System/Library
16      /boot/efi/System
2508    /boot/efi/EFI/fedora/fonts
17988   /boot/efi/EFI/fedora
2748    /boot/efi/EFI/BOOT
20740   /boot/efi/EFI
20764   /boot/efi
[root@localhost ~]# df -h /boot/efi
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       623M  237M  340M  42% /boot

[root@localhost ~]# find /boot/efi -name shim\*
/boot/efi/EFI/fedora/shimx64.efi
 
/boot/efi/EFI/fedora/shim.efi
/boot/efi/EFI/fedora/shimia32.efi
/boot/efi/EFI/fedora/shimx64-fedora.efi
/boot/efi/EFI/fedora/shimia32-fedora.efi


I have nothing resembling that in my /boot/efi. Here is what I show:
Code: Select all
4.0K    /boot/efi/dracut
4.0K    /boot/efi/EFI/EFI/mageia
8.0K    /boot/efi/EFI/EFI
128K    /boot/efi/EFI/mageia
140K    /boot/efi/EFI
412K    /boot/efi/grub
2.4M    /boot/efi/grub2/i386-pc
124K    /boot/efi/grub2/locale
2.5M    /boot/efi/grub2/fonts
5.0M    /boot/efi/grub2
126M    /boot/efi


The i386 entry is spurious when I entered a command incorrectly, I believe. I have not attempted to remove it because maybe it does belong there. Not sure, and the system does boot.

So, I seem to be missing some files needed for UEFI, but I don't see what they could be. Does anyone here know?

Now, while I describe a nice, clean, straightforward progression in this post, in reality it was much messier, with a fair amount of fumbling, following different recipes, and starting over. So it is entirely possible that there is some artifact of a previous attempt somewhere that is breaking things for me now; I don't know.

Can anyone steer me at this point?
jiml8
 
Posts: 1253
Joined: Jul 7th, '13, 18:09

Re: convert grub2 mbr boot to uefi

Postby benmc » Nov 14th, '21, 04:22

not sure if the following of any help,

Code: Select all
[root@localhost ~]# cd /boot
[root@localhost boot]# ls
config-5.10.16-desktop-1.mga8  initrd-5.10.16-desktop-1.mga8.img  System.map-5.10.16-desktop-1.mga8
config-5.10.19-desktop-1.mga8  initrd-5.10.19-desktop-1.mga8.img  System.map-5.10.19-desktop-1.mga8
dracut/                        initrd-desktop.img@                vmlinuz@
efi@                           initrd.img@                        vmlinuz-5.10.16-desktop-1.mga8
EFI/                           symvers-5.10.16-desktop-1.mga8.xz  vmlinuz-5.10.19-desktop-1.mga8
grub2/                         symvers-5.10.19-desktop-1.mga8.xz  vmlinuz-desktop@
[root@localhost boot]# cd /boot/EFI
[root@localhost EFI]# ls
EFI/
[root@localhost EFI]# cd /boot/EFI/EFI
[root@localhost EFI]# ls
BOOT/  mageia/
[root@localhost BOOT]# cd /boot/EFI/EFI/mageia
[root@localhost mageia]# ls
grubx64.efi*


the important entry here is the grubx64.efi.

Check your UEFI bios for a Mageia entry. if it is not there, the UEFI will not even look for the Mageia boot file.

have you considered downloading the netinstall 64bit medium, boot it up into UEFI mode, choose "rescue" and try a boot re-install?
benmc
 
Posts: 1175
Joined: Sep 2nd, '11, 12:45
Location: Pirongia, New Zealand

Re: convert grub2 mbr boot to uefi

Postby jiml8 » Nov 14th, '21, 07:12

The contents of my /boot/efi/EFI/mageia are:
Code: Select all
drwxrwxrwx 3 root root   4096 Nov 13 15:01 ./
drwxrwxrwx 4 root root   4096 Nov 13 09:55 ../
drwxrwxrwx 2 root root   4096 Oct 19  2018 fw/
-rwxrwxrwx 1 root root  69936 Oct 19  2018 fwupx64.efi*
-rwxrwxrwx 1 root root 123904 Nov 13 15:02 grubx64.efi*


So, I do have the grubx64.efi apparently in the right place.

Now, when I wrote the original post, the grubx64.efi was the only file in that directory, but after writing that post I did download a few packages from the repos that were related to efi and installed them, thinking it would help. This is where the fw directory and fwupx64.efi package came from.

Since that time, I have not rebooted because I have put the system back into production. I likely will take it down for a reboot before very long because I really would like to get this figured out.

As for a mageia entry in the UEFI BIOS, I don't know if it will give me that (it is a current generation ASUS mobo). It shows boot volumes that it recognizes, and allows me to choose among them. Last time I tried, when set to UEFI only, it did not recognize any boot volumes.
jiml8
 
Posts: 1253
Joined: Jul 7th, '13, 18:09

Re: convert grub2 mbr boot to uefi

Postby jiml8 » Nov 14th, '21, 07:21

OK, I just rebooted, and still cannot do UEFI

Maybe I should study the mobo manual and see if maybe there is some setting I am missing. Don't think so, but I'm pretty well stumped for now.
jiml8
 
Posts: 1253
Joined: Jul 7th, '13, 18:09

Re: convert grub2 mbr boot to uefi

Postby benmc » Nov 14th, '21, 07:28

set boot to UEFI mode.
at boot up (before grub) F8 will bring up a list of bootable entries (Asus P8B75M-LX)

if Mageia is there, you can boot into it .

if not, it means that mageia entry has not been entered into nvram. (mobo device)
only way I know to get it there is via boot repair or original install.
..........................................

Edit:

when you chrooted into the mageia system, were you in a UEFI or mbr/legacy mode?

maybe a bad thought: can you boot into a UEFI mode of any Live Mga 7/8 install media.
check the esp partition is active via diskdrake then re-install the boot loader again from the Live.
benmc
 
Posts: 1175
Joined: Sep 2nd, '11, 12:45
Location: Pirongia, New Zealand

Re: convert grub2 mbr boot to uefi

Postby doktor5000 » Nov 14th, '21, 15:30

benmc wrote:if not, it means that mageia entry has not been entered into nvram. (mobo device)
only way I know to get it there is via boot repair or original install.

Entries there can be listed and also added/edited via efibootmgr.
https://wiki.archlinux.org/title/EFISTUB#efibootmgr or https://wiki.gentoo.org/wiki/Efibootmgr#Usage show some examples.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17629
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: convert grub2 mbr boot to uefi

Postby jiml8 » Nov 15th, '21, 02:23

at boot up (before grub) F8 will bring up a list of bootable entries (Asus P8B75M-LX)


I will bet this is the answer. I was expecting a list in bios of available boot volumes; the idea of hitting F8 prior to bios did not occur to me. Also, the manual for my board (Asus X570 Plus) has that line in it, though it is not prominent, is found in a section focused on Windows, and I overlooked it for awhile.

I have not had a chance to reboot again. I will do that in the next day or so and see if this takes care of it. Hope so.
jiml8
 
Posts: 1253
Joined: Jul 7th, '13, 18:09

Re: convert grub2 mbr boot to uefi

Postby jiml8 » Nov 15th, '21, 03:25

I will also note that the installation of grub2 did not carry over the command line arguments for the kernel that were in grub. I don't know if there is a way to do this automatically or not. I had to learn how to add those command line arguments in grub2 myself.

Just a detail, but it did cause some stability issues until I figured out what was going on. And, actually, it is a big part of why I don't want to reboot now; aside from the fact that I have been getting some work done, I am checking stability.

I have been running my system off of SSDs for several years now, but I must say that this 980Pro nvme4 device is very noticeably faster. Open Office is up in about a second.
jiml8
 
Posts: 1253
Joined: Jul 7th, '13, 18:09

Re: convert grub2 mbr boot to uefi

Postby doktor5000 » Nov 15th, '21, 17:54

jiml8 wrote:I will also note that the installation of grub2 did not carry over the command line arguments for the kernel that were in grub. I don't know if there is a way to do this automatically or not. I had to learn how to add those command line arguments in grub2 myself.

Not sure what you mean in particular, but there's no relation between grub legacy and grub2 configuration IMHO. grub2 doesn't read legacy configuration and also stores things differently.
In grub legacy you used to directly edit /boot/grub/menu.lst which was the interim and resulting configuration file. In grub2 you edit /etc/default/grub and there usually GRUB_CMDLINE_LINUX_DEFAULT
which contains the default command line options that are read by each and every generated grub2 configuration (which are not mean to be edited directly) and grub2 generated configuration is updated by update-grub or grub2-mkconfig.
Hope that helps.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17629
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: convert grub2 mbr boot to uefi

Postby jiml8 » Nov 15th, '21, 18:17

Yes, I did learn about /etc/defaults/grub after not very much reading. I was not surprised, really, about the command line from grub not being carried into grub2, I just did not think about it until I had trouble and investigated.

The arguments on the command line in grub are:
Code: Select all
splash quiet acpi_enforce_resources=lax nomksboot nokmsboot net.ifnames=0 rd.driver.blacklist=nouveau vga=788


while the arguments I currently have in the grub2 boot are:
Code: Select all
acpi_enforce_resources=lax vga=788 splash

where I added the acpi_enforce_resources (as described in viewtopic.php?f=41&t=14148) and the vga788 whose lack seems to have caused some video instabilities that were so severe that for a few minutes I thought my video card had failed.

I have not found the driver blacklist to be needed any more; I suppose it was legacy. The net.ifnames used to matter in an earlier iteration of systemd so that I could keep control of the naming of my interfaces, but apparently it no longer is needed.

I don't know about the nomksboot and nokmsboot entries; so far it has not bitten me in any way I have noticed. My reading suggests these are Mageia-only, and associated with Radeon video; I use Nvidia. Those entries have been there forever; they might now be legacy and unneeded.
jiml8
 
Posts: 1253
Joined: Jul 7th, '13, 18:09

Re: convert grub2 mbr boot to uefi

Postby doktor5000 » Nov 15th, '21, 22:59

The vga= parameter is required to set the framebuffer resoution when using the proprietary nvidia driver.
nomksboot is a typo. nokmsboot aka nomodeset is also used for the proprietary driver so that X will set the graphic resolution, and not the kernel, and those are not Mageia-only.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17629
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: convert grub2 mbr boot to uefi

Postby jiml8 » Nov 16th, '21, 21:58

Well, I just rebooted, went into BIOS, set it to UEFI only, reset, and hit F8. It did not show me any bootable devices.

So I went back into BIOS, set it to either UEFI or MBR, reset, hit F8, and had choices.

So I have failed to get and EFI boot to work.

doktor5000 wrote:The vga= parameter is required to set the framebuffer resoution when using the proprietary nvidia driver.
nomksboot is a typo. nokmsboot aka nomodeset is also used for the proprietary driver so that X will set the graphic resolution, and not the kernel, and those are not Mageia-only.


Historically, for a long time, I booted with nokmsboot and vga=788, and I always observed a slow memory leak that over a few weeks would cause me to have to restart my user session. For the last couple of days, the system has been running with neither of these options set, and I have observed no evidence at all of a memory leak.

Is there a particular reason to prefer or not prefer these options? I never set them, as I recall; they came with Mageia way back when I first installed Mageia 2.
jiml8
 
Posts: 1253
Joined: Jul 7th, '13, 18:09

Re: convert grub2 mbr boot to uefi

Postby doktor5000 » Nov 16th, '21, 23:45

jiml8 wrote:Is there a particular reason to prefer or not prefer these options? I never set them, as I recall; they came with Mageia way back when I first installed Mageia 2.

As mentioned, vga= is only if you want to change the framebuffer resolution. And you don't need nomodeset if the proprietary nvidia driver works without it.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17629
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany


Return to Advanced support

Who is online

Users browsing this forum: No registered users and 1 guest

cron