如何为 Gen8 Microservr 创建自动化 grub 救援磁盘?

如何为 Gen8 Microservr 创建自动化 grub 救援磁盘?

我从 2016 年起就拥有一台 HP Gen8 Microservr,格式化后我就无法再正常启动它了。

以下是相当复杂的设置:

  • SATA 端口 1:带有 debian 的 ssd(我曾经从中启动...),
  • SATA ODD 和 SATA 端口 2、3、4:在 raid 5 中组装 3TB 驱动器,

我知道不建议这么做,但几个月来我都设法直接启动到第一个 SATA 驱动器,而无需借助 grub usb 启动键

有效的方法:

我可以从“实时”USB 密钥或“Grub 救援密钥”启动。第一个选项是格式化并安装,第二个选项是选择 Debian 并启动。

这个选项很烦人,因为这台机器没有屏幕,我必须按 3 个键才能启动……

无效的方法:

  • 直接启动到 SSD。无论grub-install选择哪种方式,BIOS 都永远不会从它启动。它曾经工作了很多年……我总是设法从第一个 SATA 驱动器启动(无论是否安装了其他磁盘)。我尝试了 AHCI、传统 SATA、b120i 以及我在 bios 和 iLO 中找到的所有其他选项
  • 从 USB 密钥启动grub-install。它多年来一直有效,但现在不行了。我不知道为什么。我还尝试了每个 USB 端口、内部、外部和 SD 卡。
  • 从 ODD 启动。它从来没有直接工作过,因为我在 2016 年买它的时候就知道它不会工作。

我无法理解的是

为什么我可以从“救援密钥”/“实时密钥”启动,但不能从 grub 特定安装启动?如何创建可启动的 grub 密钥?

我注意到的是:

  • USB 救援密钥和 USB 实时密钥有 3 个分区,如下所示:
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
  • 根据grub-install选项,grub 引导加载程序键有一个或两个分区,例如:
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

这是我的最后一个问题:

有没有办法直接启动而无需人工干预?

三天前它还能用,但之后我格式化了磁盘,我不知道我做了什么让它能用。我感到很惭愧,但就是这样!

在此先感谢您的帮助 :)


一些输出

  • 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

答案1

嗯...我成功了。

基本上我删除了一些步骤回答

以下是我遵循的步骤:

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

然后我插入了一把钥匙,fdisk告诉我它在/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*

并且它成功了。BIOS 设法找到密钥并从中启动... 启动画面相当丑陋,可能需要进行一些调整 :)

相关内容