Powered By GitBook
102.2. Install a boot manager

102.2 Install a boot manager

Weight: 2
Description: Candidates should be able to select, install and configure a boot manager.
Key Knowledge Areas:
    Providing alternative boot locations and backup boot options
    Install and configure a boot loader such as GRUB Legacy
    Perform basic configuration changes for GRUB 2
    Interact with the boot loader
The following is a partial list of the used files, terms and utilities:
    menu.lst, grub.cfg and grub.conf
    grub-install
    grub-mkconfig
    MBR
We have talked about linux boot process and boot loaders. We got introduced to LILO as a very old boot loader which was replaced by GRUB in late 1990s. In this course we take a closer look at GRUB and GRUB2 boot loaders .

GRUB

GRUB (GRand Unified Bootloader) is a boot loader package developed to support multiple operating systems and allow the user to select among them during boot-up.

GRUB versions

GRUB was created by Erich Stefan Boleyn and has been further developed under the GNU project as GNU GRUB. The original package is still available for download but no longer being developed.
GRUB2 has replaced what was formerly known as GRUB (i.e. version 0.9x), which has, in turn, become GRUB Legacy. Enhancements to GRUB2 are still being made, but the current released versions are quite usable for normal operation.

How does GRUB work?

When a computer boots, the BIOS transfers control to the first boot device, which can be a hard disk, a floppy disk, a CD-ROM, or any other BIOS-recognized device.

MBR

The first sector on a hard is called the Master Boot Record (MBR). This sector is only 512 bytes long and contains a small piece of code (446 bytes) called the primary boot loader and the partition table (64 bytes) describing the primary and extended partitions.
GRUB replaces the default MBR with its own code:
1
[[email protected] ~]# xxd -l 512 /dev/sda
Copied!
By default, MBR code looks for the partition marked as active and once such a partition is found, it loads its boot sector into memory and passes control to it.
1
[[email protected] ~]# fdisk -l /dev/sda
2
3
Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors
4
Units = sectors of 1 * 512 = 512 bytes
5
Sector size (logical/physical): 512 bytes / 512 bytes
6
I/O size (minimum/optimal): 512 bytes / 512 bytes
7
Disk label type: dos
8
Disk identifier: 0x000a1a5f
9
10
Device Boot Start End Blocks Id System
11
/dev/sda1 * 2048 2099199 1048576 83 Linux
12
/dev/sda2 2099200 104857599 51379200 8e Linux LVM
Copied!
Furthermore, GRUB works in stages.
    Stage 1 is located in the MBR and mainly points to Stage 2, since the MBR is too small to contain all of the needed data.
    Stage 2 points to its configuration file, which contains all of the complex user interface and options we are normally familiar with when talking about GRUB. Stage 2 can be located anywhere on the disk. If Stage 2 cannot find its configuration table, GRUB will cease the boot sequence and present the user with a command line for manual configuration.
The Stage architecture allows GRUB to be large (~20-30K) and therefore fairly complex and highly configurable, compared to most bootloaders, which are sparse and simple to fit within the limitations of the Partition Table.

GRUB Legacy vs GRUB2

Lets draw a big picture:
/boot/grub/menu.lst in GRUB Legacy has been replaced by /boot/grub/grub.cfg in GRUB2.
1
### GRUB Legacy
2
[[email protected] ~]# ls /boot
3
config-2.6.18-398.el5 message
4
grub symvers-2.6.18-398.el5.gz
5
initrd-2.6.18-398.el5.img System.map-2.6.18-398.el5
6
lost+found vmlinuz-2.6.18-398.el5
7
8
[[email protected] ~]# ls /boot/grub/
9
device.map grub.conf minix_stage1_5 stage2
10
e2fs_stage1_5 iso9660_stage1_5 reiserfs_stage1_5 ufs2_stage1_5
11
fat_stage1_5 jfs_stage1_5 splash.xpm.gz vstafs_stage1_5
12
ffs_stage1_5 menu.lst stage1 xfs_stage1_5
13
##############################################################
14
### GRUB2
15
[[email protected] ~]# ls /boot/
16
config-3.10.0-693.el7.x86_64
17
efi
18
grub
19
grub2
20
initramfs-0-rescue-1cf30b938dc94f2bb08fb045c7a0734e.img
21
initramfs-3.10.0-693.el7.x86_64.img
22
initramfs-3.10.0-693.el7.x86_64kdump.img
23
initrd-plymouth.img
24
symvers-3.10.0-693.el7.x86_64.gz
25
System.map-3.10.0-693.el7.x86_64
26
vmlinuz-0-rescue-1cf30b938dc94f2bb08fb045c7a0734e
27
vmlinuz-3.10.0-693.el7.x86_64
28
[[email protected] ~]# ls /boot/grub
29
splash.xpm.gz
30
31
[[email protected] ~]# ls /boot/grub2
32
device.map fonts grub.cfg grubenv i386-pc locale
Copied!
Which version of linux use which grub ?
Demonstration
In order to show differences between GRUB Legacy and GRUB2, lets change timeout parameter in Two systems (CentsOS5 and Centos7) :
1
[[email protected] ~]# cat /boot/grub/menu.lst
2
# grub.conf generated by anaconda
3
#
4
# Note that you do not have to rerun grub after making changes to this file
5
# NOTICE: You have a /boot partition. This means that
6
# all kernel and initrd paths are relative to /boot/, eg.
7
# root (hd0,0)
8
# kernel /vmlinuz-version ro root=/dev/sda2
9
# initrd /initrd-version.img
10
#boot=/dev/sda
11
default=0
12
timeout=5
13
splashimage=(hd0,0)/grub/splash.xpm.gz
14
hiddenmenu
15
title CentOS (2.6.18-398.el5)
16
root (hd0,0)
17
kernel /vmlinuz-2.6.18-398.el5 ro root=LABEL=/ rhgb quiet
18
initrd /initrd-2.6.18-398.el5.img
Copied!
just make a change in menu.lst and save it and that is all.

grub.cfg (GRUB2)

grub.cfg is overwritten by certain Grub 2 package updates, whenever a kernel is added or removed, or when the user runs update-grub.Do not edit grub.cfg directly!!
1
[[email protected] ~]# cat /boot/grub2/grub.cfg
2
#
3
# DO NOT EDIT THIS FILE
4
#
5
# It is automatically generated by grub2-mkconfig using templates
6
# from /etc/grub.d and settings from /etc/default/grub
7
#
8
9
### BEGIN /etc/grub.d/00_header ###
10
set pager=1
11
12
if [ -s $prefix/grubenv ]; then
13
load_env
14
fi
15
if [ "${next_entry}" ] ; then
16
set default="${next_entry}"
17
set next_entry=
18
save_env next_entry
19
set boot_once=true
20
else
21
set default="${saved_entry}"
22
fi
23
24
if [ x"${feature_menuentry_id}" = xy ]; then
25
menuentry_id_option="--id"
26
else
27
menuentry_id_option=""
28
fi
29
30
export menuentry_id_option
31
32
if [ "${prev_saved_entry}" ]; then
33
set saved_entry="${prev_saved_entry}"
34
save_env saved_entry
35
set prev_saved_entry=
36
save_env prev_saved_entry
37
set boot_once=true
38
fi
39
40
function savedefault {
41
if [ -z "${boot_once}" ]; then
42
saved_entry="${chosen}"
43
save_env saved_entry
44
fi
45
}
46
47
function load_video {
48
if [ x$feature_all_video_module = xy ]; then
49
insmod all_video
50
else
51
insmod efi_gop
52
insmod efi_uga
53
insmod ieee1275_fb
54
insmod vbe
55
insmod vga
56
insmod video_bochs
57
insmod video_cirrus
58
fi
59
}
60
61
terminal_output console
62
if [ x$feature_timeout_style = xy ] ; then
63
set timeout_style=menu
64
set timeout=5
65
# Fallback normal timeout code in case the timeout_style feature is
66
# unavailable.
67
else
68
set timeout=5
69
fi
70
### END /etc/grub.d/00_header ###
71
72
### BEGIN /etc/grub.d/00_tuned ###
73
set tuned_params=""
74
set tuned_initrd=""
75
### END /etc/grub.d/00_tuned ###
76
77
### BEGIN /etc/grub.d/01_users ###
78
if [ -f ${prefix}/user.cfg ]; then
79
source ${prefix}/user.cfg
80
if [ -n "${GRUB2_PASSWORD}" ]; then
81
set superusers="root"
82
export superusers
83
password_pbkdf2 root ${GRUB2_PASSWORD}
84
fi
85
fi
86
### END /etc/grub.d/01_users ###
87
88
### BEGIN /etc/grub.d/10_linux ###
89
menuentry 'CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-162b8754-3820-4229-9ab4-810de8ab8558' {
90
load_video
91
set gfxpayload=keep
92
insmod gzio
93
insmod part_msdos
94
insmod xfs
95
set root='hd0,msdos1'
96
if [ x$feature_platform_search_hint = xy ]; then
97
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 985589ee-8d6c-4dbb-9463-90576a5a1ff4
98
else
99
search --no-floppy --fs-uuid --set=root 985589ee-8d6c-4dbb-9463-90576a5a1ff4
100
fi
101
linux16 /vmlinuz-3.10.0-693.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=en_US.UTF-8
102
initrd16 /initramfs-3.10.0-693.el7.x86_64.img
103
}
104
menuentry 'CentOS Linux (0-rescue-1cf30b938dc94f2bb08fb045c7a0734e) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-1cf30b938dc94f2bb08fb045c7a0734e-advanced-162b8754-3820-4229-9ab4-810de8ab8558' {
105
load_video
106
insmod gzio
107
insmod part_msdos
108
insmod xfs
109
set root='hd0,msdos1'
110
if [ x$feature_platform_search_hint = xy ]; then
111
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 985589ee-8d6c-4dbb-9463-90576a5a1ff4
112
else
113
search --no-floppy --fs-uuid --set=root 985589ee-8d6c-4dbb-9463-90576a5a1ff4
114
fi
115
linux16 /vmlinuz-0-rescue-1cf30b938dc94f2bb08fb045c7a0734e root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet
116
initrd16 /initramfs-0-rescue-1cf30b938dc94f2bb08fb045c7a0734e.img
117
}
118
119
### END /etc/grub.d/10_linux ###
120
121
### BEGIN /etc/grub.d/20_linux_xen ###
122
### END /etc/grub.d/20_linux_xen ###
123
124
### BEGIN /etc/grub.d/20_ppc_terminfo ###
125
### END /etc/grub.d/20_ppc_terminfo ###
126
127
### BEGIN /etc/grub.d/30_os-prober ###
128
### END /etc/grub.d/30_os-prober ###
129
130
### BEGIN /etc/grub.d/40_custom ###
131
# This file provides an easy way to add custom menu entries. Simply type the
132
# menu entries you want to add after this comment. Be careful not to change
133
# the 'exec tail' line above.
134
### END /etc/grub.d/40_custom ###
135
136
### BEGIN /etc/grub.d/41_custom ###
137
if [ -f ${config_directory}/custom.cfg ]; then
138
source ${config_directory}/custom.cfg
139
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
140
source $prefix/custom.cfg;
141
fi
142
### END /etc/grub.d/41_custom ###
Copied!
In order to make any changes in grub.cfg two steps are required.

1-/etc/default/grub

first edit /etc/default/grub:
1
[[email protected] ~]# cat /etc/default/grub
2
GRUB_TIMEOUT=5
3
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
4
GRUB_DEFAULT=saved
5
GRUB_DISABLE_SUBMENU=true
6
GRUB_TERMINAL_OUTPUT="console"
7
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
8
GRUB_DISABLE_RECOVERY="true"
Copied!
save chanages in /etc/default/grub. The configurations are written to /boot/grub2/grub.cfg using grub-mkconfig command

2- grub-mkconfig

grub-mkconfig Generate a GRUB configuration file.
1
[[email protected] ~]# grub2-mkconfig
2
Generating grub configuration file ...
3
#
4
# DO NOT EDIT THIS FILE
5
#
6
# It is automatically generated by grub2-mkconfig using templates
7
# from /etc/grub.d and settings from /etc/default/grub
8
#
9
10
### BEGIN /etc/grub.d/00_header ###
11
set pager=1
12
13
if [ -s $prefix/grubenv ]; then
14
load_env
15
fi
16
if [ "${next_entry}" ] ; then
17
set default="${next_entry}"
18
set next_entry=
19
save_env next_entry
20
set boot_once=true
21
else
22
set default="${saved_entry}"
23
fi
24
25
if [ x"${feature_menuentry_id}" = xy ]; then
26
menuentry_id_option="--id"
27
else
28
menuentry_id_option=""
29
fi
30
31
export menuentry_id_option
32
33
if [ "${prev_saved_entry}" ]; then
34
set saved_entry="${prev_saved_entry}"
35
save_env saved_entry
36
set prev_saved_entry=
37
save_env prev_saved_entry
38
set boot_once=true
39
fi
40
41
function savedefault {
42
if [ -z "${boot_once}" ]; then
43
saved_entry="${chosen}"
44
save_env saved_entry
45
fi
46
}
47
48
function load_video {
49
if [ x$feature_all_video_module = xy ]; then
50
insmod all_video
51
else
52
insmod efi_gop
53
insmod efi_uga
54
insmod ieee1275_fb
55
insmod vbe
56
insmod vga
57
insmod video_bochs
58
insmod video_cirrus
59
fi
60
}
61
62
terminal_output console
63
if [ x$feature_timeout_style = xy ] ; then
64
set timeout_style=menu
65
set timeout=5
66
# Fallback normal timeout code in case the timeout_style feature is
67
# unavailable.
68
else
69
set timeout=5
70
fi
71
### END /etc/grub.d/00_header ###
72
73
### BEGIN /etc/grub.d/00_tuned ###
74
set tuned_params=""
75
set tuned_initrd=""
76
### END /etc/grub.d/00_tuned ###
77
78
### BEGIN /etc/grub.d/01_users ###
79
if [ -f ${prefix}/user.cfg ]; then
80
source ${prefix}/user.cfg
81
if [ -n "${GRUB2_PASSWORD}" ]; then
82
set superusers="root"
83
export superusers
84
password_pbkdf2 root ${GRUB2_PASSWORD}
85
fi
86
fi
87
### END /etc/grub.d/01_users ###
88
89
### BEGIN /etc/grub.d/10_linux ###
90
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
91
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
92
menuentry 'CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-162b8754-3820-4229-9ab4-810de8ab8558' {
93
load_video
94
set gfxpayload=keep
95
insmod gzio
96
insmod part_msdos
97
insmod xfs
98
set root='hd0,msdos1'
99
if [ x$feature_platform_search_hint = xy ]; then
100
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 985589ee-8d6c-4dbb-9463-90576a5a1ff4
101
else
102
search --no-floppy --fs-uuid --set=root 985589ee-8d6c-4dbb-9463-90576a5a1ff4
103
fi
104
linux16 /vmlinuz-3.10.0-693.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet
105
initrd16 /initramfs-3.10.0-693.el7.x86_64.img
106
}
107
Found linux image: /boot/vmlinuz-0-rescue-1cf30b938dc94f2bb08fb045c7a0734e
108
Found initrd image: /boot/initramfs-0-rescue-1cf30b938dc94f2bb08fb045c7a0734e.img
109
menuentry 'CentOS Linux (0-rescue-1cf30b938dc94f2bb08fb045c7a0734e) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-1cf30b938dc94f2bb08fb045c7a0734e-advanced-162b8754-3820-4229-9ab4-810de8ab8558' {
110
load_video
111
insmod gzio
112
insmod part_msdos
113
insmod xfs
114
set root='hd0,msdos1'
115
if [ x$feature_platform_search_hint = xy ]; then
116
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 985589ee-8d6c-4dbb-9463-90576a5a1ff4
117
else
118
search --no-floppy --fs-uuid --set=root 985589ee-8d6c-4dbb-9463-90576a5a1ff4
119
fi
120
linux16 /vmlinuz-0-rescue-1cf30b938dc94f2bb08fb045c7a0734e root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet
121
initrd16 /initramfs-0-rescue-1cf30b938dc94f2bb08fb045c7a0734e.img
122
}
123
if [ "x$default" = 'CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)' ]; then default='Advanced options for CentOS Linux>CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)'; fi;
124
### END /etc/grub.d/10_linux ###
125
126
### BEGIN /etc/grub.d/20_linux_xen ###
127
### END /etc/grub.d/20_linux_xen ###
128
129
### BEGIN /etc/grub.d/20_ppc_terminfo ###
130
### END /etc/grub.d/20_ppc_terminfo ###
131
132
### BEGIN /etc/grub.d/30_os-prober ###
133
### END /etc/grub.d/30_os-prober ###
134
135
### BEGIN /etc/grub.d/40_custom ###
136
# This file provides an easy way to add custom menu entries. Simply type the
137
# menu entries you want to add after this comment. Be careful not to change
138
# the 'exec tail' line above.
139
### END /etc/grub.d/40_custom ###
140
141
### BEGIN /etc/grub.d/41_custom ###
142
if [ -f ${config_directory}/custom.cfg ]; then
143
source ${config_directory}/custom.cfg
144
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
145
source $prefix/custom.cfg;
146
fi
147
### END /etc/grub.d/41_custom ###
148
done
Copied!
It reads main grub script files from /etc/grub.d and setting from /etc/default/grub and print out generated configuration.
1
[[email protected] ~]# ls /etc/grub.d/
2
00_header 01_users 20_linux_xen 30_os-prober 41_custom
3
00_tuned 10_linux 20_ppc_terminfo 40_custom README
Copied!
grub2-mkconfig options:
1
[[email protected] ~]# grub2-mkconfig --help
2
Usage: grub2-mkconfig [OPTION]
3
Generate a grub config file
4
5
-o, --output=FILE output generated config to FILE [default=stdout]
6
-h, --help print this message and exit
7
-v, --version print the version information and exit
8
9
Report bugs to <[email protected]>.
Copied!
For saving generated configuration we use -o option (it is recommanded to take a backup from /boot/grub2/grub.cfg file, how ever this is not touching Master Boot Record and just re touches GRUB menu):
1
[[email protected] ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
2
Generating grub configuration file ...
3
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
4
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
5
Found linux image: /boot/vmlinuz-0-rescue-1cf30b938dc94f2bb08fb045c7a0734e
6
Found initrd image: /boot/initramfs-0-rescue-1cf30b938dc94f2bb08fb045c7a0734e.img
7
done
Copied!
We where able to use grub2-mkconfig > /boot/grub2/grub.cfg command too,and GRUB2 configuration steps finish here.

grub-update

When you run the update-grub command, GRUB automatically combines the settings from the /etc/default/grub file, the scripts from the /etc/grub.d/ directory, and everything else, creating a /boot/grub/grub.cfg file that’s read at boot.

GRUB Interfaces

There are three interfaces in GRUB which all provide different levels of functionality. The Linux kernel can be booted by the users with the help of these interfaces. Details about the interfaces are:
1-Menu Interface
The GRUB is configured by the installation program in the menu interface. It is the default interface available. It contains a list of the operating systems or kernels which is ordered by name. A specific operating system or kernel can be selected using the arrow keys and it can be booted using the enter key.
GRUB Legacy
GRUB2
Missing 'a' hah!
2-Menu Entry Editor Interface
The e key (a key GRUB Legacy) in the boot loader menu is used to access the menu entry editor. All the GRUB commands for the particular menu entry are displayed there and these commands may be altered before loading the operating system.
GRUB Legacy
GRUB2
3-Command Line Interface
This interface is the most basic GRUB interface but it grants the most control to the user. Using the command line interface, any command can be executed by typing it and then pressing enter. This interface also features some advanced shell features.
GRUB Legacy
It is possible to have GRUB Legacy command prompt after rebooting the system and gain information form there.
2
Probing devices to guess BIOS drives. This may take a long time.
3
4
5
GNU GRUB version 0.97 (640K lower / 3072K upper memory)
6
7
[ Minimal BASH-like line editing is supported. For the first word, TAB
8
lists possible command completions. Anywhere else TAB lists the possible
9
completions of a device/filename.]
Copied!
GRUB2
Note: Partition numbering has changed in GRUB2. The first partition is 1 in GRUB2 rather than 0 (GRUB Legacy). The first device/drive is still hd0 by default (no change).

GRUB Installation

Normally when we setup a system GRUB is installed for us but there are some cases which we might need to install GRUB ourselves. There are different ways to install GRUB.
If we are on old system with GRUB legacy we can run grub-install command or using setup command in GRUB shell.
1
[[email protected] ~]# grub-install /dev/sdb
Copied!
If we are on GRUB2 we can use one of GRUB2 utilities.
1
[[email protected] ~]# grub2-
2
grub2-bios-setup grub2-mkconfig grub2-ofpathname
3
grub2-editenv grub2-mkfont grub2-probe
4
grub2-file grub2-mkimage grub2-reboot
5
grub2-fstest grub2-mklayout grub2-rpm-sort
6
grub2-get-kernel-settings grub2-mknetdir grub2-script-check
7
grub2-glue-efi grub2-mkpasswd-pbkdf2 grub2-set-default
8
grub2-install grub2-mkrelpath grub2-setpassword
9
grub2-kbdcomp grub2-mkrescue grub2-sparc64-setup
10
grub2-menulst2cfg grub2-mkstandalone grub2-syslinux2cfg
Copied!

grub2-install

grub-install installs GRUB onto a device. This includes copying GRUB images into the target directory (generally /boot/grub), and on some platforms may also include installing GRUB onto a boot sector.
1
[[email protected] ~]# grub2-install --help
2
Usage: grub2-install [OPTION...] [OPTION] [INSTALL_DEVICE]
3
Install GRUB on your drive.
4
5
--compress[=no,xz,gz,lzo] compress GRUB files [optional]
6
-d, --directory=DIR use images and modules under DIR
7
[default=/usr/lib/grub/<platform>]
8
--fonts=FONTS install FONTS [default=unicode]
9
--install-modules=MODULES install only MODULES and their dependencies
10
[default=all]
11
-k, --pubkey=FILE embed FILE as public key for signature checking
12
--locale-directory=DIR use translations under DIR
13
[default=/usr/share/locale]
14
--locales=LOCALES install only LOCALES [default=all]
15
--modules=MODULES pre-load specified modules MODULES
16
--themes=THEMES install THEMES [default=starfield]
17
-v, --verbose print verbose messages.
18
--allow-floppy make the drive also bootable as floppy (default
19
for fdX devices). May break on some BIOSes.
20
--boot-directory=DIR install GRUB images under the directory DIR/grub2
21
instead of the boot/grub2 directory
22
--bootloader-id=ID the ID of bootloader. This option is only
23
available on EFI and Macs.
24
--core-compress=xz|none|auto
25
choose the compression to use for core image
26
--disk-module=MODULE disk module to use (biosdisk or native). This
27
option is only available on BIOS target.
28
--efi-directory=DIR use DIR as the EFI System Partition root.
29
--force install even if problems are detected
30
--force-file-id use identifier file even if UUID is available
31
--label-bgcolor=COLOR use COLOR for label background
32
--label-color=COLOR use COLOR for label
33
--label-font=FILE use FILE as font for label
34
--macppc-directory=DIR use DIR for PPC MAC install.
35
--no-bootsector do not install bootsector
36
--no-nvram don't update the `boot-device'/`Boot*' NVRAM
37
variables. This option is only available on EFI
38
and IEEE1275 targets.
39
--no-rs-codes Do not apply any reed-solomon codes when
40
embedding core.img. This option is only available
41
on x86 BIOS targets.
42
--product-version=STRING use STRING as product version
43
--recheck delete device map if it already exists
44
--removable the installation device is removable. This option
45
is only available on EFI.
46
-s, --skip-fs-probe do not probe for filesystems in DEVICE
47
--target=TARGET install GRUB for TARGET platform
48
[default=i386-pc]; available targets: arm-efi,
49
arm-uboot, arm64-efi, i386-coreboot, i386-efi,
50
i386-ieee1275, i386-multiboot, i386-pc,
51
i386-qemu, i386-xen, ia64-efi, mips-arc,
52
mips-qemu_mips, mipsel-arc, mipsel-loongson,
53
mipsel-qemu_mips, powerpc-ieee1275,
54
sparc64-ieee1275, x86_64-efi, x86_64-xen
55
-?, --help give this help list
56
--usage give a short usage message
57
-V, --version print program version
58
59
Mandatory or optional arguments to long options are also mandatory or optional
60
for any corresponding short options.
61
62
INSTALL_DEVICE must be system device filename.
63
grub2-install copies GRUB images into boot/grub2. On some platforms, it may
64
also install GRUB into the boot sector.
65
66
Report bugs to <[email protected]>.
Copied!
as an example grub2-install /dev/sdb will install grub on sdb device, to the master boot record of my hard disk.
How ever instaling GRUB a from running system seems cool, but most of the time there is a problem during boot process and we can not get into our system any more, so we need to reinstall GRUB from GRUB shell. Unfortunately the setup command has been removed from GRUB2 shell and it would need more efforts. We need to bring up the system in rescue mode using a live cd and then install GRUB on our hard disk using current temporary root system file:
it is just an example and do not run it because you would mess up your current system!
grub2-install --boot-directory=/tmp/root/boot /dev/sda
.
.
.
Sources:
.
Last modified 1yr ago