Which command is used to install a GRUB boot loader into the master boot record?



A.

grub-install

B.

grub-mkconfig

C.

grub-install-mbr

D.

grub-glue-mbr

E.

grub-mbr-setup

題解

「grub-install」指令用來安裝GRUB開機啟動程式。

GRUB(Legacy)的設定檔位於「/etc/grub.conf」,內容如下:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_magiclencentos-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-642.1.1.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-642.1.1.el6.x86_64 ro root=/dev/mapper/vg_magiclencentos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_magiclencentos/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_magiclencentos/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-642.1.1.el6.x86_64.img

修改並儲存完之後無需再輸入指令即可套用。

若是GRUB2的話,設定檔位於「/etc/default/grub」,內容如下:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

修改完之後,Debian系的Linux發行版需要使用以下指令來套用設定:

update-grub

RedHat系的Linux發行版則需要使用以下指令來套用設定:

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