/boot
分区./boot
分区单独设置一个支持的文件系统.BIOS/GPT配置中,一个 BIOS启动分区是必需的。GRUB将core.img
嵌入到这个分区。php
core.img
). GRUB for GPT, however, does not use the Post-GPT gap to conform to GPT specifications that require 1_megabyte/2048_sector disk boundaries.Create a mebibyte partition (+1M
with fdisk
or gdisk
) on the disk with no file system and type BIOS boot (BIOS boot in fdisk, ef02
in gdisk, bios_grub
in parted
). This partition can be in any position order but has to be on the first 2 TiB of the disk. This partition needs to be created before GRUB installation. When the partition is ready, install the bootloader as per the instructions below. The post-GPT gap can also be used as the BIOS boot partition though it will be out of GPT alignment specification. Since the partition will not be regularly accessed performance issues can be disregarded (though some disk utilities will display a warning about it). In fdisk
or gdisk
create a new partition starting at sector 34 and spanning to 2047 and set the type. To have the viewable partitions begin at the base consider adding this partition last.html
通常来讲,若是使用兼容DOS的分区对齐模式,MBR后面空间(post-MBR gap)的大小都是31KiB(MBR和第一个分区之间的空间).不过,为了提供足够的空间嵌入GRUB的core.img
文件(FS#24103),建议将这个空间设置到1到2Mib.最好使用支持1MiB分区对齐的分区软件来分区,由于这样也能知足非512B扇区磁盘分区的需求.node
可使用pacman从官方仓库安装grub包.安装完成后它会代替grub-legacyAUR.linux
/boot/grub/i386-pc/core.img
和
/boot/grub/i386-pc
里的GRUB模组.须要使用下面介绍的
grub-install
来手动更新它们.
有三种方式安装GRUB Boot文件:ios
/boot/grub/i386-pc/core.img
)/boot/grub
,1st stage code会被安装到MBR的启动代码区域(以便和MBR分区表分开).对于无分区磁盘,请参考
#安装到分区上或者无分区磁盘上
如下命令会将grub
安装到MBR的启动代码区域,填充/boot/grub
文件夹,生成/boot/grub/i386-pc/core.img
,将其嵌入post-MBR gap或者放入BIOS boot partition中(分别对应MBR分区表和GPT分区表):git
# grub-install --target=i386-pc --recheck --debug /dev/sda
/dev/sda
只是示例.--target=i386-pc
指示grub-install
是为使用BIOS的系统安装. 推荐一直标明这点以防混淆.若是你使用LVM来进行启动,你能够将GRUB安装在多个物理磁盘上. 执行grub-install
并不会生成GRUB配置文件,请移至#生成GRUB配置文件一节redis
假设你的U盘第一个分区是FAT32,其分区是/dev/sdy1shell
# mkdir -p /mnt/usb ; mount /dev/sdy1 /mnt/usb # grub-install --target=i386-pc --recheck --debug --boot-directory=/mnt/usb/boot /dev/sdy # grub-mkconfig -o /mnt/usb/boot/grub/grub.cfg
# optional, backup config files of grub.cfg # mkdir -p /mnt/usb/etc/default # cp /etc/default/grub /mnt/usb/etc/default # cp -a /etc/grub.d /mnt/usb/etc
# sync ; umount /mnt/usb
下面的命令将会将GRUB2安装到分区扇区或者无分区磁盘上(好比闪存上):ubuntu
# chattr -i /boot/grub/i386-pc/core.img # grub-install --target=i386-pc --recheck --debug --force /dev/sdaX # chattr +i /boot/grub/i386-pc/core.img
/dev/sda
只是示例.--target=i386-pc
指示grub-install
是为使用BIOS的系统安装. 推荐一直标明这点以防混淆.
必须使用--force
选项来启用对blocklists(块列表)的支持,不该使用--grub-setup=/bin/true
(这个选项的效果相似于只生成core.img
). grub-install
会生成如下警告,你能够经过这些警告判断发生了什么问题:windows
/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea. /sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged.
若是不指定--force
选项,会出现如下错误,而且不会将启动代码安装到启动扇区上:
/sbin/grub-setup: error: will not proceed with blocklists
而指定了--force
,会出现:
Installation finished. No error reported.
grub-setup
不默认容许这种状况的缘由是,在分区或者无分区磁盘上,grub
依赖于嵌入分区引导扇区的块列表(blocklists)来定位/boot/grub/i386-pc/core.img
和/boot/grub
.而core.img
在分区上的扇区位置颇有可能随着分区文件系统的更改而变化(复制文件,删除文件等).详情请参考https://bugzilla.redhat.com/show_bug.cgi?id=728742 和 https://bugzilla.redhat.com/show_bug.cgi?id=730915.
临时解决方案是给/boot/grub/i386-pc/core.img
文件加"不可变"(immutable)标志.只有当将grub
安装到分区启动扇区或者无分区磁盘上时才须要给core.img加"不可变"标志. 执行grub-install
并不会生成GRUB配置文件,请移至#生成GRUB配置文件一节
经过添加--grub-setup=/bin/true
选项,grub-install
命令会填充/boot/grub
文件夹并生成/boot/grub/i386-pc/core.img
,可是不会将grub启动引导代码嵌入到MBR,post-MBR gap和分区引导扇区中:
# grub-install --target=i386-pc --grub-setup=/bin/true --recheck --debug /dev/sda
/dev/sda
只是示例.--target=i386-pc
指示grub-install
是为使用BIOS的系统安装. 推荐一直标明这点以防混淆.生成后,Grub Legacy或者syslinux就能够经过链式加载GRUB2的core.img
来间接加载Linux内核或者多启动内核了.
最后,生成GRUB2所需的配置文件(在配置章节会详述):
# grub-mkconfig -o /boot/grub/grub.cfg
/boot/grub/grub.cfg
, 而不是
/boot/grub/i386-pc/grub.cfg
.
若是GRUB在启动时报错"no suitable mode found",请参考#"No suitable mode found" error.
若是grub-mkconfig
执行失败,能够经过以下方式将/boot/grub/menu.lst
文件转化为/boot/grub/grub.cfg
# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg
示例以下:
/boot/grub/menu.lst
default=0 timeout=5 title Arch Linux Stock Kernel root (hd0,0) kernel /vmlinuz-linux root=/dev/sda2 ro initrd /initramfs-linux.img title Arch Linux Stock Kernel Fallback root (hd0,0) kernel /vmlinuz-linux root=/dev/sda2 ro initrd /initramfs-linux-fallback.img
/boot/grub/grub.cfg
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi set timeout=5 menuentry 'Arch Linux Stock Kernel' { set root='(hd0,1)'; set legacy_hdbias='0' legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro' legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img' } menuentry 'Arch Linux Stock Kernel Fallback' { set root='(hd0,1)'; set legacy_hdbias='0' legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro' legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img' }
若是你忘记建立GRUB配置文件/boot/grub/grub.cfg
,而后直接重启到了GRUB命令行界面,输入如下命令:
sh:grub> insmod legacycfg sh:grub> legacy_configfile ${prefix}/menu.lst
选择启动到Arch下而后再从新建立合适的GRUB配置文件/boot/grub/grub.cfg
为了实现多系统启动,须要安装os-prober.安装后,再执行grub-mkconfig -o /boot/grub/grub.cfg
.若是执行失败,可能就须要手动添加启动条目了.(后面有指导)
bootmgr
启动,如今再也不须要链式加载分区启动扇区了
bootmgr
位于
系统分区(
system partition),而不是Windows系统所在的分区(好比C盘).在uuid-卷名列表中,系统分区是那个名为
LABEL="SYSTEM RESERVED"
或
LABEL="SYSTEM"
的项,并且这个分区通常只有100到200MB大(和Arch的启动分区差很少).请参考
Wikipedia:System partition and boot partition
本节假设你的Windows分区是/dev/sda1
.首先,找到Windows系统分区的UUID(Windows's SYSTEM PARTITION,bootmgr存放其上
).若是Windows bootmgr
的位置是/media/SYSTEM_RESERVED/bootmgr
,对于 Windows Vista/7/8,执行:
# grub-probe --target=fs_uuid /media/SYSTEM_RESERVED/bootmgr 69B235F6749E84CE
# grub-probe --target=hints_string /media/SYSTEM_RESERVED/bootmgr --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1
NTLDR
替代
bootmgr
. 注意,可能
NTLDR
不是在名为"SYSTEM_RESERVED"的分区上,请在XP系统所在的分区上寻找
NTLDR
接着,将下面的代码添加到/etc/grub.d/40_custom
或者/boot/grub/custom.cfg
中.而后,使用grub-mkconfig
从新生成grub.cfg
,这样就能在BIOS-MBR配置下使用GRUB2引导启动Windows系统了:
对于 Windows Vista/7/8
if [ "${grub_platform}" == "pc" ]; then menuentry "Microsoft Windows Vista/7/8 BIOS-MBR" { insmod part_msdos insmod ntfs insmod search_fs_uuid insmod ntldr search --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 69B235F6749E84CE ntldr /bootmgr } fi
对于Windows XP
if [ "${grub_platform}" == "pc" ]; then menuentry "Microsoft Windows XP" { insmod part_msdos insmod ntfs insmod search_fs_uuid insmod ntldr search --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 69B235F6749E84CE ntldr /bootmgr } fi
\boot\bcd
报错(错误代码为
0xc000000f
).能够经过Wondows Recovery Console来修复这个错误:
x:\> "bootrec.exe /fixboot" x:\> "bootrec.exe /RebuildBcd".
不要使用bootrec.exe /Fixmbr
,由于那会将GRUB清除掉
/etc/grub.d/40_custom
能够作为建立/etc/grub.d/nn_custom
的模板.nn
定义了脚本执行的优先级.脚本执行的顺序又决定了grub引导启动目录的内容.
nn
应该比06大,这样才能确保必要的脚本被优先执行
若是想要使用EFI在某个磁盘上进行启动,那么就须要使用EFI系统分区(EFI System Partition,即ESP),GPT倒不是必须的,不过咱们仍是高度建议使用GTP,而且这也是本篇文章当前支持的方法.若是你在一个支持EFI,而且已经有操做系统的电脑上安装Arch(好比Windows 8),那么你已经有了ESP了.能够经过parted
来列出启动磁盘上的分区表以检查其是否支持GPT和ESP(假设这个启动磁盘是/dev/sda)
# parted /dev/sda print
若是使用GPT,那么会出现"分区表:GPT".若是使用EFI,那么会有一个文件系统为vfat的小分区(通常小于512MiB)而且被标志为启动分区.在这个小分区上,应该有一个名为EFI的文件夹.若是这些条件都知足,那么这就是ESP了.注意分区序号,由于以后安装GRUB2时你须要mount它.
若是你没有ESP,请参考EFI System Partition的引导来建立它
本节假设您正在安装GRUB的x86_64系统下(x86_64-EFI)。对于 i686 系统,在适当状况下替换为 x86_64-efi
和 i386-efi
。 请确保您在 bash shell 中。例如,当从Arch ISO引导时:
# arch-chroot /mnt /bin/bash
安装grub efibootmgr包。"GRUB"是引导程序, efibootmgr creates bootable .efi
stub entries used by the GRUB installation script. 接下来的步骤将安装GRUB UEFI 程序到 $esp/EFI/grub
中, 安装其模块到/boot/grub/x86_64-efi
, and place the bootable grubx64.efi
stub in $esp/EFI/grub
.
首先,告诉GRUB使用UEFI,设置引导目录,并设置引导程序ID,将$esp
修改成你的 efi 分区 (一般为 /boot
)
# grub-install --target=x86_64-efi --efi-directory=$esp --bootloader-id=grub --recheck
The --bootloader-id
is what appears in the boot options to identity the GRUB EFI boot option; make sure this is something you will recognize later. The install will create a directory of the same name under $esp/EFI/
where the EFI binary bootloader will be placed. 上述安装完成后 GRUB 的主目录将位于 /boot/grub/
。
/boot/efi
或/boot/EFI
目录,但 Arch没有。--efi-directory
和 --bootloader-id
是特定于GRUB UEFI的. --efi-directory
指定了 ESP分区的挂载点。--root-directory
已经废弃了并被取代。grub-install
命令中没有一个<device_path>选项(例如: /dev/sda
)。In fact any <device_path> provided will be ignored by the GRUB install script, as UEFI bootloaders do not use a MBR or partition boot sector at all.如今GRUB已经安装好了.请移至配置一节继续.
下面是关于经过UEFI安装Arch的相关信息
若是你想将全部的GRUB boot 文件放在ESP中,请给grub-install命令添加--boot-directory=$esp/EFI
选项:
# grub-install --target=x86_64-efi --efi-directory=$esp --bootloader-id=grub --boot-directory=$esp/EFI --recheck --debug
下面的命令会将GRUB模组文件放在$esp/EFI/grub
中.使用这个方法,grub.cfg也会被放在ESP中,因此请确保grub-mkconfig指向了正确的地方:
# grub-mkconfig -o $esp/EFI/grub/grub.cfg
配置档和BIOS-GRUB是同样的.
grub-install
会自动尝试在启动管理器中建立GRUB条目.若是没有成功,请参考Beginners' guide#GRUB,里面有关于使用efibootmgr
建立启动目录条目的介绍.通常来讲,这个问题都是由于你没有以UEFI模式启动CD/USB形成的.请参考UEFI#Create UEFI bootable USB from ISO.
能够创建一个grubx64_standalone.efi
,这个应用将全部的模组嵌入自身的memdisk中,因此就不须要使用单独的目录来存放GRUB UEFI模组和其余相关文件了,使用grub包里的grub-mkstandalone
能够实现这个功能.
最简单的的方法就是使用grub-mkstandalone
,不过,咱们还能够指定嵌入哪些模组:
# grub-mkstandalone --directory="/usr/lib/grub/x86_64-efi/" --format="x86_64-efi" --compression="xz" \ --output="$esp/EFI/grub/grubx64_standalone.efi" <你想嵌入的模组>
grubx64_standalone.efi
文件要求将grub.cfg
放置到(memdisk)/boot/grub
中,而这个memdisk是嵌入到EFI应用当中的.grub-mkstandlone
脚本容许传递将要嵌入memdisk的文件列表.(上面命令里的"<你想嵌入的模组>")
若是你的grub.cfg
的路径是/home/user/Desktop/grub.cfg
,那么须要建立一个临时的/home/user/Desktop/boot/grub/
目录,而后将grub.cfg复制到其中并进入这个目录并运行:
# grub-mkstandalone --directory="/usr/lib/grub/x86_64-efi/" --format="x86_64-efi" --compression="xz" \ --output="$esp/EFI/grub/grubx64_standalone.efi" "boot/grub/grub.cfg"
进入/home/user/Desktop/boot/grub/
可是传递boot/grub/grub.cfg
参数(请注意是boot/
而不是/boot/
)的缘由是grub-mkstandalone
会自动将boot/grub/grub.cfg处理为/(memdisk)/boot/grub/grub.cfg
若是你传递/home/user/Desktop/grub.cfg
,那么处理后的结果会是(memdisk)/home/user/Desktop/grub.cfg
.若是传递/home/user/Desktop/boot/grub/grub.cfg
,那么结果就是(memdisk)/home/user/Desktop/boot/grub/grub.cfg
.因此须要进入/home/user/Desktop/boot/grub/
并传递boot/grub/grub.cfg
参数,由于这样才能生成grub.efi
须要的(memdisk)/boot/grub/grub.cfg
.
若是须要为$esp/EFI/arch_grub/grubx64_standalone.efi
建立一个UEFI启动器条目,使用efibootmgr
.#Create GRUB entry in the Firmware Boot Manager里有介绍
能够自动生成配置档,也能够手动编辑grub.cfg
.
--boot-directory=$esp/EFI
了选项,grub.cfg
文件必须和grubx64.efi
放在同一文件夹.若是没有使用这个选项,那么grub.cfg
应当在/boot/grub/
下,和GRUB BIOS系统同样.和GRUB Legacy配置文件menu.lst
对应的GRUB配置文件是/etc/default/grub
和/etc/grub.d/*
.grub-mkconfig
使用这些文件来生成grub.cfg
.grub-mkconfig默认输出至stdout.如下命令能够生成一个grub.cfg
文件:
# grub-mkconfig -o /boot/grub/grub.cfg
/etc/grub.d/10_linux
会自动为Arch Linux设置启动项.其余操做系统的话,可能须要手动在/etc/grub.d/40_custom
或/boot/grub/custom.cfg
中设置.
在/etc/default/grub
中设置GRUB_CMDLINE_LINUX
和GRUB_CMDLINE_LINUX_DEFAULT
变量能够实现将向Linux镜像传递额外的参数.生成grub.cfg
时,若是遇到普通启动项,这两个参数会一块儿使用,遇到recovery启动项,就只使用GRUB_CMDLINE_LINUX
参数.
没有必要二者一块儿使用.这两个参数颇有用.好比,若是要系统支持休眠后恢复,须要使用GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/sdaX quiet"
(sdaX
是交换分区).这个选项会生成一个recovery启动项,这个启动项没有resume和quiet参数.其余的普通启动项也可能使用它们.(GRUB会为每一个内核生成两个启动项,一个默认的一个recovery的,GRUB_CMDLINE_LINUX指定的参数会传递给这两个启动项.GRUB_CMDLINE_LINUX_DEFAULT指定的参数只会传递给默认启动项)
当生成GRUB recovery启动项时,你必须在/etc/default/grub
中将#GRUB_DISABLE_RECOVERY=true
注释掉.
你也可使用GRUB_CMDLINE_LINUX="resume=/dev/disk/by-uuid/${swap_uuid}"
, ${swap_uuid}
是交换分区的UUID
不一样的启动项使用双引号引发来并用空格隔开.因此,对于即想使用resume又想使用systemd的用户来讲,这个参数的设置多是: GRUB_CMDLINE_LINUX="resume=/dev/sdaX init=/usr/lib/systemd/systemd"
更多信息请参考Kernel parameters.
grub-mkconfig
生成,最好编辑
/etc/default/grub
和
/etc/grub.d
文件夹下的脚本以实现修改.
基本的GRUB配置文件使用以下选项:
(hdX,Y)
是X磁盘的Y分区,分区从1开始计数,磁盘从0开始计数.set default=N
设定用户选择超时时间事后的默认启动项set timeout=M
设定用户选择超时时间(秒).menuentry "title" {entry options}
设置一个名为title
的启动项set root=(hdX,Y)
设定启动分区(kernel和GRUB模组所在磁盘),/boot没被要求独占一个分区,有可能就是root分区下的一个文件夹示例配置以下:
/boot/grub/grub.cfg
# Config file for GRUB - The GNU GRand Unified Bootloader # /boot/grub/grub.cfg # DEVICE NAME CONVERSIONS # # Linux Grub # ------------------------- # /dev/fd0 (fd0) # /dev/sda (hd0) # /dev/sdb2 (hd1,2) # /dev/sda3 (hd0,3) # # Timeout for menu set timeout=5 # Set default boot entry as Entry 0 set default=0 # (0) Arch Linux menuentry "Arch Linux" { set root=(hd0,1) linux /vmlinuz-linux root=/dev/sda3 ro initrd /initramfs-linux.img } ## (1) Windows #menuentry "Windows" { # set root=(hd0,3) # chainloader +1 #}
添加其余启动项的最好方法是编辑/etc/grub.d/40_custom
或/boot/grub/custom.cfg
.运行grub-mkconfig
后,这些文件中的启动项会被自动添加到grub.cfg中. 更新了这些文件后,运行:
# grub-mkconfig -o /boot/grub/grub.cfg
在UEFI-GPT模式下,运行:
# grub-mkconfig -o /boot/efi/EFI/GRUB/grub.cfg
这样会更新grub.cfg
一个典型/etc/grub.d/40_custom
文件相似于下面这个为HP Pavilion 15-e056sl Notebook PC|预装WIN8的HP Pavilion 15-e056sl Notebook PC而做的配置.每一个启动项的结构都应该和下面的相似.请注意UEFI分区/dev/sda2
被命名为hd0,gpt2
和ahci0,gpt2
(请参考here获取更多信息)
/etc/grub.d/40_custom:
#!/bin/sh exec tail -n +3 $0 # 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. menuentry "HP / Microsoft Windows 8.1" { echo "Loading HP / Microsoft Windows 8.1..." insmod part_gpt insmod fat insmod search_fs_uuid insmod chain search --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 763A-9CB6 chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi } menuentry "HP / Microsoft Control Center" { echo "Loading HP / Microsoft Control Center..." insmod part_gpt insmod fat insmod search_fs_uuid insmod chain search --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 763A-9CB6 chainloader (${root})/EFI/HP/boot/bootmgfw.efi } menuentry "System shutdown" { echo "System shutting down..." halt } menuentry "System restart" { echo "System rebooting..." reboot }
假设另外一个发行版位于sda2
:
menuentry "Other Linux" { set root=(hd0,2) linux /boot/vmlinuz (add other options here as required) initrd /boot/initrd.img (if the other kernel uses/needs one) }
要求FreeBSD以UFS格式被安装在单独的分区上,假设安装在sda4
上:
menuentry "FreeBSD" { set root=(hd0,4) chainloader +1 }
假设Windows分区是sda3
.请记住须要将root设置到Windows安装时创建的启动分区上,而后链式加载它,而不是Windows系统所在分区.下面的例子就是假设启动分区就是sda3
.
# (2) Windows XP menuentry "Windows XP" { set root="(hd0,3)" chainloader +1 }
若是Windows的bootloader和GRUB不在一个硬盘上,那么须要让Windows认为它是在第一硬盘上.使用drivemap
能够实现这点.假设GRUB在hd0
而windows在hd2
上,须要在设定root后执行:
drivemap -s hd0 hd2
if [ "${grub_platform}" == "efi" ]; then menuentry "Microsoft Windows Vista/7/8 x86_64 UEFI-GPT" { insmod part_gpt insmod fat insmod search_fs_uuid insmod chain search --fs-uuid --set=root $hints_string $uuid chainloader /EFI/Microsoft/Boot/bootmgfw.efi } fi
$hints_string
和 $uuid
能够经过如下命令获取:
$uuid
:
# grub-probe --target=fs_uuid $esp/EFI/Microsoft/Boot/bootmgfw.efi 1ce5-7f28
$hints_string
:
# grub-probe --target=hints_string $esp/EFI/Microsoft/Boot/bootmgfw.efi --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1
这两个命令都是假设ESP挂载在$esp
上.固然,Windows的EFI文件路径可能有变,由于这就是Windows....
menuentry "System shutdown" { echo "System shutting down..." halt }
menuentry "System restart" { echo "System rebooting..." reboot }
如今EasyBCD的NeoGRUB还不能识别GRUB的目录格式,在 C:\NST\menu.lst
中添加以下行以链式加载到GRUB:
default 0 timeout 1
title Chainload into GRUB v2 root (hd0,7) kernel /boot/grub/i386-pc/core.img
最后,使用grub-mkconfig
重建grub.cfg
GRUB默认就支持定制启动目录的外观.不过要确保使用合适的视频模式初始化GRUB的图形化终端gfxterm.在#"No suitable mode found" error一节中有介绍.GRUB经过'gfxpayload'来将视频模式传递给linux内核,因此任何可视化配置都须要这个模式的信息以正确工做.
GRUB既能够为本身,也能够为内核设定帧缓冲.如今已经不使用老的vga=
配置了.推荐方法是在/etc/default/grub
进行以下编辑:
GRUB_GFXMODE=1024x768x32 GRUB_GFXPAYLOAD_LINUX=keep
运行如下命令使配置生效:
# grub-mkconfig -o /boot/grub/grub.cfg
gfxpayload
属性会确保内核也保持这个分辨率
vbemode="0x105"
代替gfxmode="1024x768x32"
.请使用适合你屏幕的分辨率.# hwinfo --framebuffer
命令来显示全部可使用的分辨率模式(hwinfo在community里),在GRUB命令行下,可使用vbeinfo
命令这种方法无论用的话,能够试试老的vga=
方法.将它添加到"GRUB_CMDLINE_LINUX_DEFAULT="
里面就好了,好比 "GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792"
这会将系统的分辨率设定为1024*768
能够选择如下分辨率中的一种:640×480
, 800×600
, 1024×768
, 1280×1024
, 1600×1200
, 1920×1200
有些时候,Intel显卡没法经过# hwinfo --framebuffer
或vbeinfo
显示你须要的分辨率.这种状况下,你可使用915resolution hack
.915resolution hack会临时性的修改显卡BIOS来添加所需的分辨率.详情请参考915resolution's home page
首先,找一个你想要替代的视频模式.例如在GRUB命令行模式下运行:
sh:grub> 915resolution -l
Intel 800/900 Series VBIOS Hack : version 0.5.3 [...] Mode 30 : 640x480, 8 bits/pixel [...]
而后,使用1440x900
分辨率覆盖Mode 30
/etc/grub.d/00_header
[...] 915resolution 30 1440 900 # Inserted line set gfxmode=${GRUB_GFXMODE} [...]
最后,设置GRUB_GFXMODE
,从新生成GRUB配置文件,重启并测试是否生效:
# grub-mkconfig -o /boot/grub/grub.cfg # reboot
GRUB原生支持设置背景图像和点阵字体(以pf2格式).grub包含unifont字体,名为unicode.pf2
.(也有可能只包含名为ascii.pf2
的ASCII字符字体)
GRUB支持的图像格式有tga,png,jpeg.所支持的最大图像分辨率跟硬件有关.
Make sure you have set up the proper framebuffer resolution. 请确保你已经设定了合适的帧缓冲分辨率
编辑/etc/default/grub
:
GRUB_BACKGROUND="/boot/grub/myimage" #GRUB_THEME="/path/to/gfxtheme" GRUB_FONT="/path/to/font.pf2"
/boot/grub/myimage
应该改成
/grub/myimage
.
从新生成配置文件:
# grub-mkconfig -o /boot/grub/grub.cfg
若是成功的添加了背景图片,那么用户会在命令行中看到"Found background image..."
. 若是没有看到"Found background image..."
,图像信息就可能没有嵌入grub.cfg
中了.
若是图像没有正确显示,执行以下检查:
/etc/default/grub
里,图像的路径和名字是否正确/etc/default/grub
里面是否是没有开启console模式grub-mkconfig
以从新生成配置文件下面的例子将展现如何使用GRUB包重的starfield主题:
编辑 /etc/default/grub
GRUB_THEME="/usr/share/grub/themes/starfield/theme.txt"
重生成配置:
# grub-mkconfig -o /boot/grub/grub.cfg
配置成功的话,在重生成配置过程当中,会出现Found theme: /usr/share/grub/themes/starfield/theme.txt
.使用主题就不会使用以前的背景图像
GRUB支持设置目录颜色.可以使用的颜色能从the GRUB Manual里面找到.示例以下:
编辑/etc/default/grub
:
GRUB_COLOR_NORMAL="light-blue/black" GRUB_COLOR_HIGHLIGHT="light-cyan/blue"
重建配置档:
# grub-mkconfig -o /boot/grub/grub.cfg
GRUB特性之一就是支持隐藏/跳过目录,同时支持按Esc
来打断隐藏/跳过.同时还支持设置是否显示timeout计时器 下面的例子设置5s钟内没有按Esc键就启动默认的启动项,而且在屏幕上显示倒计时:
编辑/etc/default/grub
:
GRUB_HIDDEN_TIMEOUT=5 GRUB_HIDDEN_TIMEOUT_QUIET=false
重建配置档:
# grub-mkconfig -o /boot/grub/grub.cfg
Users who use NVIDIA proprietary driver might wish to disable GRUB's framebuffer as it can cause problems with the binary driver. 使用NVIDIA私有驱动的用户可能但愿禁用GRUB的framebuffer,由于会致使驱动错误.
在/etc/default/grub
中添加(若是已经有背注释掉的这行,就取消注释):
GRUB_TERMINAL_OUTPUT=console
重建配置档:
# grub-mkconfig -o /boot/grub/grub.cfg
若是你想保留GRUB的framebuffer,解决方法是在GRUB载入内核前进入文字模式.能够经过在/etc/default/grub
设置以下:
GRUB_GFXPAYLOAD_LINUX=text
而后重建配置档.
若是使用LVM作为启动设备,那么在启动项里添加:
insmod lvm
而后在启动项里指定root:
set root=lvm/lvm_group_name-lvm_logical_boot_partition_name
示例以下:
# (0) Arch Linux menuentry "Arch Linux" { insmod lvm set root=lvm/VolumeGroup-lv_boot # you can only set following two lines linux /vmlinuz-linux root=/dev/mapper/VolumeGroup-root ro initrd /initramfs-linux.img }
经过添加insmod mdraid
,GRUB可以很方便的处理磁盘阵列.好比/dev/md0
:
set root=(md0)
阵列上的分区(好比/dev/md0p1
)则为:
set root=(md0,1)
若是启动分区在raid1上,想要安装grub,只须要在两个磁盘上分别运行grub-install便可:
grub-install --target=i386-pc --recheck --debug /dev/sda && grub-install --target=i386-pc --recheck --debug /dev/sdb
这时/dev/sda和/dev/sdb就都有了raid1的启动文件夹/boot了
持久块设备命名法(Persistent block device naming)的一个目的是使用全局的UUID来区分分区,而不是用老的/dev/sd*
表示法.好处显而易见.
GRUB默认使用持久块设备命名法
/boot/grub.cfg
.经过Live-CD调整分区和文件系统后要特别注意这点
是否使用UUID由/etc/default/grub
里的这个选项控制:
# GRUB_DISABLE_LINUX_UUID=true
不管如何,变动配置后请重建配置档:
# grub-mkconfig -o /boot/grub/grub.cfg
GRUB支持以卷标识别文件系统(经过search
命令的--label参数
).
首先,给文件系统设置一个卷标:
# tune2fs -L LABEL PARTITION
而后在启动项中使用这个卷标:
menuentry "Arch Linux, session texte" { search --label --set=root archroot linux /boot/vmlinuz-linux root=/dev/disk/by-label/archroot ro initrd /boot/initramfs-linux.img }
GRUB可以记住你当前使用的启动项而且在下次启动时将其做为默认项.当你使用多个内核或操做系统时,这个特性颇有用. 编辑/etc/default/grub
中的GRUB_DEFAULT
选项:
GRUB_DEFAULT=saved
上面的命令会告诉GRUB使用记住的启动项为默认启动项. 将下面的行添加到/etc/default/grub
会让GRUB记住当前的启动项:
GRUB_SAVEDEFAULT=true
/etc/grub.d/40_custom
或
/boot/grub/custom.cfg
中,好比Windows启动项,须要添加
savedefault
请记住重建配置档.
能够经过修改/etc/default/grub
中的GRUB_DEFAULT
值来改变默认启动项
GRUB_DEFAULT=0
GRUB启动项序号从0开始计数.0表明第一个启动项.
除了使用启动项序号,也可使用启动项名:
GRUB_DEFAULT='Arch Linux, with Linux core repo kernel'
若是你想禁止其余人改变启动参数或者使用GRUB命令行,能够给GRUB配置添加用户名/密码. 运行 grub-mkpasswd-pbkdf2
,输入密码:
grub-mkpasswd-pbkdf2
[...] Your PBKDF2 is grub.pbkdf2.sha512.10000.C8ABD3E93C4DFC83138B0C7A3D719BC650E6234310DA069E6FDB0DD4156313DA3D0D9BFFC2846C21D5A2DDA515114CF6378F8A064C94198D0618E70D23717E82.509BFA8A4217EAD0B33C87432524C0B6B64B34FBAD22D3E6E6874D9B101996C5F98AB1746FE7C7199147ECF4ABD8661C222EEEDB7D14A843261FFF2C07B1269A
而后将下面的内容添加到/etc/grub.d/00_header
:
/etc/grub.d/00_header
cat << EOF set superusers="username" password_pbkdf2 username <password> EOF
set superusers="username" password_pbkdf2 username <password> 添加到/etc/grub.d/00_header中去,而必须使用上述方法.不然会报错 password_pbkdf2: not found
<password>
是grub-mkpasswd_pbkdf2
生成的那个加密事后密码.
而后重建配置档.其余用户没有密码就不能变动GRUB配置或者使用GRUB命令行了.
能够参考the GRUB manual中的"Security"部分来进行更多的客制化安全设定
将cryptdevice=/dev/yourdevice:label
添加到/etc/default/grub
中的GRUB_CMDLINE_LINUX
配置项,可让GRUB传递参数给内核,让内核对root加密:
/boot/grub/menu.lst.pacsave
以获取正确的device/label. 在
kernel /vmlinuz-linux
后去找label.
将root映射到/dev/mapper/root
:
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root"
固然,须要在rootfs上禁用UUID:
GRUB_DISABLE_LINUX_UUID=true
Regenerate the configuration.
命令grub-reboot
能够设置下次启动时启动哪一个启动项而没必要修改配置文件或者在启动时手动选择.这个设置是一次性的,即不会改变GRUB的默认启动项.
/etc/default/grub
中设定
GRUB_DEFAULT=saved
,而后重建配置档.在手动生成的
grub.cfg
中, 使用
set default="${saved_entry}"
.
为了获取更快的启动速度,而不用等GRUB倒计时,能够命令GRUB在启动时隐藏目录,除非SHIFT被按着. 将以下行添加到/etc/default/grub
:
GRUB_FORCE_HIDDEN_MENU="true"
而后建立以下文件:
/etc/grub.d/31_hold_shift
#! /bin/sh set -e # grub-mkconfig helper script. # Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GRUB is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GRUB. If not, see <http://www.gnu.org/licenses/>. prefix="/usr" exec_prefix="${prefix}" datarootdir="${prefix}/share" export TEXTDOMAIN=grub export TEXTDOMAINDIR="${datarootdir}/locale" source "${datarootdir}/grub/grub-mkconfig_lib" found_other_os= make_timeout () { if [ "x${GRUB_FORCE_HIDDEN_MENU}" = "xtrue" ] ; then if [ "x${1}" != "x" ] ; then if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then verbose= else verbose=" --verbose" fi if [ "x${1}" = "x0" ] ; then cat <<EOF if [ "x\${timeout}" != "x-1" ]; then if keystatus; then if keystatus --shift; then set timeout=-1 else set timeout=0 fi else if sleep$verbose --interruptible 3 ; then set timeout=0 fi fi fi EOF else cat << EOF if [ "x\${timeout}" != "x-1" ]; then if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then set timeout=0 fi fi EOF fi fi fi } adjust_timeout () { if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then cat <<EOF if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then EOF make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}" echo else make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" echo fi else make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}" fi } adjust_timeout cat <<EOF if [ "x\${timeout}" != "x-1" ]; then if keystatus; then if keystatus --shift; then set timeout=-1 else set timeout=0 fi else if sleep$verbose --interruptible 3 ; then set timeout=0 fi fi fi EOF
编辑/etc/grub.d/40_custom
或 /boot/grub/custom.cfg
,给目标ISO添加一个启动项.而后使用grub-mkconfig -o /boot/grub/grub.cfg
更新配置档
hd0,6
分区上的
/archives
文件夹里
(hd1,$partition)
and either
/dev/sdbY
for the
img_dev
parameter or
a persistent name, e.g.
img_dev=/dev/disk/by-label/CORSAIR
.
(hd1,$partition)
或
/dev/sdbY
做为
img_dev
参数的值,或者使用持久块设备命名法命名的设备,好比
img_dev=/dev/disk/by-label/CORSAIR
.
menuentry "Archlinux-2013.05.01-dual.iso" --class iso { set isofile="/archives/archlinux-2013.05.01-dual.iso" set partition="6" loopback loop (hd0,$partition)/$isofile linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201305 img_dev=/dev/sda$partition img_loop=$isofile earlymodules=loop initrd (loop)/arch/boot/x86_64/archiso.img }
menuentry "Archlinux-2013.05.01-dual.iso" --class iso { set isofile="/archives/archlinux-2013.05.01-dual.iso" set partition="6" loopback loop (hd0,$partition)/$isofile linux (loop)/arch/boot/i686/vmlinuz archisolabel=ARCH_201305 img_dev=/dev/sda$partition img_loop=$isofile earlymodules=loop initrd (loop)/arch/boot/i686/archiso.img }
hd0,6
分区上的
/archives
文件夹里. 用户须要根据本身系统的实际状况调整.
menuentry "ubuntu-13.04-desktop-amd64.iso" { set isofile="/archives/ubuntu-13.04-desktop-amd64.iso" loopback loop (hd0,6)/$isofile linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash -- initrd (loop)/casper/initrd.lz }
menuentry "ubuntu-12.04-desktop-amd64.iso" { set isofile="/archives/ubuntu-12.04-desktop-amd64.iso" loopback loop (hd0,6)/$isofile linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash -- initrd (loop)/casper/initrd.lz }
可从这里获取其余ISO的配置.
MBR过小,因此不足以存储全部的GRUB模组.MBR里面只有启动目录配置和一些很基本的命令.GRUB的主要功能经过/boot/grub
里的模组实现,并且能够按需加载.出现错误时,GRUB可能不能引导启动(好比,磁盘分区发生了变化).这时候,通常会出现命令行界面.
GRUB不止提供一个shell.若是GRUB不能读取到启动目录配置,可是能找到磁盘,你极可能须要进入"normal" shell:
sh:grub>
若是有更严重的问题(好比,GRUB找不到必须的文件了),你就可能须要进入"rescue" shell:
grub rescue>
"rescue" shell是"normal" shell的一个子集,其支持的功能更少.若是不幸进入了"rescue" shell里,首先记载"normal"模组,而后启动"normal" shell:
grub rescue> set prefix=(hdX,Y)/boot/grub grub rescue> insmod (hdX,Y)/boot/grub/i386-pc/normal.mod rescue:grub> normal
GRUB支持对长输出进行分页(好比运行help
的输出).不过只有normal shell支持分页,而rescue shell不支持.开启分页支持的方法以下:
sh:grub> set pager=1
grub>
可使用GRUB命令行引导操做系统,一个典型的应用场景是经过chainloading来引导另外一个Windows或Linux
ChainLoading的意思是用当前的bootloader去载入另外一个bootloader,因此叫作链式加载.这个bootloader可能位于MBR,也可能在另外一个分区的引导扇区上.
set root=(hdX,Y) chainloader +1 boot
X=0,1,2... Y=1,2,3...
好比链式加载一个位于首磁盘,首分区上的Windows:
set root=(hd0,1) chainloader +1 boot
也可使用GRUB链式加载另外一个分区引导扇区上的GRUB.
set root=hdX chainloader +1 boot
请参考#使用应急命令行
若是你安装了Windows 9x系列操做系统,而它们隐藏了磁盘(好比C盘),GRUB可以使用parttool来设置是否隐藏.好比,想从三个Windows 9x系统的第三个启动,能够这样:
parttool hd0,1 hidden+ boot- parttool hd0,2 hidden+ boot- parttool hd0,3 hidden- boot+ set root=hd0,3 chainloader +1 boot
请先阅读#使用GRUB命令行.若是没法进入命令行,请尝试使用Live CD或者其余rescue磁盘引导,而后修正错误.不过有些时候咱们手上没有此类rescue磁盘,这时,应急命令行(rescue console)就能够派上用场了.
GRUB应急命令行里可用的命令有insmod
, ls
, set
, unset
.可使用set/unset修改变量,使用insmod来载入模组.
首先,用户必须知道启动分区(/boot
所在位置而后设置:
grub rescue> set prefix=(hdX,Y)/boot/grub
经过加载linux
模组来扩展命令行的功能:
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod
set prefix=(hdX,Y)/grub
而后
insmod (hdX,Y)/grub/linux.mod
)
这个模组会启动对咱们熟悉的linux
和 initrd
命令的支持 (请参考#配置).
好比:
set root=(hd0,5) linux /boot/vmlinuz-linux root=/dev/sda5 initrd /boot/initramfs-linux.img boot
若是/boot在单独分区上:
set root=(hd0,5) linux /vmlinuz-linux root=/dev/sda6 initrd /initramfs-linux.img boot
成功启动Arch后,用户能够修正配置的错误或者从新安装GRUB.
若是你想要使用UUID来避免不可靠的BIOS设备命名或者正在研究GRUB语法,这里有个使用UUID的示例性的启动项配置脚本.若是你想要将其移植到本身的系统上,只须要修改UUID就好了.这个例子假设系统的boot和root文件系统是在不一样的分区上.若是你还有其余分区,请作相应修改.
menuentry "Arch Linux 64" { # Set the UUIDs for your boot and root partition respectively set the_boot_uuid=ece0448f-bb08-486d-9864-ac3271bd8d07 set the_root_uuid=c55da16f-e2af-4603-9e0b-03f5f565ec4a # (Note: This may be the same as your boot partition) # Get the boot/root devices and set them in the root and grub_boot variables search --fs-uuid $the_root_uuid --set=root search --fs-uuid $the_boot_uuid --set=grub_boot # Check to see if boot and root are equal. # If they are, then append /boot to $grub_boot (Since $grub_boot is actually the root partition) if [ $the_boot_uuid == $the_root_uuid ] ; then set grub_boot=($grub_boot)/boot else set grub_boot=($grub_boot) fi # $grub_boot now points to the correct location, so the following will properly find the kernel and initrd linux $grub_boot/vmlinuz-linux root=/dev/disk/by-uuid/$the_root_uuid ro initrd $grub_boot/initramfs-linux.img }
一些Intel的BIOS要求至少要一个可启动的分区(MBR方案下的),致使GTP方案下的分区GRUB没法启动.
能够经过fdisk来将一个GPT分区标志为'boot'((最好就设在你为GRUB建立的那个1007KiB分区上)),这样就能够绕过这个问题了:
1.对目标磁盘(好比/dev/sda)运行fdisk 2.按键,而后选择想要设置'boot'标志的分区 3.最后按键,将变动写入磁盘 aw
请参考 http://www.rodsbooks.com/gdisk/bios.html
在grub.cfg
里添加:
set pager=1 set debug=all
启动时可能出现以下提示信息:
error: no suitable mode found Booting however
而后你须要以合适的视频模式(gfxmode
)启动 GRUB 图形化终端(gfxterm
).视频模式由GRUB经过'gfxpayload'变量传递给linux内核.在UEFI系统下,若是没有初始化视频模式的值,终端上就不会显示内核启动消息(至少直到KMS开始运行)
将/usr/share/grub/unicode.pf2
复制到 ${GRUB_PREFIX_DIR}(/boot/grub/
.若是GRUB UEFI安装时设定了--boot-directory=$esp/EFI
,那么复制的目的文件夹是$esp/EFI/grub/
:
# cp /usr/share/grub/unicode.pf2 ${GRUB_PREFIX_DIR}
若是/usr/share/grub/unicode.pf2
不存在, 安装bdf-unifont, 建立 unifont.pf2
文件而后将其复制到 ${GRUB_PREFIX_DIR}
:
# grub-mkfont -o unicode.pf2 /usr/share/fonts/misc/unifont.bdf
而后,在grub.cfg
文件中添加以下行: (会给linux内核传递合适的视频模式,不然你只会获得一个黑屏,虽然系统仍是会启动成功) BIOS 系统:
insmod vbe
UEFI 系统:
insmod efi_gop insmod efi_uga
在这些行后添加(BIOS&&UEFI):
insmod font
if loadfont ${prefix}/fonts/unicode.pf2 then insmod gfxterm set gfxmode=auto set gfxpayload=keep terminal_output gfxterm fi
若是要gfxterm(图形化终端)工做正常,${GRUB_PREFIX_DIR}
文件夹里面应该要有unicode.pf2
.
如下错误可能出如今你将GRUB安装到VMware上时.请阅读相关连接.这种状况是由于首分区直接从MBR后开始(即第64个扇区),而不是和正常的那样有1到2M post-MBR gap.请参阅#MBR专用指令
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding will not be possible! grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and its use is discouraged. grub-setup: error: If you really want blocklists, use --force.
若是GRUB直接就启动到了rescue shell下,并且没报错,这多是由于grub.cfg
丢失或者位置不对.若是GRUB UEFI 安装时设定了--boot-directory
参数,而grub.cfg
文件丢失,会出现这个问题.若是启动分区的分区号发生了变化(这个分区号会被直接编码到grubx64.efi
文件中),也会出现这个问题.
下面是一个EFI启动项信息示例:
# efibootmgr -v
BootCurrent: 0000 Timeout: 3 seconds BootOrder: 0000,0001,0002 Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\efi\grub\grub.efi) Boot0001* Shell HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\EfiShell.efi) Boot0002* Festplatte BIOS(2,0,00)P0: SAMSUNG HD204UI
若是启动后,屏幕直接变黑,几秒后就跳到了下一个启动项,根据相关连接的说法是,将GRUB移动到root分区上可能会解决这个问题.必须先删除启动项,而后重建,变化以下:
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\grub.efi)
若是在启动Windows时出现了"invalid signature"错误(好比在从新分区或者添加了新硬盘后),删除GRUB的磁盘mapping,而后重建:
# mv /boot/grub/device.map /boot/grub/device.map-old # grub-mkconfig -o /boot/grub/grub.cfg
grub-mkconfig
此时就应该生成了新的启动项了,包括Windows.确认能启动成功后,再将备份文件/boot/grub/device.map-old
删除.
若是在GRUB载入内核并初始化ramdisk后引导过程卡死了,请尝试移除add_efi_memmap
这个内核参数
# mv /boot/grub /boot/grub.nonfunctional
/boot
:# cp -af /boot/grub-legacy /boot/grub
# dd if=/path/to/backup/first-sectors of=/dev/sdX bs=512 count=1
安全的方法是只恢复MBR中的启动代码:
# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=446 count=1
有人发现有些发行版不能使用os-prober
自动发现Arch Linux.据称先使用/etc/lsb-release
可能会解决这个问题.相关文件和工具能够在 官方仓库的lsb-release包中找到