How to resize tmpfs in Linux

How to adjust available space in tmpfs without unmouting

George Shuklin
OpsOps
1 min readJan 7, 2019

--

A simple question with a simple answer (but not that easily googlable). I wouldn’t write this article if only I hadn’t spend about 15 minutes searching for the answer.

The problem: resize tmpfs without loosing data

When one use live image (with augfs, backed by both squashfs and tmpfs), there is a big desire to have a way to adjust how much memory server uses based on later stages of the server life. There is no way to unmount root (‘/’) on booted server, so I need to find a way to adjust amount of available space on tmpfs-based root partition without unmounting it.

The solution: remount

The answer is simple: remount.

F.e.

This operation preserves data. If it’s not possible (f.e. you have more data on tmpfs than you are trying to set limit to), an error will raise:

--

--

George Shuklin
OpsOps

I work at Servers.com, most of my stories are about Ansible, Ceph, Python, Openstack and Linux. My hobby is Rust.