InfraPlatform

Linux grub2 change default kernel

IT오이시이 2017. 12. 10. 15:48
728x90

Linux grub2 change default kernel


GRUB 2 is a rewrite of GRUB

1. The configuration file is grub.cfg rather than menu.lst or grub.conf

2. grub.cfg is typically automatically generated by grub-mkconfig

3. Partition numbers in GRUB device names now start at 1, not 0

4. Many more file systems are supported, including but not limited to ext4, HFS+, and NTFS.

5. GRUB 2 can read files directly from LVM and RAID devices.

6. GRUB 2 has more reliable ways to find its own files and those of target kernels on multiple-disk systems, 



GRUB 2 configuration file

GRUB 2 reads its configuration from the /boot/grub2/grub.cfg file on traditional BIOS-based machines and from the /boot/efi/EFI/redhat/grub.cfgfile on UEFI machines. This file contains menu information.

The GRUB 2 configuration file, grub.cfg, is generated during installation, or by invoking the /usr/sbin/grub2-mkconfig utility

[/etc/default/grub]

 : grub2-mkconfig tool

[root@dev proc]# cat /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="crashkernel=auto rhgb quiet"

GRUB_DISABLE_RECOVERY="true"


Do not attempt to manually edit the boot menu because it is automatically created from files within the /boot/ 


Configuring GRUB 2

[root@cdr]# grubby --default-kernel /boot/vmlinuz-3.10.0-514.6.2.el7.x86_64

[root@cdr]# grubby --default-index

0


[root@cdr ]# ls -al /boot/vmlinuz-* -rwxr-xr-x. 1 root root 5156528 Feb 24 2017 /boot/vmlinuz-0-rescue-37f277e0207041d0bdf740809887b2bb -rwxr-xr-x. 1 root root 5392752 Feb 23 2017 /boot/vmlinuz-3.10.0-514.6.2.el7.x86_64 -rwxr-xr-x. 1 root root 6192432 Feb 20 2017 /boot/vmlinuz-4.10.0-1.el7.elrepo.x86_64

Changing the Default Boot Entry

[root@cdr]# grubby --set-default /boot/vmlinuz-4.10.0-1.el7.elrepo.x86_64

[root@cdr]# grubby --default-index

1

[root@cdr]# grubby --info=ALL

index=0 kernel=/boot/vmlinuz-3.10.0-514.6.2.el7.x86_64 args="ro crashkernel=auto rhgb quiet LANG=en_US.UTF-8" root=UUID=3022c111-bd96-410c-bef2-ab1aa5e1789b initrd=/boot/initramfs-3.10.0-514.6.2.el7.x86_64.img title=CentOS Linux (3.10.0-514.6.2.el7.x86_64) 7 (Core) index=1 kernel=/boot/vmlinuz-4.10.0-1.el7.elrepo.x86_64 args="ro crashkernel=auto rhgb quiet LANG=en_US.UTF-8" root=UUID=3022c111-bd96-410c-bef2-ab1aa5e1789b initrd=/boot/initramfs-4.10.0-1.el7.elrepo.x86_64.img title=CentOS Linux (4.10.0-1.el7.elrepo.x86_64) 7 (Core) index=2 kernel=/boot/vmlinuz-0-rescue-37f277e0207041d0bdf740809887b2bb args="ro crashkernel=auto rhgb quiet" root=UUID=3022c111-bd96-410c-bef2-ab1aa5e1789b initrd=/boot/initramfs-0-rescue-37f277e0207041d0bdf740809887b2bb.img title=CentOS Linux (0-rescue-37f277e0207041d0bdf740809887b2bb) 7 (Core) index=3 non linux entry1



Refence : 

1. http://www.gnu.org/software/grub/manual/grub/grub.html

2. https://wiki.centos.org/HowTos/Grub2


728x90
반응형