Manjaro Wiki page about `/etc/fstab` needs corrections

Following the partly off-topic discussion starting around post #9 of the thread below… :arrow_down:

… it has been brought to the attention that the Wiki page on /etc/fstab needs some revision. Concretely, the page contains the following example of an /etc/fstab:arrow_down:

# /etc/fstab: static file system information.
# <file system>                           <mount point>  <type>  <options>                     <dump>  <pass>
LABEL=ESP                                 /boot/efi      vfat    umask=0077                         0       2
/dev/sda5                                 /              ext4    defaults,noatime,discard           0       1
UUID=18360b04-a96d-4a99-8323-b07717f36a31 swap           swap    defaults,noatime,discard           0       0
UUID=b4108631-e051-48d8-b2ff-a1d924a893f1 /home          ext4    defaults,noatime,discard           0       2
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777         0       0
UUID=634E43D367B0A4B1                     /media/Data    ntfs-3g noauto,x-systemd.automount,x-systemd.device-timeout=10,rw,inherit,permissions,streams_interface=windows,windows_names,compression,norecover,hide_dot_files,hide_hid_files,big_writes 0 2

The two problematic — read: incorrect — entries in the example file are the following… :arrow_down:

UUID=18360b04-a96d-4a99-8323-b07717f36a31 swap           swap    defaults,noatime,discard           0       0
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777         0       0

And here’s why they are wrong… :arrow_down:

The first incorrect line here-above is a line for a swap partition. The mount options for that swap partition should not contain the option noatime, because noatime is a mount option that tells the filesystem not to update the time of last access on an inode unless the mtime is also modified. So far so good, but the reason why this option is wrong is that a swap partition does not contain any filesystem — the kernel accesses the raw drive blocks — and that therefore, there are no inodes.

Does this mount option cause any harm? No, it doesn’t, but for a swap partition it’s an incorrect one nevertheless. The same is true for swap files, by the way.

The second incorrect line here-above is for mounting a tmpfs to /tmp. This line is redundant, because Manjaro uses systemd as the init system and service manager, and in all systemd-based Arch-derivatives — as well as in Debian and its derivatives, and in RedHat and its derivatives — systemd itself already mounts a tmpfs at /tmp. (openSUSE and SUSE proper are the only two systemd-based exceptions that I know of.)

Therefore, having an entry for /tmp in /etc/fstab will cause this entry to mount another tmpfs at /tmp, thereby obscuring the first tmpfs that was already mounted there by systemd, possibly leading to a small loss of total available memory if something was already parked in /tmp before /etc/fstab is processed. Not exactly a tragic mistake on today’s systems with many GiB of RAM, but nevertheless an incorrect setup.

Furthermore, the example for /tmp also references the mode=1777 mount option. While tmpfs does support this mount option, it is again redundant, given that the /tmp directory is by default created with 1777 permissions — i.e. drwxrwxrwt — and that tmpfs is a POSIX-compatible virtual-memory filesystem. As such, when a tmpfs is mounted to a directory with 1777 permissions, the root directory of the tmpfs will inherit the 1777 permissions of the directory it is mounted to.

Conclusion

  1. The entry for the swap partition in the /etc/fstab example should be edited to only contain either the mount option defaults or the mount option swap — but not both at the same time — possibly added with the option discard=pages to allow for a TRIM operation, because fstrim.timer does not normally cover the swap partition, given that the fstrim command only works on read/write-mounted filesystems, and the swap partition does not contain any filesystem.

  2. The entry for /tmp should be removed altogether from the /etc/fstab example.

  3. Optional: The example on the Wiki page also contains a sample entry for an NTFS filesystem, to be mounted at /media/Data. Due to udisks2 auto-mounting removable storage and non-system filesystems alike under /run/media or /run/user, the directory /media does not exist by default anymore — i.e. the user would have to create it themselves (with superuser privileges, because it’s a root-level directory) — and I would also recommend against using uppercase characters for anything outside of the user’s own $HOME. So perhaps make it into /media/data, and add a note to the article that neither /media nor /media/data exist by default, and must be explicitly created with… :arrow_down:

sudo mkdir -p /media/data

Lastly, I am posting this thread in Wiki because I’m not a Wiki editor, and apart from one of my fellow moderators — who happens to be too busy to concern himself with editing the Wiki or monitoring the forum right now — I don’t know who the other community members with Wiki editor access are. So hopefully one of them will pick up this thread and correct the article. :wink:

:man_bowing:

8 Likes

Please take a look at my changes.

If you want something on the wiki, just send it to me. (You won’t have to argue with me most of the time :wink: )
:footprints:

1 Like

Almost perfect, but you left the mount options for the swap partition blank, and that’s going to result in a syntax error — in practice, the record will probably just be skipped — because now you are missing a field.

The whitespace acts as a field separator, and there should be six fields. This is why you must use defaults as a placeholder for the mount options for swap. :wink:

This was work in progress :wink:

I read the manpages.

swap should have “none” and “defaults”. I hope, now it is OK :wink:

And i found a new option for my fstab

lazytime instead of noatime.

2 Likes

A bit of lazy time every once in a while is healthy. :face_with_hand_over_mouth:

I have now switched all my entries in the fstab to lazytime and the computer still boots :wink:

Subjectively, it is now about 20% faster, uses less RAM and he says that he can now also do lassange.

2 Likes

Deleting the line freed me about 3GB of reserved memory (was ~27GB, is now ~30GB out of 32GB).
:yum:

2 Likes

The archwiiki describes the entry as a way to augment the defaults of tmpfs
(such as the default to use a maximum half of RAM)

https://wiki.archlinux.org/title/Tmpfs

But you are correct a second tmpfs is created… I just checked:

NO TMPFS FSTAB ENTRY:

$ df -h | grep tmp
tmpfs           6.8G     0  6.8G   0% /dev/shm
tmpfs           6.8G  4.0K  6.8G   1% /tmp
tmpfs           1.4G   32K  1.4G   1% /run/user/1000

$ findmnt /tmp
/tmp tmpfs tmpfs  rw,nosuid,nodev,size=7080756k,nr_inodes=1048576,inode64

INCLUDING TMPFS FSTAB ENTRY:

$ df -h | grep tmp
tmpfs           6.8G     0  6.8G   0% /dev/shm
tmpfs           6.8G  4.0K  6.8G   1% /tmp
tmpfs           1.4G   16K  1.4G   1% /run/user/966
tmpfs           1.4G   32K  1.4G   1% /run/user/1000

$ findmnt /tmp
/tmp tmpfs tmpfs  rw,noatime,inode64
4 Likes

I only see one /tmp, the extra one seems to be a /run/user for user 966.

Here’s mine with the fstab entry:

tmpfs    16G  260K   16G   1% /dev/shm
tmpfs    16G  309M   16G   2% /tmp
tmpfs    3.2G  76K  3.2G   1% /run/user/1000

Mine is also like dmt’s with fstab. Only three mounts, user 1000.

I’m not sure that is happenig. systemd mounts /tmp automatically via tmp.mount unit (/usr/lib/systemd/system/tmp.mount).
If there is an entry for /tmp in /etc/fstab it would be parsed and generated an own tmp.mount unit which would then take precedence over the above mentioned one: you would still only have /tmp mounted once.

Not so, my friend. See @cscs’ reply above. The mount from /etc/fstab will overlap (and obscure) the earlier tmpfs.

So the first mount is there, from systemd, mounting a tmpfs to /tmp. Then systemd parses /etc/fstab and mounts yet another tmpfs over the first tmpfs.

I was curious and read arch wiki about tmpfs:
Under systemd, /tmp is automatically mounted as a tmpfs, if it is not already a dedicated mountpoint (either tmpfs or on-disk) in /etc/fstab. To disable the automatic mount, mask the tmp.mount systemd unit.
I readded the tmpfs line in fstab

  • no tmpfs entry
$ df -h | grep tmp
tmpfs            16G     45M   16G    1% /dev/shm
tmpfs            16G    4,5M   16G    1% /tmp
tmpfs           3,1G     80K  3,1G    1% /run/user/1000
$
$ findmnt /tmp
/tmp tmpfs tmpfs  rw,nosuid,nodev,nr_inodes=1048576,inode64
$ 
  • with readded tmpfs entry
$ df -h | grep tmp
tmpfs            16G       0   16G    0% /dev/shm
tmpfs            16G     16K   16G    1% /tmp
tmpfs           3,1G     76K  3,1G    1% /run/user/1000
$ 
$ findmnt /tmp
/tmp tmpfs tmpfs  rw,noatime,inode64
$ 

…miraculous selfhealing, still have 30.6GB out of 32GB. It was ~27GB before. :jigsaw:

no tmpfs entry in fstab

devtmpfs        4,0M       0  4,0M    0% /dev
tmpfs            24G       0   24G    0% /dev/shm
tmpfs           9,5G    9,7M  9,4G    1% /run
tmpfs            24G    4,0K   24G    1% /tmp
tmpfs           4,8G     64K  4,8G    1% /run/user/1000

devtmpfs ??

Is created and mounted by the kernel. It gets populated with device nodes before init (systemd) is started.

1 Like

thx a lot

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.