基于BIOS或者UEFI 的Centos 7.4 如何修改内存大页

1、在修改前查看系统的内存大页参数

# grep Huge /proc/meminfo
HugePages_Total:      16
HugePages_Free:       16
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:    1048576 kB

从图中可以看到单个内存大页大小为1G,内存大页数量为16个;

2、通过修改内核命令行来修改内存大页

首先查看内核命令行

# cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-3.10.0-693.2.2.rt56.623.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap no_timer_check clocksource=tsc tsc=perfect intel_pstate=disable selinux=0 enforcing=0 nmi_watchdog=0 softlockup_panic=0 isolcpus=1-39 nohz_full=0-39 idle=poll default_hugepagesz=1G hugepagesz=1G hugepages=16 rcu_nocbs=1-39 kthread_cpus=0 irqaffinity=0 rcu_nocb_poll rhgb quiet

这是修改后的命令行,从中可以发现

default_hugepagesz=1G hugepagesz=1G hugepages=16

这是修改内存大页的参数;

3、查看并修改内核配置文件

#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 rd.lvm.lv=centos/root rd.lvm.lv=centos/swap no_timer_check clocksource=tsc tsc=perfect intel_pstate=disable selinux=0 enforcing=0 nmi_watchdog=0 softlockup_panic=0 isolcpus=1-39 nohz_full=0-39 idle=poll default_hugepagesz=1G hugepagesz=1G hugepages=16 rcu_nocbs=1-39 kthread_cpus=0 irqaffinity=0 rcu_nocb_poll rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

只需要修改 /etc/default/grub中的GRUB_CMDLINE_LINUX,在其中添加

default_hugepagesz=1G hugepagesz=1G hugepages=16 即可;

4、在修改后需要重新生成内核引导文件

对于/etc/default/grub进行编辑之后,需要产生grun.cfg;

对于BIOS-based 系统

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

对于 UEFI-based system

grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

5、在生成新的配置文件之后需要重启

systemctl reboot

6、最后验证内核命令行是否修改成功、以及内存大页是否修改成功

# cat /proc/cmdline 
BOOT_IMAGE=/vmlinuz-3.10.0-693.2.2.rt56.623.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap no_timer_check clocksource=tsc tsc=perfect intel_pstate=disable selinux=0 enforcing=0 nmi_watchdog=0 softlockup_panic=0 isolcpus=1-39 nohz_full=0-39 idle=poll default_hugepagesz=1G hugepagesz=1G hugepages=16 rcu_nocbs=1-39 kthread_cpus=0 irqaffinity=0 rcu_nocb_poll rhgb quiet
# grep Huge /proc/meminfo
HugePages_Total:      16
HugePages_Free:       16
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:    1048576 kB

需要特别注意的是BIOS和UEFI需要对应着不同的配置文件

你可能感兴趣的:(LInux系统基本功能安装,Centos,内存大页,UEFI)