RAM disks

Sometimes it is desirable to have a ram disk for reasons as:

More feature, more simple and more modern is using mount -t tmpfs -o size=256M tmpfs /mnt/tmpfs.

cat /etc/mtab | grep tmpfs shows already available ram disk space.

To create a ram disk the "old-way" check if it is already available ls -l /dev/ram*

and if it is already mounted: cat /etc/mtab | grep ram

If no /dev/ram* device files exist, check the kernel:

If necessary modify it to have something as:

CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=16
CONFIG_BLK_DEV_RAM_SIZE=4096

Then format it mke2fs -m 0 /dev/ram0

Create a mounting point and mount it: mount /dev/ram0 /mnt/ram

Recheck that it is mounted: cat /etc/mtab | grep ram

Check the disk size df -T | grep ram

cat /usr/src/linux/.config | grep DEV_RAM

The size can be reconfigured without recompiling the kernel by passing a parameter to the kernel at boot time. Using grub, add something as the following to get 16MByte

kernel /kernel-3.<version>-gentoo-r<release> ramdisk_size=16000

df -h | grep /dev/ram and lsblk shows the status


Linurs startpage