How to Create a tmpfs Filesystem in CentOS/RHEL

tmpfs are not really used as filesystems, but just take advantage of the filesystem abstraction. Applications can do I/O on a tmpfs. tmpfs functions reside purely in memory.

Creating a tmpfs special filesystem

1. Mount a new instance of tmpfs:

# mkdir /mnt/tmpfs
# mount -t tmpfs none /mnt/tmpfs

Note: Check how much space the filesystem has been given and how much it is using.

# df -h /mnt/tmpfs
Filesystem Size Used Avail Use% Mounted on
none         915M 0    915M 0%    /mnt/tmpfs

2. Once the filesystem is not more needed, unmount the filesystem

# umount /mnt/tmpfs

Conclusion

Virtually, modern Linux distributions mount an instance of tmpfs at /dev/shm.

# df -h /dev/shm
Filesystem Size Used Avail Use% Mounted on
tmpfs 915M 0 915M 0% /dev/shm

To check which instaces of tmpfs is using the system by default:

# df -h | grep tmpfs
devtmpfs 901M 0 901M 0% /dev
tmpfs 915M 0 915M 0% /dev/shm
tmpfs 915M 9.6M 906M 2% /run
tmpfs 915M 0 915M 0% /sys/fs/cgroup
tmpfs 183M 28K 183M 1% /run/user/42
tmpfs 183M 3.5M 180M 2% /run/user/1000
tmpfs 183M 4.0K 183M 1% /run/user/0
Related Post