how to automatically clean /tmp
Jon LaBadie
jonfu at jgcomp.com
Wed Jan 27 20:06:54 UTC 2016
On Wed, Jan 27, 2016 at 08:29:57PM +0100, Walter Cazzola wrote:
> Dear Linux Experts,
>
> I've recently passed from Fedora 20 to Fedora 23 on my laptop.
>
> I've a separate partition for /tmp that I'm used to see it wiped out at
> any reboot on my previous installation but now this is never wiped out.
>
> This is a real partition:
>
> /dev/sda10 5029504 1154204 3596772 25% /tmp
>
> whereas previously it was a tmpfs partition. I've read on the web that
> after Fedora 20 the tmpfs has been dropped in favor of real partition
> but I was expecting anacron/cron entry that wipe the content of the
> partition at boot but my system doesn't have any.
>
> It is also difficult to create my own anacron/cron entry because this
> should take effect before the system starts and create its temp
> files/sockets in there.
>
> I'm also puzzled because I also have a couple of tmpfs partitions:
>
> tmpfs 1633640 0 1633640 0% /run/user/989
> tmpfs 1633640 16 1633624 1% /run/user/526
>
> that I don't what they are for and if I can (and how) rid of them.
>
> Probably I could add an entry like this
> tmpfs /tmp tmpfs rw,seclabel 0 0
>
> in /etc/fstab but this would means a waste of the space I currently have
> reserved for /tmp (4Gb not much but I would prefer to use them).
>
> So there is a way to wipe out the /tmp partition before it has been
> mounted and the system creates its files and use the current partition
> for it?
Couple of points. I don't think you can reserve a partition for the
use of a tmpfs. It uses your RAM memory and swap space instead.
You could add /dev/sda10 as another swap partition. Then perhaps add
the fstab entry. However, I think systemd has a way mount /tmp as a
tmpfs without having an fstab entry.
If you want to use your partition as /tmp but have it cleaned out at
boot, check the manpage for tmpfiles.d
Jon
--
Jon H. LaBadie jonfu at jgcomp.com
More information about the users
mailing list