Page 1 of 1

Lost my UEFI partition

PostPosted: Jun 17th, '21, 16:13
by DiBosco
I'm having a mare with my Mageia 8 installation. It all starts with the fact that the latest nvidia drivers stopped me from booting when I updated. So, I have been running Mageia 8 and doing no updates. Today I installed Mageia 8 on a second HDD, took out my M2 drive (as I'm paranoid about overwriting anything) to see whether the very latest nvidia drivers have solved anything. They don't and to make matters worse, when I put my M2 drive back in it now won't boot. If I use the installer to reinstall Mageia on that M2 drive it tells me there's no UEFI partition (even though you can see it in blue on the installer partitioner page) and it tells me I have to wipe the M2 drive if I want to install again. If I say I'm just upgrading from the Mageia 8 installer, I get to the end and it says:

an error occurred grub2-instll error install device isn't specified

So, my main question is, what can I do to get my bootloader back? Why would it just disappear? Why has my UEFI partion gone? I was every so careful with the M2 drive, and I can boot to a different drive and see all the data on the M2 drive, so I've clearly not destroyed it.

Many thanks.

Re: Lost my UEFI partition

PostPosted: Jun 17th, '21, 18:26
by JoesCat
The problem with UEFI is that we think everything is on the Harddrive/SSD like with MBR, but it's not, there is also information kept in the BIOS.

Pick-up the latest gparted and run it in UEFI mode.
You might need to resize a partition to save the new settings.

Also look at the drive using fdisk and see which partition is marked as Boot. It should be the UEFI partition.

(advice is from memory - might have forgotten something as I don't have those tools in front of me right now)

Re: Lost my UEFI partition

PostPosted: Jun 17th, '21, 18:40
by DiBosco
So are you saying it could actually be a BIOS setting, and because I've attached and unattached drives around something's gone a bit screwy?

I'm not at all clear what I'd need to do with gparted. I'm guessing I'd burn it to a USB stick and boot from that? What partition might I have to resize and why?

fdisk shows this for the drive in question:

Code: Select all
Disk /dev/nvme0n1: 894.25 GiB, 960197124096 bytes, 1875385008 sectors
Disk model: KINGSTON SA1000M8960G                   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 5B4531FA-B072-41FD-A372-8AF990006E7F

Device             Start        End    Sectors  Size Type
/dev/nvme0n1p1      2048     614433     612386  299M EFI System
/dev/nvme0n1p2    616448    2664447    2048000 1000M Linux filesystem
/dev/nvme0n1p3   2664448  100968447   98304000 46.9G Linux filesystem
/dev/nvme0n1p4 100968448  109160447    8192000  3.9G Linux swap
/dev/nvme0n1p5 109160448  125544447   16384000  7.8G Linux filesystem
/dev/nvme0n1p6 125544448  182888447   57344000 27.3G Linux filesystem
/dev/nvme0n1p7 182888448 1875384974 1692496527  807G Linux filesystem

Which shows nothing as boot because, well, it's booting from the spinning platter drive I suppose.

Re: Lost my UEFI partition

PostPosted: Jun 17th, '21, 22:01
by doktor5000
JoesCat wrote:The problem with UEFI is that we think everything is on the Harddrive/SSD like with MBR, but it's not, there is also information kept in the BIOS.

It's not really that much different, you only have a list of boot entries there which you can show with efibootmgr.

Re: Lost my UEFI partition

PostPosted: Jun 18th, '21, 19:12
by JoesCat
Thanks doktor5000 - I thought there would be more than just a table saved into BIOS area.
DiBosco, you won't see this table in the BIOS screens.

There is no partition set to boot.
As an experiment (from my point of view), I'd try set /dev/nvme0n1p1 as boot using fdisk (I'd also check the status of boot on the harddrive - might get lost), shutdown, pull-out the harddrive, and reboot.
/dev/nvme0n1p1 is also very significant as it is the very first location starting at 2048
With older MBR stuff, it used to be the first 256bytes of the harddrive (like DOS OS floppy disks), then they needed more room than 256bytes because there wasn't enough space to bootup win95, sectors also grew larger than 256bytes as well.

I'd suggest using gparted on a usb stick to avoid any possible mangling of the harddrive (example boot), so yes, burning gparted to a usb stick seems more preferable. Just download the iso and then use:
dd bs=1M if=gparted.iso of=/dev/where_ever_your_usb_stick_is_found_using_fdisk

The reason I had suggested resizing a partition was to also re-save new data (by gparted in UEFI mode) into the BIOS area.
Don't resize /dev/nvme0n1p1, swap, or /dev/nvme0n1p? which holds /boot or /
because newer ISOs put a lot more into /usr I'd avoid touching that too, that would leave /home as a likely candidate.
If you don't know which partition is which, you can take a look:
md /mnt/a
mount /dev/nvme0n1p7 /mnt/a
ls /mnt/a
umount /mnt/a

If you're worried about losing info, then clone the M2 drive first.
md mnt/b
umount /dev/backupdevice (sometimes these get auto-mounted under user, but you want su access)
mount /dev/backupdevice
md /mnt/b/myclone
dd bs=100M if=/dev/nvme0n1 | gzip -c | split -b 638m - /mnt/b/myclone/backup.img.gz.

restoring is something like this:
cat /mnt/b/myclone/backup.img.gz.* | gzip -dc | dd bs=100M of=/dev/nvme0n1

If this makes you nervous, just read through this page:
The reason for breaking the image up into small pieces is to allow you to save on vfat (limited to 2GB-1byte file size).
I could be in error, could be /dev/nvme0n1p instead of /dev/nvme0n1 - just check your cloned backup size if too small.