<SOLVED> Putting /tmp on tmpfs

Message
Author
philotux
Posts: 280
Joined: Sun Apr 22, 2018 12:57 pm

<SOLVED> Putting /tmp on tmpfs

#1 Post by philotux »

I just came across the following blogpost at https://blog.ubuntu.com/2016/01/20/data ... p-on-tmpfs
I quote:
Put /tmp on tmpfs and you’ll improve your Linux system’s I/O, reduce your carbon foot print and electricity usage, stretch the battery life of your laptop, extend the longevity of your SSDs, and provide stronger security.
And the method proposed for doing this:

Code: Select all

echo "tmpfs /tmp tmpfs rw,nosuid,nodev" | sudo tee -a /etc/fstab
sudo reboot
My question is if I should go ahead and apply this? Is there anything I should consider like any downsides of mounting the /tmp in the memory (if that is what happens if I have understood it correctly)? Can this method be used for other directories to be put on tmpfs with the gains mentioned in the quote above and in that case for which ones is it safe to do that?

Thanks in advance for your comments!
Last edited by philotux on Tue Jan 22, 2019 11:09 am, edited 1 time in total.

User avatar
dolphin_oracle
Developer
Posts: 20012
Joined: Sun Dec 16, 2007 1:17 pm

Re: Putting /tmp on tmpfs

#2 Post by dolphin_oracle »

just make sure /tmp is a directory and not a symlink first. if its a symlink, then just remove the symlink, make a directory with 1777 permissions, and then do your fstab modification and then reboot.

I can't think of a downside, other than the potential memory usage, which is likely to be small.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.

philotux
Posts: 280
Joined: Sun Apr 22, 2018 12:57 pm

Re: Putting /tmp on tmpfs

#3 Post by philotux »

dolphin_oracle wrote: Tue Jan 22, 2019 10:25 am just make sure /tmp is a directory and not a symlink first. if its a symlink, then just remove the symlink, make a directory with 1777 permissions, and then do your fstab modification and then reboot.
It looks like it is a symlink. So after removing the symlink, is it this:

Code: Select all

sudo mkdir /tmp
sudo chmod 1777 /tmp
what i need to do?

User avatar
dolphin_oracle
Developer
Posts: 20012
Joined: Sun Dec 16, 2007 1:17 pm

Re: Putting /tmp on tmpfs

#4 Post by dolphin_oracle »

now you can do your fstab stuff for the tmpfs and reboot.

just don't do too much else until you reboot, because anything you have running that is looking for a file in /tmp won't be able to find it anymore.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.

philotux
Posts: 280
Joined: Sun Apr 22, 2018 12:57 pm

Re: Putting /tmp on tmpfs

#5 Post by philotux »

Alright. Will do. Thanks d_o!

philotux
Posts: 280
Joined: Sun Apr 22, 2018 12:57 pm

Re: Putting /tmp on tmpfs

#6 Post by philotux »

Going to reboot now. Will come back in a short while with the report.

philotux
Posts: 280
Joined: Sun Apr 22, 2018 12:57 pm

Re: Putting /tmp on tmpfs

#7 Post by philotux »

System booted just fine. Do I need to run some check to make sure everything is alright?
Are there other stuff that are safe to put on tmpfs?

User avatar
dolphin_oracle
Developer
Posts: 20012
Joined: Sun Dec 16, 2007 1:17 pm

Re: Putting /tmp on tmpfs

#8 Post by dolphin_oracle »

philotux wrote: Tue Jan 22, 2019 10:43 am System booted just fine. Do I need to run some check to make sure everything is alright?
Are there other stuff that is safe to put on tmpfs?
I can't tell you about what's safe and what's not. I can tell you not to put /var/tmp on a tmpfs because that directory is expected to survive reboots and a tmpfs won't since its in memory.

you can look at the output of "df" to see all mounts, including your tmpfs mounts.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.

philotux
Posts: 280
Joined: Sun Apr 22, 2018 12:57 pm

Re: Putting /tmp on tmpfs

#9 Post by philotux »

dolphin_oracle wrote: Tue Jan 22, 2019 10:48 am I can't tell you about what's safe and what's not. I can tell you not to put /var/tmp on a tmpfs because that directory is expected to survive reboots and a tmpfs won't since its in memory.

you can look at the output of "df" to see all mounts, including your tmpfs mounts.
Alright, I think I'll settle as it is. Here is the:

Code: Select all

df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           789M  1.3M  788M   1% /run
/dev/sda11       25G  9.8G   14G  42% /
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           1.6G     0  1.6G   0% /run/shm
/dev/sda12       15G  5.9G  8.1G  43% /home/philotux
/dev/sda13       62G   30G   33G  48% /media/Storage
tmpfs           512M  8.0K  512M   1% /tmp
cgroup           12K     0   12K   0% /sys/fs/cgroup
tmpfs           789M  4.0K  789M   1% /run/user/115
tmpfs           789M   28K  789M   1% /run/user/1000

Great help! Thanks d_o!

philotux
Posts: 280
Joined: Sun Apr 22, 2018 12:57 pm

Re: <SOLVED> Putting /tmp on tmpfs

#10 Post by philotux »

Is putting ~/.cache on tmpfs any good or bad idea?

Post Reply

Return to “General”