なかのにっき

最新版はこちら。 いろいろ危ない世の中になってきたので、static に生成した html での公開に切り替えました。ご了承ください。


hns - 日記自動生成システム - Version 2.19.9

先月 2025年11月 来月
日 月 火 水 木 金 土
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30

2025年11月21日(金)

#1 Debian trixie の 13.1→13.2 で grub の EFI ブートローダが壊れたので復旧した

家の NUC PC に trixie を入れ、squid と家 PC のバックアップ先にしていたのだが、13.2 にしてから起動しなくなった。

これは SATA の SSD なので、ひとまず UGREEN の USB3-SATA アダプタ を買い、disk を生きている Linux ホストに接続。 各パーティションは無事に見えたので、
sudo mount -rt ext4 /dev/sdc2 /mnt/mnt_sdc2
でマウントし、
sudo rsync -aHAXv --numeric-ids --info=progress2 \
  --ignore-errors --partial --dry-run \
  --exclude='/proc/*' --exclude='/sys/*' --exclude='/dev/*' \
  --exclude='/run/*'  --exclude='/tmp/*' --exclude='/mnt/*' \
  --exclude='/lost+found/*' --exclude='/home/nakano/Dropbox/*' \
  /mnt/mnt_sdc2/ /opt/backup_atom/
で中身をバックアップ。

その後は ChatGPT さんに聞いて復旧。
sudo mount -rwt vfat /dev/sdc1 /mnt/mnt_sdc2/boot/efi
chroot する
sudo mount --bind /dev  /mnt/mnt_sdc2/dev
sudo mount --bind /proc /mnt/mnt_sdc2/proc
sudo mount --bind /sys  /mnt/mnt_sdc2/sys
sudo mount --bind /run  /mnt/mnt_sdc2/run

sudo chroot /mnt/mnt_sdc2 /bin/bash
その後 grub-install を実行
# grub-install --target=x86_64-efi --efi-directory=/boot/efi \
  --bootloader-id=debian --recheck
Installing for x86_64-efi platform.
grub-install: warning: EFI variables cannot be set on this system.
grub-install: warning: You will have to complete the GRUB setup manually.
Installation finished. No error reported.
この段階で chroot を抜け、下流から /mnt/mnt_sdc2 まで umount し、 SSD を取り外して NUC に再接続。

付いで(このステップが必要だったかどうかはわからないが)、 trixie の installer usb で NUC wo起動し、rescue モードのコンソールに抜け、 /target に chroot して /boot/efi/EFI/debian に grubx64.efi が、 /boot/efi/EFI/BOOT に BOOTX64.EFI があるのを確認。 一応
update-grub
しておき、usb を抜いて NUC を起動したら、grub コンソールが立ち上がった。
grub> ls
(hd0) (hd0,gpt1) (hd0,gpt2) (hd0,gpt3)
という具合で、
grub> ls (hd0,gpt2)/
でちゃんと /etc や /boot が見えて、 /boot に vmlinuz-*-amd64 と initrd.img-*-amd64 が入っていることも確認できた。
grub> set root=(hd0,gpt2)
grub> linux /boot/vmlinux-6.12.57+deb13-amd64 root=/dev/sda2 ro
grub> initrd  /boot/initrd.img-6.12.57+deb13-amd64
grub> boot
すると、ちゃんと trixie のシステムが起動した。

そんで
sudo grub-install --target=x86_64-efi \
  --efi-directory=/boot/efi --bootloader-id=debian --recheck
sudo update-grub
sudo efibootmgr -c -d /dev/sda -p 1 -L "debian" -l '\EFI\debian\grubx64.efi'
して installer usb も抜いて再起動したら、 普通に debian のログインプロンプトが出た。やれやれ。

upgrade 前後のチェック用のスクリプトも作ってもらったのでこちらに。 grub-efi-check.sh

アップグレードの前後に
sudo grub-efi-check.sh pre
(upgrade)
sudo grub-efi-check.sh post
という感じで使うとよいそうです。

以上の全会話はこちらに貼る。
rsync オプション提案

以上、1 日分です。
タイトル一覧
カテゴリ分類
Powered by hns-2.19.9, HyperNikkiSystem Project

中野武雄 (NAKANO, Takeo) <nakano@st.seikei.ac.jp> Since 1999-10-07

中野のホームページへ