Monday, April 11, 2011

RAMDISK in Linux

Step 1: Take a look at what has already been created by your system

ls -l /dev/ram*
dmesg | grep RAMDISK

Step 2: Increase ramdisk size

in the /etc/grub.conf add this
kernel /vmlinuz-2.4.20-20.9 ro root=LABEL=/ hdc=ide-scsi ramdisk_size=16000 { 16 mb- u can specify as per u r need}

After this restart the system

dmesg | grep RAMDISK
RAMDISK driver initialized: 16 RAM disks of 16000K size 1024 blocksize {output}

Step 3: Format the ramdisk
mke2fs -m 0 /dev/ram0


Step 4: Create a mount point and mount the ramdisk

mkdir /mnt/rd
mount /dev/ram0 /mnt/rd

verify the new ramdisk mount:
mount | grep ram0
df -h | grep ram0

You can even take a detailed look at the new ramdisk with the tune2fs command:

tune2fs -l /dev/ram0


Automating Ramdisk Creation

If you need to create and mount a ramdisk every time your system boots, you can
automate the process by adding some commands to your /etc/rc.local init script. Here are the lines that I added:

/sbin/mke2fs -q -m 0 /dev/ram0
/bin/mount /dev/ram0 /mnt/rd

No comments: