Page 1 of 1

/tmp mounted as tmpfs

Posted: 14 Jul 2021, 07:57
by rych
Hi, I have a lot of RAM, could I have /tmp folder mounted to be ramdisk, as either tmpfs or ramfs or whatnot?

My understanding is that for tmpfs I only specify the upper limit, and there is no minimum reserved space, so that my /tmp won't claim unnecessary fixed memory from the start (?)

Are there other system folders that don't really need to persistent and are better to live in memory and be wiped every reboot?

/tmp mounted as tmpfs

Posted: 14 Jul 2021, 08:53
by babam
Add to /etc/rc.d/rc.local

Code: Select all

    cp -af /tmp /var/tmp2tmpfs
    mount -t tmpfs -o size=60% tmpfs /tmp
    cp -af /var/tmp2tmpfs/. /tmp
    rm -rf /var/tmp2tmpfs

/tmp mounted as tmpfs

Posted: 14 Jul 2021, 09:32
by rych
babam, thanks. One question: as we about to mount -t tmpfs -o size=60% tmpfs /tmp, the /tmp is probably nonempty. Don't we want to make it empty first?

/tmp mounted as tmpfs

Posted: 14 Jul 2021, 09:44
by babam
You can delete unnecessary files/directories.

But there are files/directories that are created every time the system boot and those files are important.

/tmp mounted as tmpfs

Posted: 14 Jul 2021, 09:55
by rych
babam, So even if /tmp was empty to begin with, some files could be created already by the time /etc/rc.d/rc.local is processed? And those files will be mounted over and hidden, their copies brought on top the newly mounted /tmp? I'll probably try to comment out the rm -rf /var/tmp2tmpfs at least once to see what was there.

/tmp mounted as tmpfs

Posted: 14 Jul 2021, 15:47
by Ed_P
On my Porteus USB system the /tmp folder is in RAM and it's in RAM on the systems I boot as ISOs.

/tmp mounted as tmpfs

Posted: 28 Oct 2023, 15:16
by rych
babam wrote:
14 Jul 2021, 08:53
Add to /etc/rc.d/rc.local
Nowadays I save changes on exit only and can exclude /tmp folder from ever being saved as changes to USB (well, it's not even mentioned in /etc/changes-exit.conf therefore unsaved by default), so I guess the /tmp and all changed session data lives in memory anyway and I don't need to specifically make /tmp a separate ramdisk -- its already in memory anyway?

So I'm going to remove that section from my /etc/rc.d/rc.local, returning it to the original.

/tmp mounted as tmpfs

Posted: 03 Nov 2023, 06:16
by Rava
rych wrote:
28 Oct 2023, 15:16
I don't need to specifically make /tmp a separate ramdisk -- its already in memory anyway?

So I'm going to remove that section from my /etc/rc.d/rc.local, returning it to the original.
Yes, by standard /tmp might not be mounted as a tmpfs.

But it not needs to, since it is part of / and / is mounted into RAM since we have a live system:
Porteus 5.01 on a mere 4GB of RAM PC (using ramsize=10% zram=8%) :

Code: Select all

guest@rava:/$ df -Tm /tmp/
Filesystem     Type 1M-blocks  Used Available Use% Mounted on
aufs           aufs       388   276       112  72% /