Shared memory

What is /dev/shm?

/dev/shm is basically Virtual shared memory that allows data to be shared between processes. "/dev/shm" is shown as a tmpfs. This is a file system that stores its data within virtual memory and not on your disks.


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

Changing Shared memory size

To change the size of share memory, you will need add an entry into the mount table "/etc/fstab" and then issue the "mount -o remount /dev/shm" command.

In the example below, I will change the size to 1GB. Currently the size is showing as 738M


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

Add entry into /etc/fstab:


tmpfs /dev/shm tmpfs defaults,size=1G,nodev,nosuid 0 0

Now issue the following command: mount -o remount /dev/shm


# mount -o remount /dev/shm

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

We can now see that the above size has been changed.

Note: If you amend the size without rebooting your system, it is strongly advised that any applications you have that are running are stopped as when the /dev/shm area is unmounted, any data within this area will be lost immediately.