Fstab – Difference Between Mounting in fstab and File Manager

automountingfile-managerfstab

..and what are the consequences of the different methods?

I have been trying some things with the mounting of an sda2 partition.
Mounting in fstab, not mounting in fstab but from the file manager.

So far, if I am right, I learned that by mounting in fstab, a partition is mounted automatically at startup.
But this mounted partition is not shown under 'devices' in the file manager, whereas the root partition and cdrom for example are shown.

When you want to have it under devices in the sidebar, a partition should not be mounted in fstab but by clicking it in the file manager. Is that correct?

But which way to go if you want both? Automatically mounted at startup AND being shown in the sidebar of file manager?

Best Answer

This is documented (at least for gnome-shell/nautilus) in gvfs-udisks2-volume-monitor:

The gvfs-udisks2-volume-monitor process is responsible for the disks,
media, mounts and fstab entries shown in the desktop user interface.
..........................................
A device is either mounted (in which case its directory is known) or
it's not. If the device is not mounted, then its directory is known
only if it's referenced in the /etc/fstab file.

Further down comes the explanation:

If the directory for a device is known and outside /media, $HOME
(typically /home/foo) or /run/media/$USER then the device is not shown
in the user interface. Additionally, if any of component directories
in its directory starts with a dot ("."), the device is not shown
either. This policy may be overriden by use of the options x-gvfs-show
and x-gvfs-hide.

To sum up:

Partitions listed in /etc/fstab would (by default) only show up if they're mounted under /media, $HOME or /run/media/$USER. If you want a partition to be automatically mounted at system startup and also listed in the file manager sidebar, the easiest way is to mount it via /etc/fstab under one of those three locations.
If you want the partition to be mounted under a different directory (e.g. /mnt) and still be shown in the sidebar, you can override the default behaviour by adding x-gvfs-show to your mount options in fstab:

UUID=5a1615ca-cffd3124917a /mnt/storage ext4 rw,noatime,discard,x-gvfs-show 0 2

Partitions not listed in /etc/fstab are handled by udisks2 and will be mounted under /run/media/$USER/VolumeName or /media/VolumeName depending on the value of UDISKS_FILESYSTEM_SHARED1 hence they will be shown under Devices in the sidebar. However, they are not automatically mounted. A user could automatically mount them at session startup with udisksctl, e.g. adding:

udisksctl mount -b /dev/sdb2 -t ext4

to the session startup scripts.


1
man udisks:

UDISKS_FILESYSTEM_SHARED
   If set to 1, the filesystem on the device will be mounted in a shared directory e.g. /media/VolumeName)
   instead of a private directory (e.g. /run/media/$USER/VolumeName) when the Filesystem.Mount() method is handled.
Related Question