Linux : How to create Ramdisk

By | November 23, 2010

Here is a procedure to create ramdisk on Linux.

1. Look for ramdisk devices :

ls -la /dev/ram*

2. Increase size by adding the kernel parameter in the grub config file

(this example assume you want a 512 Mb ramdisk) :

ramdisk_size=512000

3. Format the ramdisk :

mke2fs -m 0 /dev/ram0

4. Mount the ramdisk :

mkdir /mnt/ramdisk
mount /dev/ram0 /mnt/ramdisk

 

5. Umount the ramdisk :

umount -v /mnt/ramdisk

6. Automated ramdisk creation (add to init) :

/sbin/mke2fs -q -m 0 /dev/ram0
/bin/mount /dev/ram0 /mnt/ramdisk
/bin/chown root:root /mnt/ramdisk
/bin/chmod 0750 /mnt/ramdisk