升级到 Fedora Server 27 后使用 Grub2

升级到 Fedora Server 27 后使用 Grub2

我升级到 F27,重启后进入紧急 shell。经过几个小时的谷歌搜索和实验,从安装 CD 加载恢复,找到操作系统映像并将 /usr/lib/os-release 复制到 /etc/os-release,除此之外,还有其他我可能不记得的事情,让我

grub>

所以我发现如果我这样做,我就可以启动

grub> set boot=(hd0,msdos1)
grub> set prefix=(hd0,msdos1)
grub> insmod normal
normal

然后我得到内核选择提示(现在显示“dracut”而不是“Fedora”?)并按“e”编辑 4.14.18-300.fc27.x86_64 并将“set root='hd0,msdos1'”更改为“set root='hd0,msdos3'”,然后按 ctrl-x 启动,Fedora 27 最终启动。

我的问题是每次重启时我都必须这样做。我运行了

# grub2-mkconfig -o /boot/grub2/grub.cfg

它说成功了,但这并没有改变任何事情。我仍然必须完成整个过程才能启动机器,这有点麻烦。幸运的是,我们不必经常重新启动它。

我的问题是:如何使这些分区更改在重启后继续存在?

谢谢!

grub.cfg 似乎具有正确的值,但我仍然必须执行上述操作才能使机器启动。/etc/grub.cfg 链接到 /boot/grub2/grub.cfg:

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set pager=1

if [ -f ${config_directory}/grubenv ]; then
  load_env -f ${config_directory}/grubenv
elif [ -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="${saved_entry}"
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
}

terminal_output console
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/01_users ###
if [ -f ${prefix}/user.cfg ]; then
  source ${prefix}/user.cfg
  if [ -n "${GRUB2_PASSWORD}" ]; then
    set superusers="root"
    export superusers
    password_pbkdf2 root ${GRUB2_PASSWORD}
  fi
fi
### END /etc/grub.d/01_users ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'dracut (4.14.18-300.fc27.x86_64) 27 (Server Edition) dracut-046-8.git20180105.fc27' --class generic --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.14.18-300.fc27.x86_64-advanced-14f0dc3e-9ff4-4051-a8a8-302730b552fb' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos3'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e5576283-fa19-4b57-8c1a-4d44227e8b8c
    else
      search --no-floppy --fs-uuid --set=root e5576283-fa19-4b57-8c1a-4d44227e8b8c
    fi
    linux16 /vmlinuz-4.14.18-300.fc27.x86_64 root=UUID=14f0dc3e-9ff4-4051-a8a8-302730b552fb ro rhgb quiet 
    initrd16 /initramfs-4.14.18-300.fc27.x86_64.img
}
menuentry 'dracut (4.11.12-100.fc24.x86_64) 27 (Server Edition) dracut-046-8.git20180105.fc27' --class generic --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.11.12-100.fc24.x86_64-advanced-14f0dc3e-9ff4-4051-a8a8-302730b552fb' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos3'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e5576283-fa19-4b57-8c1a-4d44227e8b8c
    else
      search --no-floppy --fs-uuid --set=root e5576283-fa19-4b57-8c1a-4d44227e8b8c
    fi
    linux16 /vmlinuz-4.11.12-100.fc24.x86_64 root=UUID=14f0dc3e-9ff4-4051-a8a8-302730b552fb ro rhgb quiet 
    initrd16 /initramfs-4.11.12-100.fc24.x86_64.img
}
menuentry 'dracut (4.11.10-100.fc24.x86_64) 27 (Server Edition) dracut-046-8.git20180105.fc27' --class generic --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.11.10-100.fc24.x86_64-advanced-14f0dc3e-9ff4-4051-a8a8-302730b552fb' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos3'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e5576283-fa19-4b57-8c1a-4d44227e8b8c
    else
      search --no-floppy --fs-uuid --set=root e5576283-fa19-4b57-8c1a-4d44227e8b8c
    fi
    linux16 /vmlinuz-4.11.10-100.fc24.x86_64 root=UUID=14f0dc3e-9ff4-4051-a8a8-302730b552fb ro rhgb quiet 
    initrd16 /initramfs-4.11.10-100.fc24.x86_64.img
}
menuentry 'dracut (4.14.18-300.fc27.x86_64+debug) 27 (Server Edition) dracut-046-8.git20180105.fc27' --class generic --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.14.18-300.fc27.x86_64+debug-advanced-14f0dc3e-9ff4-4051-a8a8-302730b552fb' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos3'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e5576283-fa19-4b57-8c1a-4d44227e8b8c
    else
      search --no-floppy --fs-uuid --set=root e5576283-fa19-4b57-8c1a-4d44227e8b8c
    fi
    linux16 /vmlinuz-4.14.18-300.fc27.x86_64+debug root=UUID=14f0dc3e-9ff4-4051-a8a8-302730b552fb ro rhgb quiet 
    initrd16 /initramfs-4.14.18-300.fc27.x86_64+debug.img
}
menuentry 'dracut (4.11.12-100.fc24.x86_64+debug) 27 (Server Edition) dracut-046-8.git20180105.fc27' --class generic --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.11.12-100.fc24.x86_64+debug-advanced-14f0dc3e-9ff4-4051-a8a8-302730b552fb' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos3'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e5576283-fa19-4b57-8c1a-4d44227e8b8c
    else
      search --no-floppy --fs-uuid --set=root e5576283-fa19-4b57-8c1a-4d44227e8b8c
    fi
    linux16 /vmlinuz-4.11.12-100.fc24.x86_64+debug root=UUID=14f0dc3e-9ff4-4051-a8a8-302730b552fb ro rhgb quiet 
    initrd16 /initramfs-4.11.12-100.fc24.x86_64+debug.img
}
menuentry 'dracut (4.11.10-100.fc24.x86_64+debug) 27 (Server Edition) dracut-046-8.git20180105.fc27' --class generic --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.11.10-100.fc24.x86_64+debug-advanced-14f0dc3e-9ff4-4051-a8a8-302730b552fb' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos3'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e5576283-fa19-4b57-8c1a-4d44227e8b8c
    else
      search --no-floppy --fs-uuid --set=root e5576283-fa19-4b57-8c1a-4d44227e8b8c
    fi
    linux16 /vmlinuz-4.11.10-100.fc24.x86_64+debug root=UUID=14f0dc3e-9ff4-4051-a8a8-302730b552fb ro rhgb quiet 
    initrd16 /initramfs-4.11.10-100.fc24.x86_64+debug.img
}
menuentry 'dracut (0-rescue-a9f8b0f7c9ac492ea0ca157a4e1f3d7b) 27 (Server Edition) dracut-046-8.git20180105.fc27' --class generic --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-a9f8b0f7c9ac492ea0ca157a4e1f3d7b-advanced-14f0dc3e-9ff4-4051-a8a8-302730b552fb' {
    load_video
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos3'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e5576283-fa19-4b57-8c1a-4d44227e8b8c
    else
      search --no-floppy --fs-uuid --set=root e5576283-fa19-4b57-8c1a-4d44227e8b8c
    fi
    linux16 /vmlinuz-0-rescue-a9f8b0f7c9ac492ea0ca157a4e1f3d7b root=UUID=14f0dc3e-9ff4-4051-a8a8-302730b552fb ro rhgb quiet 
    initrd16 /initramfs-0-rescue-a9f8b0f7c9ac492ea0ca157a4e1f3d7b.img
}

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

### BEGIN /etc/grub.d/20_linux_xen ###

### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_ppc_terminfo ###
### END /etc/grub.d/20_ppc_terminfo ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### 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.
### 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 ###

blkid 的输出:

 [root@vh02 ~]# blkid
/dev/sda1: UUID="e5576283-fa19-4b57-8c1a-4d44227e8b8c" TYPE="ext4" PARTUUID="348d6d2c-01"
/dev/sda2: LABEL="home" UUID="5c592a5a-9819-40d5-a1aa-9e04688cecfa" TYPE="ext4" PARTUUID="348d6d2c-02"
/dev/sda3: UUID="14f0dc3e-9ff4-4051-a8a8-302730b552fb" TYPE="xfs" PARTUUID="348d6d2c-03"
/dev/sda5: UUID="4f19f0d8-badf-4dd3-8105-0bfb3d12609c" TYPE="swap" PARTUUID="348d6d2c-05"

答案1

如果您的 /boot 卷位于 sda1 上,那么您的菜单项肯定是错误的。查看以下顶部条目:

### BEGIN /etc/grub.d/10_linux ###
menuentry 'dracut (4.14.18-300.fc27.x86_64) 27 (Server Edition) dracut-046-8.git20180105.fc27' --class generic --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.14.18-300.fc27.x86_64-advanced-14f0dc3e-9ff4-4051-a8a8-302730b552fb' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos3'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e5576283-fa19-4b57-8c1a-4d44227e8b8c
    else
      search --no-floppy --fs-uuid --set=root e5576283-fa19-4b57-8c1a-4d44227e8b8c
    fi
    linux16 /vmlinuz-4.14.18-300.fc27.x86_64 root=UUID=14f0dc3e-9ff4-4051-a8a8-302730b552fb ro rhgb quiet 
    initrd16 /initramfs-4.14.18-300.fc27.x86_64.img
}

set root='hd0,msdos3' 不正确。它应该读作 'hd0,msdos1'。这是将 GRUB 指向您的 /boot 分区的内容,而内核的 root= 参数(以“linux16”开头的行)应该指向文件系统 UUID /。

您的 / 和 /boot 上可能都有 grub 文件,升级期间可能已卸载 /boot。根据给出的信息很难判断,但这是一个常见的罪魁祸首。修复此问题可能很简单,只需重新生成 grub 配置,同时grub-mkconfig确保 /dev/sda1 已安装在 /boot 上。如果这确实是问题所在,您可能还需要先清理 / 文件系统上的 /boot 目录。

您的 dracut 问题虽然独立但又相互关联。我会查看内核的 root=UUID= 行,并确保那里的 UUID 确实属于您的根文件系统,而不是其他文件。blkid正在运行的系统内将在挂载点旁边打印 UUID 以及其他详细信息。您的菜单和其他内容显示“dracut”,因为 grub 配置生成未正确检测到 fedora 安装。同样,这可能是由于卸载了 /boot 或甚至在 期间绑定了挂载 / grub-mkconfig

相关内容