Grubは、セキュアブートが有効な状態で署名されていないカーネルをロードします。

Grubは、セキュアブートが有効な状態で署名されていないカーネルをロードします。

私は現在、GentooとWindows(2つの異なるディスク)をダブルブートしています。私はgrub2を使ってLinuxドライブから起動します。そこでGentooやWindows(os-proberによって追加された)から選択できます。

最近、Windows 10をWindows 11に更新しました。その後、一部のアプリケーションは、セキュアブートが有効になっていないと文句を言い始めました。問題は、私のマザーボード(Asus z370f)のBIOSメニューでセキュアブートオプションが有効になっていることです。その後、セキュアブートポリシーをOther OS(すでに行ったように)またはWindows UEFI(実際にMicrosoftが提供した署名を確認したようです)に設定できることがわかりました。後者を有効にした後、デュアルブート設定は何もせず、赤いエラーメッセージが表示された後にWindows 11にリダイレクトされました。

デュアルブートを復元し、セキュアブートを維持するために、以下に従いました。Sasakiの安全な起動ガイド。詳細な詳細:

  • efiキー(PK、PEK、db、dbx)を保存しました。
  • opensslを使用して新しいefiキーを作成する
  • 複合キーの生成と署名
  • マザーボードのキーを消去して複合キーをアップロードします。

その後、efi-readvarを使用してキーが正常にロードされたことを確認しました。次に、新しく生成された証明書を使用してsbsignを介してカーネル署名を進めます。

sbsign --key /etc/efikeys/db.key --cert /etc/efikeys/db.crt --output /boot/vmlinuz-6.1.2.signed /boot/vmlinuz-6.1.2

今、すべてが正常になると思います。署名されていないコードを読み込もうとすると、まだ赤いエラーメッセージが表示されます。しばらくの間、テーブルに頭を当てた後、グラブ画像に署名しようとしました。

sbsign --key /etc/efikeys/db.key --cert /etc/efikeys/db.crt --output /boot/efi/gentoo/grubx64.efi grubx64.efi.back

今、状況は少し良くなった。 grubは少なくとも正しく開始されます。ただし、実際にLinuxまたはWindowsを起動することはできません。より多くの検索と欲求不満の終わりに、私はgrubが起動に必要ないくつかのモジュールをロードできないことに気づきました(署名されていないため)。その後、grub-installいくつかのモジュールを使用しました。

MODULES="all_video cat chain configfile disk echo \
    ext2 efi_gop efifwsetup efi_uga fat file font gfxmenu gettext gfxterm \
    gzio help jpeg linux ls normal part_gpt \
    reboot search test tpm video_colors video \
    gcry_sha512 gcry_rsa gcry_sha256"

grub-mkconfig -o /boot/grub/grub.cfg
grub-install --target=x86_64-efi --efi-directory=/boot --disable-shim-lock --modules="$MODULES"
mv /boot/efi/gentoo/grubx64.efi grubx64.efi.back
sbsign --key /etc/efikeys/db.key --cert /etc/efikeys/db.crt --output /boot/efi/gentoo/grubx64.efi grubx64.efi.back

この時点で、実際にはgrubを使用してWindows 11またはgentooから起動でき、Windows uefiモードでもセキュアブートできます。数時間の試行錯誤の後、すべてが正常に機能しました。

問題は、次の日にvmlinux-6.1.2.signed(実際に署名されたカーネル)だけでなく、vmlinux-6.1.2(元の署名されていないカーネル)でも起動できることがわかったときに始まりました。 Grubを使用すると、署名されていないカーネル(!)で起動(セキュア起動を有効にする)が可能になり、両方のカーネルを確認するとメッセージ(!!)がdmesg表示されます。Secure boot enabled

だから私が現在経験している問題は次のとおりです。セキュアブートが有効になっていても、grub(および私のuefi)が署名されていないカーネルを起動できるようにするのはなぜですか?キーを追加する方法に問題がありますか? Grubに署名するのに間違えましたか?

注:このプロセスではGPGキーを使用しません。私は鍵の生成とアップロードに関する佐々木の指示に厳密に従いました。可能であれば、gpgキーを使用せずにopensslを使用して生成された証明書のみを使用したいと思います。

注2:Grub構成に次の行を追加しようとしましたが、特にうまくいきませんでした。 Grubは.sigファイルの欠落について文句を言い、ブートを拒否しました。

set check_signatures=enfore
export check_signatures

正直なところ、私はgrubでカーネルが署名されたことを確認したかったのですが、このオプションはgpg署名に関連しているように見え、grubに追加しませんでした。

注3:また、さまざまな変更を適用した後、grubが著しく遅くなることを確認しました。以前は開始はほぼすぐに行われていましたが、メニューが開く前にしばらく「ようこそ」というメッセージが表示されます。また、コンソールはキーを押すたびに遅くなり、非常に遅くなります。モジュールが多すぎると状況が悪くなりますか?

/boot/grub/grub.cfg

#
# do not edit this file
#
# it is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### begin /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="advanced options for gentoo gnu/linux>gentoo gnu/linux, with linux 5.15.6-gentoo.signed"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

insmod part_gpt
insmod fat
search --no-floppy --fs-uuid --set=root e179-b0bd
if loadfont /grub/fonts/terminus18.pf2 ; then
  set gfxmode=2560x1440,auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_us
  insmod gettext
fi
terminal_output gfxterm
insmod part_gpt
insmod fat
search --no-floppy --fs-uuid --set=root e179-b0bd
insmod gfxmenu
loadfont ($root)/grub/themes/vimix/dejavu_sans_12.pf2
loadfont ($root)/grub/themes/vimix/dejavu_sans_14.pf2
loadfont ($root)/grub/themes/vimix/dejavu_sans_16.pf2
loadfont ($root)/grub/themes/vimix/dejavu_sans_24.pf2
loadfont ($root)/grub/themes/vimix/dejavu_sans_32.pf2
loadfont ($root)/grub/themes/vimix/dejavu_sans_48.pf2
loadfont ($root)/grub/themes/vimix/terminus-12.pf2
loadfont ($root)/grub/themes/vimix/terminus-14.pf2
loadfont ($root)/grub/themes/vimix/terminus-16.pf2
loadfont ($root)/grub/themes/vimix/terminus-18.pf2
insmod jpeg
insmod png
set theme=($root)/grub/themes/vimix/theme.txt
export theme
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### end /etc/grub.d/00_header ###

### begin /etc/grub.d/10_linux ###
menuentry 'gentoo gnu/linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-889b06ae-8d49-4046-a1c6-42e6967862b2' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt
    insmod fat
    search --no-floppy --fs-uuid --set=root e179-b0bd
    echo    'loading linux 6.1.2-gentoo.signed ...'
    linux   /vmlinuz-6.1.2-gentoo.signed root=/dev/nvme1n1p3 ro vt.default_utf8=1
}
submenu 'advanced options for gentoo gnu/linux' $menuentry_id_option 'gnulinux-advanced-889b06ae-8d49-4046-a1c6-42e6967862b2' {
    menuentry 'gentoo gnu/linux, with linux 6.1.2-gentoo.signed' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.1.2-gentoo.signed-advanced-889b06ae-8d49-4046-a1c6-42e6967862b2' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod fat
        search --no-floppy --fs-uuid --set=root e179-b0bd
        echo    'loading linux 6.1.2-gentoo.signed ...'
        linux   /vmlinuz-6.1.2-gentoo.signed root=/dev/nvme1n1p3 ro  vt.default_utf8=1
    }
    menuentry 'gentoo gnu/linux, with linux 6.1.2-gentoo.signed (recovery mode)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.1.2-gentoo.signed-recovery-889b06ae-8d49-4046-a1c6-42e6967862b2' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod fat
        search --no-floppy --fs-uuid --set=root e179-b0bd
        echo    'loading linux 6.1.2-gentoo.signed ...'
        linux   /vmlinuz-6.1.2-gentoo.signed root=/dev/nvme1n1p3 ro single  }
    menuentry 'gentoo gnu/linux, with linux 6.1.2-gentoo' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.1.2-gentoo-advanced-889b06ae-8d49-4046-a1c6-42e6967862b2' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod fat
        search --no-floppy --fs-uuid --set=root e179-b0bd
        echo    'loading linux 6.1.2-gentoo ...'
        linux   /vmlinuz-6.1.2-gentoo root=/dev/nvme1n1p3 ro  vt.default_utf8=1
    }
    menuentry 'gentoo gnu/linux, with linux 6.1.2-gentoo (recovery mode)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.1.2-gentoo-recovery-889b06ae-8d49-4046-a1c6-42e6967862b2' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod fat
        search --no-floppy --fs-uuid --set=root e179-b0bd
        echo    'loading linux 6.1.2-gentoo ...'
        linux   /vmlinuz-6.1.2-gentoo root=/dev/nvme1n1p3 ro single 
    }
    menuentry 'gentoo gnu/linux, with linux 5.15.6-gentoo.signed' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.6-gentoo.signed-advanced-889b06ae-8d49-4046-a1c6-42e6967862b2' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod fat
        search --no-floppy --fs-uuid --set=root e179-b0bd
        echo    'loading linux 5.15.6-gentoo.signed ...'
        linux   /vmlinuz-5.15.6-gentoo.signed root=/dev/nvme1n1p3 ro  vt.default_utf8=1
    }
    menuentry 'gentoo gnu/linux, with linux 5.15.6-gentoo.signed (recovery mode)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.6-gentoo.signed-recovery-889b06ae-8d49-4046-a1c6-42e6967862b2' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod fat
        search --no-floppy --fs-uuid --set=root e179-b0bd
        echo    'loading linux 5.15.6-gentoo.signed ...'
        linux   /vmlinuz-5.15.6-gentoo.signed root=/dev/nvme1n1p3 ro single 
    }
    menuentry 'gentoo gnu/linux, with linux 5.15.6-gentoo' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.6-gentoo-advanced-889b06ae-8d49-4046-a1c6-42e6967862b2' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod fat
        search --no-floppy --fs-uuid --set=root e179-b0bd
        echo    'loading linux 5.15.6-gentoo ...'
        linux   /vmlinuz-5.15.6-gentoo root=/dev/nvme1n1p3 ro  vt.default_utf8=1
    }
    menuentry 'gentoo gnu/linux, with linux 5.15.6-gentoo (recovery mode)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.6-gentoo-recovery-889b06ae-8d49-4046-a1c6-42e6967862b2' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod fat
        search --no-floppy --fs-uuid --set=root e179-b0bd
        echo    'loading linux 5.15.6-gentoo ...'
        linux   /vmlinuz-5.15.6-gentoo root=/dev/nvme1n1p3 ro single 
    }
}

### end /etc/grub.d/10_linux ###

### begin /etc/grub.d/20_linux_xen ###
### end /etc/grub.d/20_linux_xen ###

### begin /etc/grub.d/30_os-prober ###
menuentry 'windows boot manager (on /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-3e17-e3b9' {
    insmod part_gpt
    insmod fat
    search --no-floppy --fs-uuid --set=root 3e17-e3b9
    chainloader /efi/microsoft/boot/bootmgfw.efi
}
### end /etc/grub.d/30_os-prober ###

### begin /etc/grub.d/30_uefi-firmware ###
menuentry 'uefi firmware settings' $menuentry_id_option 'uefi-firmware' {
    fwsetup
}
### end /etc/grub.d/30_uefi-firmware ###

### begin /etc/grub.d/40_custom ###
# this file provides an easy way to add custom menu entries.  simply type the
# menu entries you want to add after this comment.  be careful not to change
# the 'exec tail' line above.

#set check_signatures=enforce
#export check_signatures
### end /etc/grub.d/40_custom ###

### begin /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg
fi
### end /etc/grub.d/41_custom ###

/etc/default/grub

# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
#
# To populate all changes in this file you need to regenerate your
# grub configuration file afterwards:
#     'grub-mkconfig -o /boot/grub/grub.cfg'
#
# See the grub info page for documentation on possible variables and
# their associated values.

GRUB_DISTRIBUTOR="Gentoo"

# Default menu entry
#GRUB_DEFAULT=0

# Boot the default entry this many seconds after the menu is displayed
GRUB_TIMEOUT=5
#GRUB_TIMEOUT_STYLE=menu

# Append parameters to the linux kernel command line
#GRUB_CMDLINE_LINUX=""
#
# Examples:
#
# Boot with network interface renaming disabled
# GRUB_CMDLINE_LINUX="net.ifnames=0"
#
# Boot with systemd instead of sysvinit (openrc)
# GRUB_CMDLINE_LINUX="init=/usr/lib/systemd/systemd"

# Append parameters to the linux kernel command line for non-recovery entries
#GRUB_CMDLINE_LINUX_DEFAULT=""

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal.
# Note that you can use only modes which your graphic card supports via VBE.
# You can see them in real GRUB with the command `vbeinfo'.
GRUB_GFXMODE=2560x1440,auto

# Set to 'text' to force the Linux kernel to boot in normal text
# mode, 'keep' to preserve the graphics mode set using
# 'GRUB_GFXMODE', 'WIDTHxHEIGHT'['xDEPTH'] to set a particular
# graphics mode, or a sequence of these separated by commas or
# semicolons to try several modes in sequence.
#GRUB_GFXPAYLOAD_LINUX=

# Path to theme spec txt file.
# The starfield is by default provided with use truetype.
# NOTE: when enabling custom theme, ensure you have required font/etc.
GRUB_THEME="/boot/grub/themes/vimix/theme.txt"

# Background image used on graphical terminal.
# Can be in various bitmap formats.
#GRUB_BACKGROUND="/boot/grub/mybackground.png"

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to kernel
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY=true

# Uncomment to disable generation of the submenu and put all choices on
# the top-level menu.
# Besides the visual affect of no sub menu, this makes navigation of the
# menu easier for a user who can't see the screen.
#GRUB_DISABLE_SUBMENU=y

# Uncomment to play a tone when the main menu is displayed.
# This is useful, for example, to allow users who can't see the screen
# to know when they can make a choice on the menu.
#GRUB_INIT_TUNE="60 800 1"

GRUB_DEFAULT="Advanced options for Gentoo GNU/Linux>Gentoo GNU/Linux, with Linux 5.15.6-gentoo.signed"
# EDITED
GRUB_TERMINAL_OUTPUT="gfxterm"
GRUB_FONT=/boot/grub/fonts/Terminus18.pf2 
GRUB_GFXMODE=2560x1440,auto
GRUB_GFXPAYLOAD_LINUX=keep
GRUB_DISABLE_OS_PROBER=n
GRUB_CMDLINE_LINUX_DEFAULT="vt.default_utf8=1"

ベストアンサー1

おすすめ記事