LoginSignup
3
4

More than 3 years have passed since last update.

ubuntu 20.04 grub symbol 'grub_calloc' not found (備忘録)

Last updated at Posted at 2020-07-30

あらすじ

ubuntu 20.04でgrub2関係のセキュリティーupdate(upgrade)を掛けるとgrub-pcから

The GRUB boot loader was previously installed to a disk that is no longer present, 
or whose unique identifier has changed for some reason.  It is important to make sure 
that the installed GRUB core image stays in sync with GRUB modules and grub.cfg. 
Please check again to make sure that GRUB is written to the appropriate boot devices.   

If you're unsure which drive is designated as boot drive by your BIOS, 
it is often a good idea to install GRUB to all of them. 
Note: it is possible to install GRUB to partition boot records as well, 
and some appropriate partitions are offered here. However, this forces GRUB to use 
the blocklist mechanism, which makes it less reliable, and therefore is not recommended.

的な事をが言われ以前までのgrubが存在しない的な事を言われ,grubを(再?)installするdevicesを次から選べ的な事が言われる.
文言としてはhttps://askubuntu.com/questions/23418/what-do-i-select-for-grub-install-devices-after-an-updateと同じ

nvme0n1    
└─nvme0n1p2

よく分からなければ両方選択しろと指摘されているのに,nvme0n1p2にのみチェックしたためかbootできなくなりました.
PCを起動すると

error: symbol 'grub_calloc' not found
grub rescue>

となりgrub rescue modeになる.grub rescue コマンド一覧.grub rescue なら

grub rescue >set prefix=(hd0,***)/boot/grub
grub rescue >insmod (hd0,***)/boot/grub/i386-pc/normal.mod
grub rescue >normal

(私の場合は***にgpt2が入った) とすればboot出来るようだが,本件では

error: symbol 'grub_calloc' not found

となりbootできない.ask ubuntuに今日postされ1k以上のviewがあるのでかなり多くの人が同じ症状のようだ.
https://www.mail-archive.com/ubuntu-bugs@lists.ubuntu.com/msg5813006.html
にbug reportとして報告されている.

対処療法

ask ubuntuを一通りみたががgrub rescueからでは解決できそうにないので,最新版のubuntu 20.04 のdesktopのisoをusbかdvdに焼きlive 版(インストールせずubuntu を試す)から立ち上げてgrub-installを行う(多分server版にlive版がないと思う).
具体的な手順はhttp://powerx.jp/feature/labo_x/xpm/win7_ubuntu/02.php がわかりやすい.こちらも参考になると思う(https://www.reddit.com/r/Ubuntu/comments/i0vlf0/repair_grub_boot_error_symbol_grub_calloc_not/)
私は最悪クリーンインストールで良いやと思っていたが,ddコマンドでディスク全体のイメージを作成しても良かったかもしれしれない.(参考:https://www.atmarkit.co.jp/flinux/rensai/linuxtips/927reinstgrub.html)

追記
(ここから)
一次情報としては
https://wiki.ubuntu.com/SecurityTeam/KnowledgeBase/GRUB2SecureBootBypass
に対処方法を含めた方法見つける事ができる.取り敢えず8月3日に修正版が公開されたようだ.
(ここまで)

私の場合Live版から立ち上げて

# sudo mount /dev/nvme0n1p2 /mnt
# sudo mount --bind /dev/ /mnt/dev
# sudo chroot /mnt
# sudo grub-install /dev/nvme0n1

を実施した.これで十分だったかもしれないが,Warningが数行で不安だったので

# grub-install /dev/nvme0n1p2

も実行したが,多分(/dev/nvme0n1)にinstallすれば十分だと思う.再起動後に念の為

# update-grub

を掛けておいた.これで正解だったのかよくわからないが,回復までに数時間掛かってしまったので備忘録として残しておく.

なお,私の環境のパーティション構成は次のような構成で,install時に「ディスク全体をubuntuとして使用する」という選択でubuntu 20.04 server版をnvme m.2 ssd にinstallしている(非RAID).

$ lsblk 
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
nvme0n1     259:0    0 465.8G  0 disk 
├─nvme0n1p1 259:1    0   512M  0 part /boot/efi
├─nvme0n1p2 259:2    0 369.4G  0 part /
└─nvme0n1p3 259:3    0  95.9G  0 part [SWAP]

追記

grub関係のupdateがubuntu のみならずdebian 10 (UEFI環境)でも

$ sudo apt list --upgradable
grub-common/stable 2.02+dfsg1-20+deb10u2 amd64 [2.02+dfsg1-20 からアップグレード可]
grub-efi-amd64-bin/stable 2.02+dfsg1-20+deb10u2 amd64 [2.02+dfsg1-20 からアップグレード可]
grub-efi-amd64-signed/stable 1+2.02+dfsg1+20+deb10u2 amd64 [1+2.02+dfsg1+20 からアップグレード可]
grub-efi-amd64/stable 2.02+dfsg1-20+deb10u2 amd64 [2.02+dfsg1-20 からアップグレード可]
grub2-common/stable 2.02+dfsg1-20+deb10u2 amd64 [2.02+dfsg1-20 からアップグレード可]

ubuntu でも似たようなものだと思う.

当面grub関係のupdateをやり過ごすためには

$ sudo apt-mark hold grub*

としておけばupdateをpendingできる.holdの解除は

$ sudo apt-mark unhold grub*

でholdされているpackageは

$ sudo apt-mark showhold

ただ脆弱性が残ったままなので,本当に当面の間の対処療法である.

試しに幾つかのdebian 10 (4台)やlaptop/desktop ubuntu (1台/1台)でも上述のupgradeしたが,本件の問題が生じたのはdesktop ubuntu 1台のみで再現性が良くわからん.

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4