How to change tmpfs partition size in Linux ( RHEL / CentOS 7 )

Written by - Deepak Prasad

Increase or Decrease tmpfs partition size in Linux

In my last article I gave an overview on tuned and steps to create a custom tuned profile as per your performance requirement. In this article I will share the steps to (increase/decrease) change tmpfs partitions size in Linux. With RHEL 7 the Linux kernel provides a number of different ways for userspace to communicate with it.

For many facilities there are system calls, others are hidden behind netlink interfaces, and even others are exposed via virtual file systems such as /proc or /sys. These file systems are programming interfaces, they are not actually backed by real, persistent storage. They simply use the file system interface of the kernel as interface to various unrelated mechanisms.

Now by default systemd assigns a certain part of your physical memory to these partitions as a threshold. But what if your requirement requires you to change tmpfs partition size?

For some of the tmpfs partitions, you can change the threshold size by using fstab. While for other partitions like (/run/user/) which are created runtime, you cannot use fstab to change tmpfs partition size for such runtime directories.

Below are the list of tmpfs partitions available in RHEL 7

Filesystem Size Used Avail Use% Mounted on
tmpfs      187G    0  187G   0% /dev/shm
tmpfs      187G  41M  187G   1%  /run
tmpfs      187G    0  187G   0% /sys/fs/cgroup
tmpfs       38G    0   38G   0% /run/user/1710
tmpfs       38G    0   38G   0% /run/user/0
You may notice that /etc/fstab does not contains entries for these tmpfs partitions but still df -h will show these partitions.


Change tmpfs partition size for /dev/shm

If an application is POSIX compliant or it uses GLIBC (2.2 and above) on a Red Hat Enterprise Linux system, it will usually use the /dev/shm for shared memory (shm_open, shm_unlink). /dev/shm is a temporary filesystem (tmpfs) which is mounted from /etc/fstab. Hence the standard options like "size" supported for tmpfs can be used to increase or decrease the size of tmpfs on /dev/shm (by default it is half of available system RAM).

For example, to set the size of /dev/shm to 2GiB, change the following line in /etc/fstab:


none     /dev/shm       tmpfs   defaults                0 0


none     /dev/shm       tmpfs   defaults,size=2G        0 0

For the changes to take effect immediately remount /dev/shm:

# mount -o remount /dev/shm
A mount -o remount to shrink a tmpfs will succeed if there are not any blocks or inodes allocated within the new limit of the smaller tmpfs size. It is not possible to predict or control this, however a remount simply will not work if it cannot be done. In that case, stop all processes using tmpfs, unmount it, and remount it using the new size.

Lastly validate the new size

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


Change tmpfs partition size for /run

/run is a filesystem which is used by applications the same way /var/run was used in previous versions of RHEL. Now /var/run is a symlink to /run filesystem. Previously early boot programs used to place runtime data in /dev under numerous hidden dot directories. The reason they used directories in /dev was because it was known to be available from very early time during machine boot process. Because /var/run was available very late during boot, as /var might reside on a separate file system, directory /run was implemented.


By default you may not find any /etc/fstab entry for /run, so you can add below line

none     /run          tmpfs       defaults,size=600M        0 0

For the changes to take effect immediately remount /run:

# mount -o remount /run

lastly validate the new size

# df -h /run
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           600M  9.6M  591M   2% /run


Change tmpfs partition size for /run/user/$UID

/run/user/$UID is a filesystem used by pam_systemd to store files used by running processes for that user. In previous releases these files were typically stored in /tmp as it was the only location specified by the FHS which is local, and writeable by all users. However using /tmp can causes issues because it is writeable by anyone and thus access control was challenging. Using /run/user/$UID fixes the issue because it is only accessible by the target user.

You cannot change tmpfs partition size for /run/user/$UID using /etc/fstab.

tmps partition size for /run/user/$UID is taken based on RuntimeDirectorySize value from /etc/systemd/logind.conf

# grep -i runtime /etc/systemd/logind.conf

By default the default threshold for these runtime directory is 10% of the total physical memory.

From the man page of logind.conf

      Sets the size limit on the $XDG_RUNTIME_DIR runtime directory for each user who logs in. Takes a size in bytes, optionally suffixed with the usual K, G, M, and T suffixes, to the base 1024 (IEC). Alternatively, a numerical percentage suffixed by "%" may be specified, which sets the size limit relative to the amount of physical RAM. Defaults to 10%. Note that this size is a safety limit only. As each runtime directory is a tmpfs file system, it will only consume as much memory as is needed.

Modify this variable to your required value, for example I have provided threshold of 100M

# grep -i runtime /etc/systemd/logind.conf

Next restart the systemd-logind service

A reboot of the node is required to activate the changes.


Change tmpfs partition size for /sys/fs/cgroup

/sys/fs/cgroup is an interface through which Control Groups can be accessed. By default there may or may not be /etc/fstab content for /sys/fs/cgroup so add a new entry

Current value for /sys/fs/cgroup

# df -h /sys/fs/cgroup
Filesystem      Size  Used Avail Use% Mounted on
tmpfs            63G     0   63G   0% /sys/fs/cgroup

Add below line in your /etc/fstab to change the threshold to 2GB

none          /sys/fs/cgroup          tmpfs       defaults,size=2G         0 0

Remount the partition /sys/fs/cgroup

# mount -o remount /sys/fs/cgroup

Lastly validate the updated changes

# df -h /sys/fs/cgroup
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup


Why are there many tmpfs filesystems mounted on the server?
What is the purpose of the /run/user/1000, tmpfs filesystem that appears in df?
How to work with /dev/shm in Red Hat Enterprise Linux 7
How do I modify the size of tmpfs?


Lastly I hope the steps from the article to change tmpfs partition size on Linux was helpful. So, let me know your suggestions and feedback using the comment section.


Views: 170

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can reach out to him on his LinkedIn profile or join on Facebook page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to

Thank You for your support!!

9 thoughts on “How to change tmpfs partition size in Linux ( RHEL / CentOS 7 )”

  1. Hi

    Thanks for the Article,

    If I suppose to have 125Gb of /dev/shm, do i need to add the additional diskspace?

    rootvg having 140GB- Rootvg50+swap90

    • /dev/shm by default is allotted 50% of the allotted RAM so if your system has 4Gb RAM then /dev/shm will have 2GB assigned. I don’t think it is related to filesystem size. The allotted /dev/shm size should not exceed the available RAM Memory as in such case system will start using swap memory which is considered more slower then actual RAM.

  2. Very nice work, but could you please show us how to reduce the size of devtempfs?.
    The output of df -h /dev shows devtempfs is mounted on /dev, now if you cat /etc/fstab there’s no information about devtempfs. So how can I reduce the size in /etc/fstab file?

    Thank you very much

    • There should be no impacts if you increase the size of /dev/shm runtime. Although decreasing may impact your application depending upon the usage

  3. Thank you!! This entry is succinct and informative, so much nicer than the rest of the results on changing tmpfs sizes in fstab! If you feel like it, it would be nice to know how to change an overlay root partition, but what you have is great!!


Leave a Comment