linux启动内存设置

来源:互联网 发布:营销网络地图制作 编辑:程序博客网 时间:2024/05/07 17:14

因为测IO性能,需要将启动内存设置为小于实际物理内存的值。我们的服务器当前的物理内存是60g(可通过cat /proc/meminfo查看),计划设置为40g。网上找了下修改方法,各种描述,最终在stackoverflow上看到一个类似的运用,经过验证有效,记录如下,免得同行走弯路。

以下是/boot/grub/grub.conf文件:

 10 default=0
     11 timeout=5
     12 splashimage=(hd0,1)/boot/grub/splash.xpm.gz
     13 #hiddenmenu
     14 title Red Hat Enterprise Linux AS (2.6.32_1-13-0-0rc1)
     15         root (hd0,1)
     16         kernel /boot/vmlinuz-2.6.32_1-13-0-0rc1 ro root=/dev/cciss/c0d0p2 crashkernel=auto 
     17         initrd /boot/initrd-2.6.32_1-13-0-0rc1.img
     18 title Red Hat Enterprise Linux AS (2.6.32_schedoff)
     19         root (hd0,1)
     20         kernel /boot/vmlinuz-2.6.32_schedoff ro root=/dev/cciss/c0d0p2 crashkernel=auto
     21         initrd /boot/initrd-2.6.32_schedoff.img
     22 title Red Hat Enterprise Linux AS (2.6.32_2-2-0-4_pagecache)
     23         root (hd0,1)
     24         kernel /boot/vmlinuz-2.6.32_2-2-0-4_pagecache ro root=/dev/cciss/c0d0p2 crashkernel=auto
     25         initrd /boot/initrd-2.6.32_2-2-0-4_pagecache.img

显然有多种内核可选,由于我们只打算验证自己的内核2.6.32_1-13-0-0rc1,因此修改16行为

kernel /boot/vmlinuz-2.6.32_1-13-0-0rc1 ro root=/dev/cciss/c0d0p2 crashkernel=auto mem=40g

注意事项:

1、g/m均有效,mem=40000m也可,网上只有用m,估摸着应该用g也行,验证有效;

2、如果mem=40g放在initrd /boot/initrd-2.6.32_1-13-0-0rc1.img后无效;

3、不要搞错内核,如果当前的启动内核不对,也不会生效;

0 0