How to resize tmpfs without losing data

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. Increasing and decreasing the size is 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. Click here



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