Resize tmpfs in Linux without unmounting
Today we see a quick solution to resize a resource formatted with tmpfs quickly, without rebooting or losing data. This is the case of complex server applications, but it's also my case. For a few months I have been using Solus as the operating system on the laptop to my great advantage since the laptop is not fast, not recent.
Solus has the peculiarity of mounting the directory /tmp
in a separate partition (inside the RAM) con filesystem tmpfs. This greatly speeds up writing such data to the system, but if the RAM is not sufficiently capable you risk getting the classic error “Out of disk space”.
$ df -h
File system Dim. Usati Dispon. Uso% Montato su
/dev/mapper/SolusSystem-Root 454G 259G 172G 61% /
devtmpfs 4,0M 0 4,0M 0% /dev
tmpfs 1,9G 0 1,9G 0% /dev/shm
tmpfs 776M 9,6M 766M 2% /run
tmpfs 1,9G 332K 1,9G 1% /tmp
/dev/sda1 449M 151M 269M 36% /boot
tmpfs 388M 2,7M 386M 1% /run/user/1000
That's what happened to me. The solution is very simple:
# mount -o remount,size=new_size /path/to/tmpfs
This solution preserves the data and if the size we are trying to set is larger than the space available in RAM the data will then be written to disk in the SWAP partition.
0 Comments