Linux Ramdisks

So you want to make a ramdisk under linux... There are two ways, and they're both pretty simple.

You can use the /dev/ram0 through /dev/ram19 (or more I suppose) and create a simple ramkdisk. These are supported directly from the kernel and require the lease amount of work.

mkfs /dev/ram0 mount -t ext2 /dev/ram0 /mnt/ramdisk
The only problem with this is that you can't control the size. The kernel decides the size and it defaults to 4 megs. You can override it with a kernel parameter but that would require a reboot. Or you can use the loopback device which is slightly more complicated.

dd if=/dev/zero of=/tmp/ramdisk.bin bs=1024k count=10 mkfs /tmp/ramdisk mount -t ext2 /tmp/ramdisk.bin /mnt/ramdisk -o loop
Just change the count=10 to however big you want the ramdisk to be.

Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
Logged IP:
To prevent spam please submit by clicking the kitten: