How can I create an automated grub rescue disk for Gen8 Microservr?

0

I have a HP Gen8 Microservr since 2016 and after a format I can't boot it normally anymore.

Here is the quite complicated setup :

  • SATA port 1 : ssd with debian (from wich I used to boot...),
  • SATA ODD & SATA port 2, 3, 4 : 3TB drives assembled in raid 5,

I know it's not recommended but for many monthes I managed to boot directly to the first sata drive without the help of a grub usb boot key

What works :

I can boot from a "live" usb key OR "Grub rescue key". First option to format and install, second option to choose debian and boot.

This option is quite annoying, since this machine doesn't have a screen and I have to press 3 keys to boot...

What doesn't work :

  • boot directly to SSD. Whatever the grub-install options, the bios will never boot from it. It used to work for years... I always managed to boot from first SATA drive (with or without other disks installed). I tried AHCI, legacy sata, b120i and every other option I could find in the bios and iLO
  • boot from a grub-install usb key. It also worked for years but now it doesn't. I can't figure why. Also I tried every usb port, internal, external and SD card.
  • boot from ODD. It never worked directly, as I knew it wouldn't when I bought it back in 2016.

What I can't figure

Why can I boot from a "rescue key" / "live key" but not from a grub specific install ? How can I create a bootable grub-key ?

and what I noticed :

  • USB rescue Key and USB live keys have 3 partitions as shown below :
GPT PMBR size mismatch (26747 != 4014079) will be corrected by write.
Disk /dev/sdf: 1.9 GiB, 2055208960 bytes, 4014080 sectors
Disk model: Flash Disk
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: F66396F0-7517-4347-8374-89816EFB2200

Device     Start   End Sectors  Size Type
/dev/sdf1     64   275     212  106K Microsoft basic data
/dev/sdf2    276  6035    5760  2.8M EFI System
/dev/sdf3   6036 26699   20664 10.1M Microsoft basic data
  • depending on grub-install options, grub bootloader keys have one or two partitions like :
Disk /dev/sdg: 3.8 GiB, 4009754624 bytes, 7831552 sectors
Disk model: STORE N GO
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: dos
Disk identifier: 0x00000000

So here's my final question :

Is there a way to boot directly without manual intervention ?

It used to work, like three days ago, but I formated the disk since and I can't figure what I dit that was working. I'm quite ashamed, but that's it !

Thanks in advance for your help :)


Some outputs

  • fdisk -l
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
Disk model: KINGSTON SV300S3
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: dos
Disk identifier: 0x17bc4435

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048 234430463 234428416 111.8G 83 Linux
/dev/sda2       234432510 468860927 234428418 111.8G  5 Extended
/dev/sda5       234432512 468860927 234428416 111.8G 83 Linux


The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sdb: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors
Disk model: WDC WD30EFRX-68E
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 547F77B6-7490-46FC-B9AC-AEC3498FC700


Disk /dev/md127: 8.2 TiB, 9001374842880 bytes, 17580810240 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 524288 bytes / 1572864 bytes


Disk /dev/sdc: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors
Disk model: WDC WD30EFRX-68E
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sdd: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors
Disk model: WDC WD30EFRX-68E
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 38106669-3829-48CD-8584-2F4EA3D6E2DC


The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sde: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors
Disk model: WDC WD30EFRX-68E
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 2AA10B22-E7E8-4C0B-B580-F0F7D4C0A23D


GPT PMBR size mismatch (26747 != 4014079) will be corrected by write.
Disk /dev/sdf: 1.9 GiB, 2055208960 bytes, 4014080 sectors
Disk model: Flash Disk
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: F66396F0-7517-4347-8374-89816EFB2200

Device     Start   End Sectors  Size Type
/dev/sdf1     64   275     212  106K Microsoft basic data
/dev/sdf2    276  6035    5760  2.8M EFI System
/dev/sdf3   6036 26699   20664 10.1M Microsoft basic data
  • parted -l
Model: ATA KINGSTON SV300S3 (scsi)
Disk /dev/sda: 240GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End    Size   Type      File system  Flags
 1      1049kB  120GB  120GB  primary   ext4         boot
 2      120GB   240GB  120GB  extended
 5      120GB   240GB  120GB  logical   ext4


Error: The primary GPT table is corrupt, but the backup appears OK, so that will
be used.
OK/Cancel?
OK/Cancel? ok
Model: ATA WDC WD30EFRX-68E (scsi)
Disk /dev/sdb: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start  End  Size  File system  Name  Flags


Error: /dev/sdc: unrecognised disk label
Model: ATA WDC WD30EFRX-68E (scsi)
Disk /dev/sdc: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: unknown
Disk Flags:

Error: The primary GPT table is corrupt, but the backup appears OK, so that will be used.
OK/Cancel? ok
Model: ATA WDC WD30EFRX-68E (scsi)
Disk /dev/sdd: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start  End  Size  File system  Name  Flags


Error: The primary GPT table is corrupt, but the backup appears OK, so that will be used.
OK/Cancel? ok
Model: ATA WDC WD30EFRX-68E (scsi)
Disk /dev/sde: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start  End  Size  File system  Name  Flags


Model: Generic Flash Disk (scsi)
Disk /dev/sdf: 2055MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name                Flags
 1      32.8kB  141kB   109kB                Gap0                hidden, msftdata
 2      141kB   3090kB  2949kB               EFI boot partition  boot, hidden, esp
 3      3090kB  13.7MB  10.6MB  hfs+         Gap1                hidden, msftdata


Model: Linux Software RAID Array (md)
Disk /dev/md127: 9001GB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system  Flags
 1      0.00B  9001GB  9001GB  ext4


Model: Verbatim STORE N GO (scsi)
Disk /dev/sdg: 4010MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system  Flags
 1      0.00B  4010MB  4010MB  fat32
linux
hard-drive
boot
partitioning
grub
asked on Super User Mar 24, 2021 by qkzk

1 Answer

1

Well... I managed to do it.

Basically I removed some steps from this answer

Here are the steps I followed :

# install grub EFI
sudo apt-get install grub-efi-amd64-bin
# used later to get the MBR file
sudo apt-get install syslinux-common

Then I inserted a key, fdisk told me it was at /dev/sdg

# create a GPT table
sudo parted /dev/sdg --script mktable gpt
# create a 9MiB UEFI VFAT partition
sudo parted /dev/sdg --script mkpart EFI fat16 1MiB 10MiB
# and a protected MBR partition table
sudo parted /dev/sdg --script set 1 msftdata on
# fs vfat
sudo mkfs.vfat -n EFI /dev/sdg1
# create a folder to mount the key
mkdir /tmp/usb-efi
sudo mount /dev/sdg1 /tmp/usb-efi
# grub install EFI mode, on the key
sudo grub-install --no-uefi-secure-boot --removable --target=x86_64-efi --boot-directory=/tmp/usb-live/boot/ --efi-directory=/tmp/usb-efi /dev/sdg
# MAGIC copy the MBR GPT the bios can read
sudo dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/mbr/gptmbr.bin of=/dev/sdg
sudo umount /dev/sdg*

And it works. The bios manages to find the key and boot from it... The splash screen is quite ugly, a little tuning might be welcome :)

answered on Super User Mar 24, 2021 by qkzk

User contributions licensed under CC BY-SA 3.0