Page 1 of 1

Mount /tmp as tmpfs

Posted: Mon Dec 18, 2017 8:18 am
by dr-kart
:confused: couldn't find anything fresh on this over recent forum posts.
...looking at https://wiki.debian.org/SSDOptimization ... ia_RAMDISK

So does it make sense (if any) to add to fstab

Code: Select all

tmpfs /tmp tmpfs noatime,nosuid 0 0
and (or) do we get some unwanted side effects here? Since mx wiki/help keeps silence on this.
In general this is the question to find reasonable optimal way to boost RAM usage via fstab or /etc/default/tmpfs or else.
arch-ers have it by default afaik

Re: Mount /tmp as tmpfs

Posted: Sat Dec 22, 2018 12:52 am
by freefreeno
I also would like to know what MX says about this because like you I can find it all over the web but I haven't seen anything on MX forums about it. I do mine this way in arch but I am not for sure on here.
tmpfs /tmp tmpfs noexec,noatime 0 0
tmpfs /home/josh/.cache/google-chrome/Default tmpfs noexec,noatime 0 0

I have been doing it this way but if I am wrong or there is a better way let me know.

Re: Mount /tmp as tmpfs

Posted: Sat Dec 22, 2018 7:28 am
by dphn
You don't need it on MX. /tmp linked to /var/tmp and this loads to RAM. Good configuration on MX.

Re: Mount /tmp as tmpfs

Posted: Sat Dec 22, 2018 10:03 am
by oops
dphn wrote: Sat Dec 22, 2018 7:28 am You don't need it on MX. /tmp linked to /var/tmp and this loads to RAM. Good configuration on MX.
Yes , and to check:

Code: Select all

cat /proc/mounts | grep /tmp
#or
cat /proc/mounts | grep tmpfs

Re: Mount /tmp as tmpfs

Posted: Sat Dec 22, 2018 5:53 pm
by MAYBL8
Mine shows this but I don't know what any of it means:
Is my SSD ok with this?

Code: Select all

dcihon@mx:~/.conky$ cat /proc/mounts | grep tmpfs
udev /dev devtmpfs rw,nosuid,relatime,size=8158164k,nr_inodes=2039541,mode=755 0 0
tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=1636936k,mode=755 0 0
tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
tmpfs /run/shm tmpfs rw,nosuid,nodev,noexec,relatime,size=6629300k 0 0
cgroup /sys/fs/cgroup tmpfs rw,relatime,size=12k,mode=755 0 0
tmpfs /run/user/115 tmpfs rw,nosuid,nodev,relatime,size=1636932k,mode=700,uid=115,gid=126 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=1636932k,mode=700,uid=1000,gid=1000 0 0

Re: Mount /tmp as tmpfs

Posted: Sat Dec 22, 2018 6:17 pm
by fehlix
dcihon wrote: Sat Dec 22, 2018 5:53 pm Mine shows this but I don't know what any of it means:
Is my SSD ok with this?
This means that neither /tmp nor ( symlinked to) /var/tmp is mounted into shared memory RAM (aka tmpfs)
but instead resides on the disk. If /tmp ( symlinked to /var/tmp) is desired to have as shared memory tmpfs
( and probably for SSD recommended if enough RAM is available)
this line within /etc/fstab is required:

Code: Select all

tmpfs      /tmp           tmpfs   defaults,mode=1777 0  0
:puppy:
EDIT: Corrected to have /tmp as tmpfs, as clarfied by BitJam here

Re: Mount /tmp as tmpfs

Posted: Sat Dec 22, 2018 6:24 pm
by MAYBL8
Ok now it shows this:

Code: Select all

dcihon@mx:~/.conky$ cat /proc/mounts | grep tmpfs
udev /dev devtmpfs rw,nosuid,relatime,size=8158164k,nr_inodes=2039541,mode=755 0 0
tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=1636936k,mode=755 0 0
tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
tmpfs /run/shm tmpfs rw,nosuid,nodev,noexec,relatime,size=6629300k 0 0
tmpfs /var/tmp tmpfs rw,relatime 0 0
cgroup /sys/fs/cgroup tmpfs rw,relatime,size=12k,mode=755 0 0
tmpfs /run/user/115 tmpfs rw,nosuid,nodev,relatime,size=1636932k,mode=700,uid=115,gid=126 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=1636932k,mode=700,uid=1000,gid=1000 0 0

Re: Mount /tmp as tmpfs

Posted: Sat Dec 22, 2018 6:41 pm
by fehlix
dcihon wrote: Sat Dec 22, 2018 6:24 pm Ok now it shows this:

Code: Select all

dcihon@mx:~/.conky$ cat /proc/mounts | grep tmpfs
udev /dev devtmpfs rw,nosuid,relatime,size=8158164k,nr_inodes=2039541,mode=755 0 0
tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=1636936k,mode=755 0 0
tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
tmpfs /run/shm tmpfs rw,nosuid,nodev,noexec,relatime,size=6629300k 0 0
tmpfs /var/tmp tmpfs rw,relatime 0 0
cgroup /sys/fs/cgroup tmpfs rw,relatime,size=12k,mode=755 0 0
tmpfs /run/user/115 tmpfs rw,nosuid,nodev,relatime,size=1636932k,mode=700,uid=115,gid=126 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=1636932k,mode=700,uid=1000,gid=1000 0 0
nice , when you open /tmp in Thunar you see free space is related to your available ram.
I think default for tmpfs to have 50% RAM promised for tmpfs to be used, sure lot's of tweaking can be done here.
Only if enough RAM is available this is recommended - otherwise tmpfs would go swapped out into disk on swap-partition/file :eek:

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 1:49 am
by BitJam
dphn wrote: Sat Dec 22, 2018 7:28 am You don't need it on MX. /tmp linked to /var/tmp and this loads to RAM. Good configuration on MX.
This configuration does not follow the Linux Filesystem Hierarchy Standard. It is okay for /tmp to be tmpfs because there is no guarantee that files under /tmp will survive a reboot. But the whole point of having a separate /var/tmp is so that files put there can survive a reboot.

From the Filesystem Hierarchy Standard:
/var/tmp : Temporary files preserved between system reboots

The /var/tmp directory is made available for programs that require temporary files or directories that are preserved between system reboots. Therefore, data stored in /var/tmp is more persistent than data in /tmp.

Files and directories located in /var/tmp must not be deleted when the system is booted. Although data stored in /var/tmp is typically deleted in a site-specific manner, it is recommended that deletions occur at a less frequent interval than /tmp.

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 7:59 am
by fehlix
BitJam wrote: Sun Dec 23, 2018 1:49 am The /var/tmp directory is made available for programs that require temporary files or directories that are preserved between system reboots. Therefore, data stored in /var/tmp is more persistent than data in /tmp.
Thanks, for pointing that out.

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 8:45 am
by fehlix
BitJam wrote: Sun Dec 23, 2018 1:49 am It is okay for /tmp to be tmpfs because there is no guarantee that files under /tmp will survive a reboot.
The question remains, how can we follow the Linux Filesystem Hierarchy Standard, which states clearly:
Chapter: 3.18. /tmp : Temporary files wrote:Although data stored in /tmp may be deleted in a site-specific manner, it is recommended that files and directories located in /tmp be deleted whenever the system is booted.
As within the installed system we do have currently /tmp symlinked => /var/tmp and by this we do not follow the standard,
as we must not delete /var/tmp on reboot, and hence cannot clear /tmp on reboot.
Suggest to change our current default to have /tmp not symlinked to /var/tmp but keep it as separate /tmp folder.
And we make sure that the default deletion of files in /tmp are activated ( e.g. in /etc/default/rcS ).
If users than want to have /tmp put as tmpfs into shared memory we might add a commented line into /etc/fstab
something like:

Code: Select all

#uncomment to have /tmp as temporary filesystem that resides in memory 
#tmpfs      /tmp           tmpfs   defaults,mode=1777 0  0
which might help the user to easily put /tmp in RAM by just commenting out this /tmp line in /etc/fstab
:puppy:

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 9:04 am
by oops
@fehlix ...The question is especially: is this standard relevant?
For which features /var/tmp is very important to keep?
Otherwise there is no relevance to changing current behavior (IMHO).

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 9:11 am
by fehlix
oops wrote: Sun Dec 23, 2018 9:04 am @fehlix ...The question is especially: is this standard relevant?
For which features /var/tmp is very important to keep?
Otherwise there is no relevance to changing current behavior (IMHO).
Yes, the point is, as soon as you install a app/programm, which is programmed
according to the standard and requires to have it's var/tmp data available after reboot
to function properly, you might have an issue, as the app might not work properly.
So as @BitJam pointed out better stay with the standard to avoid issues later.
:puppy:

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 9:18 am
by oops
@fehlix
Yes but in an exhaustive way, for which programs (they must be probably very rare?)

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 9:24 am
by fehlix
oops wrote: Sun Dec 23, 2018 9:18 am @fehlix
Yes but exhaustively, for which programs (they must be very very rare?)
Good question .. you might find out (or not) when something is not behaving properly, and you start to debug :eek:

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 9:35 am
by anticapitalista
Running live does not symlink tmp to /var/tmp.
Only on installation does it do so.
The gui installer has these lines.

Code: Select all

if (exitStatus == QProcess::NormalExit) {
        updateStatus(tr("Fixing configuration"), 99);
        chmod("/mnt/antiX/var/tmp",01777);
        shell.run("cd /mnt/antiX && ln -s var/tmp tmp");
This must have been a decision by MEPIS.

antiX cli-installer also does not symlink tmp to var/tmp

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 9:47 am
by fehlix
anticapitalista wrote: Sun Dec 23, 2018 9:35 am Running live does not symlink tmp to /var/tmp.
Only on installation does it do so.
The gui installer has these lines.

Code: Select all

if (exitStatus == QProcess::NormalExit) {
        updateStatus(tr("Fixing configuration"), 99);
        chmod("/mnt/antiX/var/tmp",01777);
        shell.run("cd /mnt/antiX && ln -s var/tmp tmp");
This must have been a decision by MEPIS.

antiX cli-installer also does not symlink tmp to var/tmp
May I interpret your comment, as support of my proposal to keep /tmp not symlinked to /var/tmp in MX Linux, which I hope is the case :happy:
:puppy:

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 10:12 am
by anticapitalista
fehlix wrote: Sun Dec 23, 2018 9:47 am
anticapitalista wrote: Sun Dec 23, 2018 9:35 am Running live does not symlink tmp to /var/tmp.
Only on installation does it do so.
The gui installer has these lines.

Code: Select all

if (exitStatus == QProcess::NormalExit) {
        updateStatus(tr("Fixing configuration"), 99);
        chmod("/mnt/antiX/var/tmp",01777);
        shell.run("cd /mnt/antiX && ln -s var/tmp tmp");
This must have been a decision by MEPIS.

antiX cli-installer also does not symlink tmp to var/tmp
May I interpret your comment, as support of my proposal to keep /tmp not symlinked to /var/tmp in MX Linux, which I hope is the case :happy:
:puppy:
From MX-19 onwards, ok if the other devs have no objections.

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 10:15 am
by MAYBL8
Ok I have read all of your posts.
So I am confused.
Do I need tmpfs to be /var/tmp for my SSD to be set up correctly or does it not matter how this is set?
Sorry if I am taking this thread off topic.

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 10:25 am
by fehlix
dcihon wrote: Sun Dec 23, 2018 10:15 am So I am confused.
Sorry about this :bawling:
Here what I would do:
Reboot with LiveUSB MX18
Mount rootMX17 or rootMX18
Assuming now rootMX18 is mounted under /media/demo/rootMX18:

Edit as root fstab /media/demo/rootMX18/etc/fstab
within the mounted rootMX18 and add this line to fstab

Code: Select all

tmpfs      /tmp           tmpfs   defaults,mode=1777 0  0
NOTE: noatime option as we are dealing with SSD noatime not needed in tmpfs
Now remove the tmp->var/tmp symlink
i.e. remove /media/demo/rootMX18/tmp < this is a symlink to var/tmp

Create an empty folder ( as user root )
/media/demo/rootMX18/tmp
now reboot.
:puppy:
EDIT: noatime is not need in tmpfs -

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 10:40 am
by dphn
I'm interesting in an example for an app, who needs a regular standard /tmp to hold data. I personally prefer the MX configuration. On other systems I've taken this similiar with a fstab config.

Code: Select all

tmpfs /tmp tmpfs nosuid 0 0

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 11:01 am
by fehlix
dphn wrote: Sun Dec 23, 2018 10:40 am I'm interesting in an example for an app, who needs a regular standard /tmp to hold data. I personally prefer the MX configuration. On other systems I've taken this similiar with a fstab config.

Code: Select all

tmpfs /tmp tmpfs nosuid 0 0
No app should rely on having data kept /tmp, rather in /var/tmp.
In your example at least mode=1777 is missing, as it is needed for /tmp to work properly and option "defaults" might be sufficient to add also.

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 11:04 am
by MAYBL8
Ok did all of that.
I now have this:

Code: Select all

dcihon@mx:~/.conky$ cat /proc/mounts | grep tmpfs
udev /dev devtmpfs rw,nosuid,relatime,size=8158164k,nr_inodes=2039541,mode=755 0 0
tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=1636936k,mode=755 0 0
tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
tmpfs /run/shm tmpfs rw,nosuid,nodev,noexec,relatime,size=6629300k 0 0
tmpfs /tmp tmpfs rw,noatime 0 0
cgroup /sys/fs/cgroup tmpfs rw,relatime,size=12k,mode=755 0 0
tmpfs /run/user/115 tmpfs rw,nosuid,nodev,relatime,size=1636932k,mode=700,uid=115,gid=126 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=1636932k,mode=700,uid=1000,gid=1000 0 0

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 11:06 am
by MAYBL8
Oops I just saw the edit after I posted.
I will go take out the noatime

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 11:14 am
by dphn
fehlix wrote: Sun Dec 23, 2018 11:01 am
dphn wrote: Sun Dec 23, 2018 10:40 am I'm interesting in an example for an app, who needs a regular standard /tmp to hold data. I personally prefer the MX configuration. On other systems I've taken this similiar with a fstab config.

Code: Select all

tmpfs /tmp tmpfs nosuid 0 0
No app should rely on having data kept /tmp, rather in /var/tmp.
In your example at least mode=1777 is missing, as it is needed for /tmp to work properly and option "defaults" might be sufficient to add also.
yep. Thx fehlix.

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 11:18 am
by fehlix
dcihon wrote: Sun Dec 23, 2018 11:04 am Ok did all of that.
Some fine tuning can be acchieved if the default 50% of available RAM for /tmp need to be adjusted by explicitely adding a size-option like
size=1G or size=2G, depending on the vailable RAM.
Note: I have corrected and removed "noatime" as this is used for SSD-mounts but not needed for tmpfs-mounts.

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 11:23 am
by baldyeti
FWIW my mepis partition indeed had /tmp symlinked to /var/tmp; OTOH neither jessie nor stretch have any tmpfs filesystem mentioned in fstab.

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 2:24 pm
by BitJam
fehlix wrote: Sun Dec 23, 2018 11:18 amNote: I have corrected and removed "noatime" as this is used for SSD-mounts but not needed for tmpfs-mounts.
The Linux default of relatime is almost always preferably to the noatime option. Except for some extremely unusually circumstances, the difference in wear and performance will not be measurable when the default relatime is used instead of noatime. There is a lot of bad/incorrect advice about this floating around the internet. It's often given along with the terrible advice of using a non-journaling file system in order to increase performance and decrease wear.

Even back in 2013, Consumer SSDs were benchmarked (to death) and lasted for longer than they were rated. In addition, the endurance of SSDs has increased dramatically since those tests were done. Even with block erase and write-amplification, the tiny bit of extra writing done by relatime is not going to cause significant extra wear. In order to wear out the circa 2013 drives that were tested, the people at TechReport had to write to them continuously, often for over a year. A standard workload over 5 years is a tiny fraction of that; the increase due to journaling and/or relatime is a tiny fraction of that tiny fraction.

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 2:43 pm
by oops
https://refspecs.linuxfoundation.org/FH ... 05s15.html
5.15. /var/tmp : Temporary files preserved between system reboots
5.15.1. Purpose

The /var/tmp directory is made available for programs that require temporary files or directories that are preserved between system reboots. Therefore, data stored in /var/tmp is more persistent than data in /tmp.

Files and directories located in /var/tmp must not be deleted when the system is booted. Although data stored in /var/tmp is typically deleted in a site-specific manner, it is recommended that deletions occur at a less frequent interval than /tmp.
"... it is recommended that deletions occur at a less frequent interval than /tmp"
... So it is not very explicit and must also be deleted sometimes
(and I still do not know which programs need this functionality)

And:
https://www.tldp.org/LDP/sag/html/var-fs.html
/var/tmp
Temporary files that are large or that need to exist for a longer time than what is allowed for /tmp . (Although the system administrator might not allow very old files in /var/tmp either.)

Re: Mount /tmp as tmpfs

Posted: Sun Dec 23, 2018 3:59 pm
by fehlix
BitJam wrote: Sun Dec 23, 2018 2:24 pm
fehlix wrote: Sun Dec 23, 2018 11:18 amNote: I have corrected and removed "noatime" as this is used for SSD-mounts but not needed for tmpfs-mounts.
The Linux default of relatime is almost always preferably to the noatime option. Except for some extremely unusually circumstances, the difference in wear and performance will not be measurable when the default relatime is used instead of noatime. There is a lot of bad/incorrect advice about this floating around the internet. It's often given along with the terrible advice of using a non-journaling file system in order to increase performance and decrease wear.

Even back in 2013, Consumer SSDs were benchmarked (to death) and lasted for longer than they were rated. In addition, the endurance of SSDs has increased dramatically since those tests were done. Even with block erase and write-amplification, the tiny bit of extra writing done by relatime is not going to cause significant extra wear. In order to wear out the circa 2013 drives that were tested, the people at TechReport had to write to them continuously, often for over a year. A standard workload over 5 years is a tiny fraction of that; the increase due to journaling and/or relatime is a tiny fraction of that tiny fraction.
Thanks. Nearly convinced. An actual proof of this message would certainly help, to make a clear and prooven statement,
of our recommended usage of relatime for SSD mounts for all current SSD's - or at least for the one's we are sure about.
Alternatively, we would state this a clear message of MX/antiX recommandations verified/prooven by own expiriences.
:puppy:

Re: Mount /tmp as tmpfs

Posted: Mon Dec 24, 2018 3:43 pm
by BitJam
Thank you for your considered reply fehlix! I'm not sure how much more proof you need. In order to wear out those 2013 drives, they had to write to them nearly continuously for about a year, some much longer than that. The duty cycle of writes in normal use is vastly smaller that that. You could reinstall MX every day of the year and only do a small fraction of that writing. What's it take? Five minutes on a fast drive? Call it 5G. That's about .01% of the daily writes used during the torture test. Likewise, updating access time stamps once a day is much less writing than that even assuming every file is read from. The size of the data is much greater than the size of the metadata.

The SMART system tells you the total bytes written, at least on some SSDs. I suppose someone could try to do a measurement comparing the bytes written when noatime is used versus the bytes written when relatime is but I think you would have to measure for months to test this under normal operation and I imagine any difference might still be lost in the noise. Even if it increased the writing by 10% (which I doubt) this is literally a small fraction of a small fraction of the writes needed to kill a drive.

There is no question that using atime can hurt performance and probably longevity. The relatime option became the default back in 2007. Here is part of the story behind it: Once upon atime. So there was a time, over a decade ago when using noatime on flash drives made sense.

(Too Many) Notes
It is my opinion that the noatime suggestion and the suggestion for no journaling dates back to the very early days of usb flash sticks. This may have been before relatime was a viable option (or became the default). Years ago, I searched and searched for any hard data indicating these options increased usb stick longevity. I could not find any. I think part of it was people were pushing every button they could push. But I think the theories had some validity way back when if the very early flash sticks had no wear levelling. In that case, frequent writes to the same location (directory inodes and the journal area) could kill a stick before its time. Then, unfortunately, these suggestions got propagated and amplified over time by the internet echo chamber even as technology developed and they became less and less relevant.

Back around 2009, anticapitalista and I decided to focus a substantial part of our development effort on live-usb technology which led to the Most Extensive Live-usb on the Planet! Even back in 2009 it was clear to us that live-usbs were better than live-dvds and live-cds. It was also clear that the usb flash drive technology was going to improve drastically in the coming years leaving cds and dvds in the dust. This happened Running live on usb-3 is amazingly fast. With fast hardware I can install and boot a Frugal system with persistence in less than a minute. This long-term live-usb project is why I researched the "noatime" and "no journaling" claims years ago.

But those old rumors are hard to kill. That is one of the reasons why live-usb-maker always creates a journaling filesystem. Some people still cling to those old rumors which, even if they were applicable over a decade ago, are certainly not applicable now. If you go through the MX forums, you will see that most of the non-recoverable live-usb data loss was associated with using a non-journaling filesystem.

Re: Mount /tmp as tmpfs

Posted: Mon Dec 24, 2018 5:54 pm
by fehlix
BitJam wrote: Mon Dec 24, 2018 3:43 pm .. I'm not sure how much more proof you need.
.. But those old rumors are hard to kill.
This last sentence is I'm all about. And I'm so thankful you summarized all your clear thoughts in such consize manner. This is more than enough to have a well educated and well proven statement from with MX/antiX community and development team to go further.
fehlix