RamDisk的大小是被一个命令行选项控制的,这个选项会在系统启动时传给内核。由于RedHat9的默认bootloader是GRUB,我将用新的选项修改/etc/grub.conf,RamDisk大小的内核选项是:ramdisk_size=xxxxx ,xxxxx是指大小为1024-Byte的块的个数。下面要调整大小设置:/etc/grub.conf,将RamDisk配置为16MB:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/hda5
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.4.20-20.9)
root (hd0,0)
kernel /vmlinuz-2.4.20-20.9 ro root=LABEL=/ hdc=ide-scsi ramdisk_size=16000
initrd /initrd-2.4.20-20.9.img
将文件保存后,需要重启系统。重启后,通过查看dmesg的输出来确认修改已经生效:
dmesg | grep RAMDISK
将RamDisk格式化ram0::mke2fs -m 0 /dev/ram0
挂载RamDisk:mount /dev/ram0 /mnt/rd
查看挂载:mount | grep ram0
用tune2fs命令查看新RamDisk的详细信息
开机自动创建、挂载,在/etc/rc.local下创建如下脚本:
# Formats, mounts, and sets permissions on my 16MB ramdisk
/sbin/mke2fs -q -m 0 /dev/ram0
/bin/mount /dev/ram0 /mnt/rd
至此可以使用了,如果需要一睦其他用户或组访问,需要改相应权限就好
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)