Walker News

How To Resize /dev/shm Filesystem In Linux?

By default installation, RHEL and most Linux distributions mount tmpfs (a RAM-based temporarily filesystem) to /dev/shm directory and this temporarily filesystem size is always set to be half of the installed memory.

If that default size is not something expected, you can increase or reduce the /dev/shm filesystem size at wish.

To be even extreme, you may drop or disable this temporarily RAM-based filesystem entirely, to prevent it from auto-mount during system boots up, if none of the application in that Linux server relying on shared memory function or explicitly using tmpfs (as a quick-and-dirty trick to improve execution performance).

To increase or decrease /dev/shm filesystem size

1) Open /etc/fstab with vi or any text editor of your choice,

2) Locate the line of /dev/shm and use the tmpfs size option to specify your expected size,

e.g. 512MB:
tmpfs      /dev/shm      tmpfs   defaults,size=512m   0   0

e.g. 2GB:
tmpfs      /dev/shm      tmpfs   defaults,size=2g   0   0

The /etc/fstab content format is documented in man fstab and the tmpfs filesystem options can be found in man mount

3) To make change effective immediately, run this mount command to remount the /dev/shm filesystem:
mount -o remount /dev/shm

To disable the /dev/shm or tmpfs filesystem
Actually, Linux allocates the memory for this tmpfs on demand basis, up to the maximum size that shown in df -h command output. If none of the application is using the /dev/shm, this tmpfs in fact does not consume any memory space. So, why have to disable it?

To disable /dev/shm immediately once only (but enable it on subsequent reboots), just execute the umount command:
umount /dev/shm

To prevent tmpfs from auto-mount each time the Linux boots up, just remark or delete that line from /etc/fstab.

Custom Search

  1. Oly 26-03-17@21:42


  2. Todd (oracle dba) 22-10-17@01:56

    I’m in the middle of a GRID install for a 2-node RAC environment and OUI kept giving me an error on /dev/shm being size 0. It was actually 12g and empty. This is on RHEL 6.9 using VM’s. Once I added ‘size=12g’ in /etc/fstab the installer had no issues. This took quite a bit of time to resolve and luckily I found your site. Good job and thanks!

2018  •  Privacy Policy