縮小RAID1ディスクにGRUB2をインストールするには?

縮小RAID1ディスクにGRUB2をインストールするには?

簡単に言うと: RAID1のブロックデバイスにGRUB2をインストールしてみてください。ブートローダのインストールが中断されました。

ターゲット

HDDをより小さなSSDに交換してください。私が取ったステップは次のとおりです。

# Booted into rescue mode 
# failed and removed the partition from md array
mdadm --manage /dev/md1 -f /dev/sdb2
mdadm --manage /dev/md1 -r /dev/sdb2

# took out the HDD
# shrunk the filesystem and then the md
resize2fs -f /dev/md1 85G
mdadm --grow /dev/md1 -z 88G

# md1 mounted fine, no issues there. Didn't try to mount /dev/sdd2, as it's Linux RAID type
# recreated partitions on SSD as they are on HDD

# added to array
mdadm --add /dev/md1 /dev/sdb2

# waited for the sync to finish.
# recreated partitions on second SSD
# removed remaining HDD once synced, added SSD to array

gdisk -l

Partition table scan:
  MBR: protective
  GPT: present

Disk label type: GPT
#    Start          End    Size          Type
1     2048         6143      2M      Linux fs
2     6144    195371534   93.2G    Linux RAID

質問

SSD-sにブートローダをインストールする方法は?私が経験しているエラー:

grub2-install --directory /mnt/sysimage/boot/grub2/i386-pc /dev/sdd
Installing for i386-pc platform.
grub2-install error: cannot open `/mnt/sysimage/boot/grub2/i386-pc/kernel.img': No such file or directory.

メガネ

  • オペレーティングシステム7
  • mdadm v4.1
  • LVMなし

編集する:gdisk -lトリム出力を追加

アップデート#1

mount --bind-ing/{proc,dev,sys}と実行すると、grub2-install次のエラーが発生します。たぶん私が間違って設定したのでしょうか?

grub2-install: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image.. (2x)
grub2-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be psosible.
grub2-install: error: embedding is not possible, but this is rquired for RAID and LVM install.

アップデート#2

相談後手動 grub2-install成功!

将来の世代のために私がしたこと:

gdisk /dev/sdd
# t - changed partition 1 type to ef02 -- BIOS boot partition
chroot /mnt/sysimage/
grub2-install /dev/sdd
# grub2-install warned about not finding physical volume `(null)' but installation finished without any errors.
# added to md, failed, removed the other disk, repeated grub2-install

サーバーが起動します! @telcoMさん、時間を割いてご案内いただきありがとうございます!

今、すべてが大丈夫であることを確認する必要があります:)

ベストアンサー1

この--directoryオプションはgrub2-installGRUBコンポーネントファイルの場所を定義します。~から--boot-directory配置位置の定義中到着

リカバリchrootの設定は、リカバリ環境で直接実行するために必要なすべての長いパス名を入力するよりもはるかに簡単です。さらに、およびgrub2-installを指定する必要があります。だから:--grub-setup--grub-mkrelpath--grub-probe--directory--boot-directory

mount --rbind /dev /mnt/sysimage/dev
mount -t proc none /mnt/sysimage/proc
mount -t sysfs none /mnt/sysimage/sys
chroot /mnt/sysimage /bin/bash
grub2-install /dev/sdd

ただし、独自の方法で実行するには、次の手順を実行します。 (\読みやすくするために行分割が表示されます)

grub2-install --directory=/mnt/sysimage/usr/lib/grub/i386-pc \
    --grub-setup=/mnt/sysimage/usr/bin/grub2-setup \
    --grub-mkrelpath=/mnt/sysimage/usr/bin/grub2-mkrelpath \
    --grub-probe=/mnt/sysimage/usr/sbin/grub2-probe \
    --boot-directory=/mnt/sysimage/boot \
    /dev/sdd

おすすめ記事