tmpfiles Question 08 January 2025, 19:56:49 Hello, looks like I cannot make the system clean /tmp contents on shutdown/reboot (or I'm doing something wrong).I've copied the file /usr/lib/tmpfiles.d/tmp.conf into /etc/tmpfiles.d and changed its contents to:Code: [Select]D! /tmp 1777 root root 0D! /var/tmp 1777 root root 0Now these dirs should be cleaned. But they are not...Any ideas?
Re: tmpfiles Question Reply #1 – 09 January 2025, 02:34:33 Do you have tmpfs mounted in /etc/fstab ? Something like this should do it, the exact mount options might vary according to what guides you follow and the intended security level:Code: [Select]tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0https://wiki.archlinux.org/title/Tmpfs
Re: tmpfiles Question Reply #2 – 09 January 2025, 08:58:01 Quote from: ####### – on 09 January 2025, 02:34:33Do you have tmpfs mounted in /etc/fstab ?No. Do I have to?
Re: tmpfiles Question Reply #3 – 09 January 2025, 09:01:07 No, unless you want to remove /tmp contents on shutdown/reboot.
Re: tmpfiles Question Reply #4 – 09 January 2025, 09:13:32 Quote from: Everyone – on 09 January 2025, 09:01:07No, unless you want to remove /tmp contents on shutdown/reboot.I understand that. Do I have to keep the new tmp.conf? Won't the system clean /tmp without this config?
Re: tmpfiles Question Reply #5 – 09 January 2025, 15:17:02 tmpfs is a RAM based virtual drive, it is used for /tmp because it is both inherently temporary, not surviving a reboot, and faster and more efficient than writing temporary files to your hard drive. It also saves wear and tear to your hard drive. Before this system was commonly deployed in Linux, going back to the 32 bit era when RAM was often in short supply, there was a system to delete the contents of /tmp during boot. You can research on how to resurrect this older method of managing /tmp if you want, but for a modern setup, adjust your /etc/fstab and afterwards run:Code: [Select]# mkinitcpio -P There is usually very little in terms of file size that goes in /tmp so it isn't a big drain on RAM. The only common snag is if you use an AUR helper that builds in /tmp by default to make use of faster write times, a big build like the kernel or something will usually fail due to lack of space and RAM, so for large packages you need to specify it builds somewhere else in a regular directory backed by the hard drive. Unless you have vast quantities of RAM, of course. 2 Likes
Re: tmpfiles Question Reply #6 – 09 January 2025, 16:35:54 https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txttmpfs can swap to disk if full, right? So small size not a big deal?
Re: tmpfiles Question Reply #7 – 09 January 2025, 16:58:25 Quote from: n00b – on 09 January 2025, 16:35:54tmpfs can swap to disk if full, right? So small size not a big deal?No. if something is using /tmp (as tmpfs) and it's gets full things break/crash.However I think, but am not sure, that if you set tmpfs to be bigger than your installed ram then it might swap some out to disk if it actually exceeds the installed ram size ? I'm not sure if I've read that or if I am guessing ?I have only ever had issues with such crashes when compiling huge programs such as chromium but I suppose video editing could be another candidate ?
Re: tmpfiles Question Reply #8 – 09 January 2025, 17:40:08 thank you. still sipping coffee. I meant to say it can be bigger than ram and will swap to disk
Re: tmpfiles Question Reply #9 – 09 January 2025, 20:22:46 Quote from: ####### – on 09 January 2025, 15:17:02...but for a modern setup, adjust your /etc/fstab and afterwards run:Code: [Select]# mkinitcpio -P There is usually very little in terms of file size that goes in /tmp so it isn't a big drain on RAM.Thank you very much for the explanation! Now I'm happy. Cheers!