How to resize tmpfs without losing data

Linux

Definition from Wikipedia: tmpfs is a temporary file storage paradigm implemented in many Unix-like operating systems. It is intended to appear as a mounted file system, but data is stored in volatile memory instead of a persistent storage device. A similar construction is a RAM disk, which appears as a virtual disk drive and hosts a disk file system.

To resize tmpfs without lose any data, remount it instead of umount tmpfs and mount it again. Increase and decrease the size also possible.

The syntax:

mount -o remount,size=new_size /path/to/tmpfs

Real life examples:

mount -o remount,size=500M /tmp

mount -o remount,size=2G /var/log

If you have more data on tmpfs than you are trying to set a limit to, an error message appear:

mount point not mounted or bad option.

 

Get free $100 credit on DigitalOcean if you Sign Up through this link. Great possibility to try VPS (Virtual Personal Server) technology for free.

This article was updated on April 16, 2021

Feriman

Automation, Optimization, Linux, IT things and do better everything day by day.

Comments