You are not logged in.

#1 2012-11-29 10:16:40

xworld
Member
Registered: 2012-05-27
Posts: 153

/tmp as tmpfs

Hello Arch users, I had a question about mounting /tmp as tmpfs. I am worried it could somehow mess up the system. I read this:

Do not remove files from this directory unless you know exactly what you are doing! Many of these files are important for currently running programs and deleting them may result in a system crash.

In the wiki and I noticed there is a folder called: systemd-private-p9Qg9X in the /tmp folder. I am unable to delete it and I'm sure that is for the best. My question is this; Would mounting /tmp as tmpfs mess up my system since there is a folder in there that persists even after shutdown? It seems that it is supposed to stay there.

Thanks.

Offline

#2 2012-11-29 10:30:55

drenninghoff
Member
Registered: 2012-11-28
Posts: 34

Re: /tmp as tmpfs

No, /tmp will be regulary deleted even if you don't have it as tmpfs. The systemd-private folder is created by systemd on every boot.

So you can use /tmp as tmpfs without any problems. I would even suggest using it because new arch linux installations already have /tmp as tmpfs. Check out the default /etc/fstab file, it already contains a line for /tmp as tmpfs.

Offline

#3 2012-11-29 10:37:15

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: /tmp as tmpfs

The default fstab no longer contains this at all.  systemd takes care of it.


All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#4 2012-11-29 11:01:07

googol-1
Member
Registered: 2012-10-21
Posts: 22

Re: /tmp as tmpfs

Most likely you are already using tmpfs

% grep /tmp /etc/mtab
tmpfs /tmp tmpfs rw 0 0

Offline

#5 2012-11-29 11:07:31

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: /tmp as tmpfs

Unless you have changed it you will.  It's the default for both systemd and initscripts.  For example, look at /lib/systemd/system/tmp.mount.

[Unit]
Description=Temporary Directory
Documentation=man:hier(7)
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target

[Mount]
What=tmpfs
Where=/tmp
Type=tmpfs
Options=mode=1777,strictatime

As such the entry is not required in /etc/fstab and has been removed.

Last edited by loafer (2012-11-29 11:07:47)


All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#6 2012-11-29 21:31:59

xworld
Member
Registered: 2012-05-27
Posts: 153

Re: /tmp as tmpfs

Ah I see, thanks for the replies everyone. I'm also curious about your opinions on encrypting the /tmp directory and how you think the best way to go about it is.

Offline

#7 2012-11-29 21:42:19

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: /tmp as tmpfs

Depending on what you're doing, you might also consider using /dev/shm.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#8 2012-11-29 22:08:43

tomegun
Developer
From: France
Registered: 2010-05-28
Posts: 661

Re: /tmp as tmpfs

xworld wrote:

Ah I see, thanks for the replies everyone. I'm also curious about your opinions on encrypting the /tmp directory and how you think the best way to go about it is.

If /tmp is on tmpfs (i.e., the default if you don't override it somehow), then encrypting it would not make any sense. However, as it will be (potentially) backed by swap, information written to /tmp might survive on your swap partition after a reboot. To avoid this you could encrypt your swap. I do this as follows:

/etc/fstab:
/dev/mapper/swap        swap            swap    nofail
/etc/crypttab:
swap    /dev/sda2       /dev/urandom    swap,nofail

The 'nofail' entries means that systm boot will not wait for the swap partition to be ready (as it might be a bit slow to set-up, and you probably don't need swap immediately at boot that makes sense in most cases).

Offline

#9 2012-11-29 23:11:47

xworld
Member
Registered: 2012-05-27
Posts: 153

Re: /tmp as tmpfs

Fortunately for me I never enabled the swap partition. I have plenty of RAM. I will look into using /dev/shm thanks alot for the info everyone.

Offline

Board footer

Powered by FluxBB