Boost your Linux system 30x times faster, by mounting /dev/shm to /tmp

I’m sharing the tip for the linux system that will make your linux desktop much faster,

by manipulating the /dev/shm system then mount it to /tmp

/dev/shm is nothing but an implementation of the traditional shared memory concept. It is an efficient means of passing data between programs. One program will create a memory portion, which other processes (if permitted) can access. This will result in speeding up things on Linux.

SSD vs. RAM Speed

RAM is orders of magnitude faster than an SSD. An SSD’s theoretical maximum transfer speed is that of the SATA interface — 6Gbps, which is equivalent to 750MB/sec. A relatively fast SSD may achieve real-world write speeds of 456MB/sec, though. The theoretical maximum speed of RAM is in its PC number, so a module of PC3-12800 memory can transfer 12,800MB/sec–roughly 30 times faster than the real-world performance of an SSD. Directly substituting an SSD for RAM would end up significantly slowing down your system.

First of all, we are going to append the line to the /etc/fstab as below
(since my rig has 96GB RAM, I’m assigning 10GB for the /dev/shm even though it will hardly reach 1GB usage, since most of the time my ram is just seating there doing nothing)

tmpfs /dev/shm tmpfs defaults,size=10240M 0 0

tmpfs is a temporary filesystem that resides in memory and/or swap partition(s). Mounting directories as tmpfs can be an effective way of speeding up accesses to their files, or to ensure that their contents are automatically cleared upon reboot.

and now we are going to mount /dev/shm to /tmp so Linux system will mostly process everything with the physical ram,

append the following line to /etc/fstab underneath the line we just appended above.
also make the symlink /tmp to /var/tmp

/dev/shm /tmp none bind,umask=1777,nofail 0 0
/tmp /var/tmp none bind

so right after /dev/shm gets 10GB ram out of my system, it will immediately mount /dev/shm to /tmp, the permission 1777 is a must for the /tmp in Linux system, ‘nofail’ won’t halt boot process when something goes wrong with your /dev/shm while booting up.

Now try to reboot the system.
You would notice the boot-up speed is reduced, and whatever you do is almost instant response.

In Unix and Linux, the global temporary directories are /tmp and /var/tmp. Web browsers periodically write data to the tmp directory during page views and downloads. Typically, /var/tmp is for persistent files (as it may be preserved over reboots), and /tmp is for more temporary files. See Filesystem Hierarchy Standard. In addition, a user can set their TMPDIR environment variable to point to a preferred directory (where the creation and modification of files are allowed).

so I’m going to delete the /var/tmp

: sudo mv /var/tmp/* /tmp/*
: sudo rm /var/tmp -rf

That’s all, enjoy your system.

Leave a Comment