Linux RAM Disk: Creating A Filesystem In RAM

www.la‮.iruttu‬com
Linux RAM Disk: Creating A Filesystem In RAM

To create a filesystem in RAM on a Linux system, you can use the tmpfs filesystem. tmpfs is a virtual filesystem that stores files in volatile memory (i.e., RAM).

  1. To create a tmpfs filesystem, use the mount command with the tmpfs filesystem type and the desired size:
mount -t tmpfs -o size=SIZE tmpfs MOUNT_POINT

Replace SIZE with the desired size of the tmpfs filesystem in bytes and MOUNT_POINT with the desired mount point (e.g., /mnt/ramdisk).

For example, to create a tmpfs filesystem of 1 GB in size and mount it at /mnt/ramdisk, you would run:

mount -t tmpfs -o size=1G tmpfs /mnt/ramdisk
  1. To make the tmpfs filesystem persistent across reboots, you can add an entry to the /etc/fstab file. For example, to mount the tmpfs filesystem at /mnt/ramdisk on boot, you would add the following line to the /etc/fstab file:
tmpfs /mnt/ramdisk tmpfs defaults,size=1G 0 0

This will mount the tmpfs filesystem at /mnt/ramdisk on boot with a size of 1 GB.

Created Time:2017-10-30 10:17:37  Author:lautturi