BLS是linux内核社区推出的一套标准化引导加载器配置规范,旨在统一不同linux发行版本的启动配置管理方式
在之前各个发型版本的grub文件夹都不尽相同,并且由脚本生成,管理复杂;每次更新配置文件,需要手动执行grub-mkconfig;支持加密启动配置
配置文件位于/boot/loader/entries/,每个conf都是一个模式,在系统启动时进行加载
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| ls /boot/loader/entries/ 87db439bcd174376b872d2e732b67d0c-0-rescue.conf 87db439bcd174376b872d2e732b67d0c-5.14.0-503.33.1.el9_5.x86_64.conf 87db439bcd174376b872d2e732b67d0c-5.14.0-503.35.1.el9_5.x86_64.conf 87db439bcd174376b872d2e732b67d0c-5.14.0-503.38.1.el9_5.x86_64+debug.conf 87db439bcd174376b872d2e732b67d0c-5.14.0-570.49.1.el9_6.x86_64+debug.conf 87db439bcd174376b872d2e732b67d0c-5.14.0-570.49.1.el9_6.x86_64.conf
5.14.0-570.49.1.el9_6.x86_64.conf ← 最新稳定内核(默认启动) 5.14.0-570.49.1.el9_6.x86_64+debug.conf ← 调试版本(特殊用途) 5.14.0-503.38.1.el9_5.x86_64+debug.conf ← 旧调试版本(保留) 5.14.0-503.35.1.el9_5.x86_64.conf ← 旧稳定版本(保留) 5.14.0-503.33.1.el9_5.x86_64.conf ← 更旧版本(可能即将删除) 0-rescue.conf ← 救援内核(故障恢复)
系统会加载最新内核版本作为默认启动项 0-rescue.conf 是固定的救援模式配置
cat 87db439bcd174376b872d2e732b67d0c-5.14.0-570.49.1.el9_6.x86_64.conf title AlmaLinux (5.14.0-570.49.1.el9_6.x86_64) 9.6 (Sage Margay) version 5.14.0-570.49.1.el9_6.x86_64 linux /vmlinuz-5.14.0-570.49.1.el9_6.x86_64 initrd /initramfs-5.14.0-570.49.1.el9_6.x86_64.img $tuned_initrd options root=/dev/mapper/almalinux_192-root ro crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/almalinux_192-swap rd.lvm.lv=almalinux_192/root rd.lvm.lv=almalinux_192/swap $tuned_params grub_users $grub_users grub_arg --unrestricted grub_class almalinux
title:启动菜单显示的名称 version:内核版本号 linux:指定内核镜像,包含操作系统核心 initrd:临时根文件系统,提供硬件驱动和工具 初始ramdisk的路径 root:真正的根文件系统位置 ro:启动时只读挂载 console:内核输出目的地
|
可以通过修改配置文件的方式来添加参数,不赘述了
通过修改默认配置来添加参数的方式
1 2 3 4 5 6 7 8
| grubby --info=ALL
grubby --update-kernel=ALL --args="hugepagesz=2M hugepages=1024 default_hugepagesz=2M"
grubby --update-kernel=/boot/vmlinuz-4.18.0-348.el8.x86_64 --args="hugepagesz=2M hugepages=1024"
|
临时修改
在grub菜单选择启动项时,按e编辑,添加或修改options行
可添加的参数
- 硬件性能调优参数
- 调试和故障排查参数
- 安全相关参数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| isolcpus=1,3,5-7 nohz_full=1,3,5-7 rcu_nocbs=1,3,5-7 processor.max_cstate=1 intel_pstate=disable
options isolcpus=2-4 nohz_full=2-4 rcu_nocbs=2-4
transparent_hugepage=never transparent_hugepage=madvise numa=on numa_balancing=disable mem=8G vm.swappiness=10
options transparent_hugepage=never numa=on
elevator=noop elevator=deadline elevator=cfq pci=assign-busses pci=realloc
options elevator=noop pci=realloc
selinux=0 enforcing=0 audit=0 ipv6.disable=1
debug ignore_loglevel earlyprintk=serial,ttyS0,115200 systemd.log_level=debug
quiet splash nomodeset acpi=off noapic
title Database Optimized Kernel version 4.18.0-348.el8.x86_64 linux /vmlinuz-4.18.0-348.el8.x86_64 initrd /initramfs-4.18.0-348.el8.x86_64.img options root=/dev/mapper/rhel-root ro options hugepagesz=1G hugepages=16 options default_hugepagesz=1G options transparent_hugepage=never options isolcpus=2-7 options elevator=deadline
|