Chapter 18 - Automatic Filesystem Mounting - doesn't work for me
I was trying to implement "Automatic Filesystem Mounting" using the systemd way. As mentioned in this chapter, in the past the autofs package did the job and I had used it several times without issues.
My host system: Manjaro
Kernel: 5.8.11-1-MANJARO
systemd: systemd 246 (246.6-1-manjaro)
My idea was to automount an external backup drive connected via USB. The filesystem on the backup drive is NTFS, since it backs up the photo collection on my Windows 10 VM. The NTFS driver I use is NTFS-3g which is the default nowadays:
$ ls -lF /usr/bin/mount.ntfs* lrwxrwxrwx 1 root root 16 Aug 30 12:50 /usr/bin/mount.ntfs -> /usr/bin/ntfs-3g* lrwxrwxrwx 1 root root 16 Aug 30 12:50 /usr/bin/mount.ntfs-3g -> /usr/bin/ntfs-3g*
The mount options in my fstab before using the systemd approach are as follows:/dev/disk/by-partlabel/wdbook /media/heiko/wdbook ntfs-3g noauto,rw,user,nls=utf8,uid=1000,gid=1000,dmask=027,fmask=137,nofail,windows_names,locale=en_US.utf8 0 0
which should translate into: noauto = don't mount at boot or with mount -a, rw = read-write access, user = let non-root user mount the filesystem, nls = enable utf8 character encoding, uid/gid = set the file ownership and group to myself (1000), dmask/fmask = mask the directory and file permissions (restrict access), nofail = don't cry if the drive isn't there, windows_names = prevent files, directories and extended attributes to be created with a name not allowed by windows, locale = set the locale (needed for sorting etc.), 0 0 = don't dump and don't fsck. I know it's a mouthful of options, but that worked fine so far.
If I comment out the line in fstab (no entry for the drive), the drive is shown in the file browser but not mounted. I can easily mount it via the file browser. I guess that's the default setting for this desktop OS.
However, the drive doesn't spin down and I was hoping that the systemd approach would allow me to spin down the disk when not in use. Here are the settings I used:
/dev/disk/by-partlabel/wdbook /media/heiko/wdbook ntfs-3g noauto,x-systemd.automount,x-systemd.device-timeout=10,x-systemd.idle-timeout=60,rw,user,nls=utf8,uid=1000,gid=1000,dmask=027,fmask=137,nofail,windows_names,locale=en_US.utf8 0 0
The timeout settings had absolutely no effect. By the way, I found the following website: https://www.golinuxcloud.com/automount-file-system-systemd-rhel-centos-7-8/
The article describes how to set up automount using systemd. It talks about first creating a .mount file for the drive, then a .automount config file to have it automounted. If I understand that correctly, the .mount file would be in lieu of the /etc/fstab entry?
I think this whole systemd approach is messing up my mind. What would be the right approach - using systemd - to have an external drive recognized and mounted "on demand", that is not automatically at boot. Also, the drive should spin down after a given idle time.
Thanks for looking into it.
Comments
-
I rechecked the setup. It turns out I had created a media-heiko-wdbook.mount file with the following content:
# https://www.golinuxcloud.com/automount-file-system-systemd-rhel-centos-7-8/ [Unit] Description=Western Digital Book wdbook external drive DefaultDependencies=no Conflicts=umount.target Before=local-fs.target umount.target After=swap.target [Mount] What=/dev/disk/by-partlabel/wdbook Where=/media/heiko/wdbook Type=ntfs-3g Options=noauto,rw,user,nls=utf8,uid=1000,gid=1000,dmask=027,fmask=137,nofail,windows_names,locale=en_US.utf8 [Install] WantedBy=multi-user.target
This mount option was enabled.
When I stopped and disabled the mount service the drive does NOT auto-mount:
$ systemctl status media-heiko-wdbook.mount ● media-heiko-wdbook.mount - Western Digital Book wdbook external drive Loaded: loaded (/etc/systemd/system/media-heiko-wdbook.mount; disabled; vendor preset: disabled) Active: inactive (dead) Where: /media/heiko/wdbook What: /dev/disk/by-partlabel/wdbookTo check it:
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdf 8:80 0 3.6T 0 disk └─sdf1 8:81 0 3.6T 0 part
or better:
$ systemctl -t mount UNIT LOAD ACTIVE SUB DESCRIPTION -.mount loaded active mounted Root Mount boot-efi.mount loaded active mounted /boot/efi dev-hugepages.mount loaded active mounted /dev/hugepages dev-mqueue.mount loaded active mounted POSIX Message Queue File System home.mount loaded active mounted /home run-user-1000-gvfs.mount loaded active mounted /run/user/1000/gvfs run-user-1000.mount loaded active mounted /run/user/1000 sys-fs-fuse-connections.mount loaded active mounted FUSE Control File System sys-kernel-config.mount loaded active mounted Kernel Configuration File System sys-kernel-debug.mount loaded active mounted Kernel Debug File System sys-kernel-tracing.mount loaded active mounted Kernel Trace File System tmp.mount loaded active mounted Temporary Directory (/tmp)
It turns out thunar-volman was installed which handles removable drives automatically. Thunar is the file manager on XFCE Arch Linux (and Manjaro) and it's quite convenient.
Below is a summary of tests I've done:
- No /etc/fstab entry, media-heiko-wdbook.mount disabled:
Using the Thunar file manager I can manually mount/unmount the drive. However, the disk never spins down.
- /etc/fstab entry, media-heiko-wdbook.mount disabled:
I can no more mount the volume via Thunar and get the following error:

Here is the fstab entry:
/dev/disk/by-partlabel/wdbook /media/heiko/wdbook ntfs-3g noauto,rw,user,nls=utf8,uid=1000,gid=1000,dmask=027,fmask=137,nofail,windows_names,locale=en_US.utf8 0 0Note the "user" option which should allow me to mount the drive.
- With fstab entry, media-heiko-wdbook.mount enabled and running:
sudo systemctl enable media-heiko-wdbook.mount
sudo systemctl start media-heiko-wdbook.mountThe moment I enter systemctl start media...mount command the drive is mounted.
I can unmount the drive using the Thunar file manager, but when I try to mount it again using Thunar, I get the error window shown above.
Trying to remount the drive with root privileges works:
$ sudo mount /media/heiko/wdbook/ [heiko@woody ~]$ cat /proc/mounts | grep sdf1 /dev/sdf1 /media/heiko/wdbook fuseblk rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
But trying to mount as regular user doesn't:
$ mount /media/heiko/wdbook/ Unprivileged user can not mount NTFS block devices using the external FUSE library. Either mount the volume as root, or rebuild NTFS-3G with integrated FUSE support and make it setuid root. Please see more information at http://tuxera.com/community/ntfs-3g-faq/#unprivileged
- No /etc/fstab entry, media-heiko-wdbook.mount enabled and running:
I commented out the /etc/fstab entry and rebooted.
The drive is automatically mounted under /media/heiko/wdbook:
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdf 8:80 0 3.6T 0 disk └─sdf1 8:81 0 3.6T 0 part /media/heiko/wdbook
A look at /proc/mounts shows the mount options used:
$ cat /proc/mounts | grep sdf1 /dev/sdf1 /media/heiko/wdbook fuseblk rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
Seems like the only thing taken from media-heiko-wdbook.mount options is the mount point.
I can unmount the drive using Thunar, and remount it again. This time, however, it mounts under a different folder:
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdf 8:80 0 3.6T 0 disk └─sdf1 8:81 0 3.6T 0 part /run/media/heiko/32BB56432280CBF1
The Thunar volume mounter has disregarded both the mount point and the mount options specified in media-heiko-wdbook.mount:
/proc/mounts reveals the following:
$ cat /proc/mounts | grep sdf1 /dev/sdf1 /run/media/heiko/32BB56432280CBF1 fuseblk rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
My conclusion and questions
- Some higher-level convenience tools don't play nicely with "low-level" configurations, overriding manual systemd and fstab configurations.
- The ntfs-3g driver complains about non-root user trying to use external FUSE library. This may explain why I always get user_id=0 and group_id=0. Any ideas?
- As far as I can tell, thunar-volman is using udev to automount? If yes, how does that work?
- Is there an easy way to let both methods live side by side - that is systemd mounting and udev / thunar-volman mounting - without one interfering with the other?
In any case, the automount systemd feature doesn't seem to be that straightforward.
0 -
Note: we were taking a look to this on the Office Hours. Heiko will do another test on Ubuntu, as Manjaro was doing weird for some things. He was able to expose the external disk to a guest, using virsh/quemu.
Heiko will update this thread with his findings

Luis.
0 -
Just a reminder:
We make no attempt to make sure anything works on Manjaro or with thunar etc, as we do not try to cover the entire universe of distributions and versions. We test on CentOS and Ubuntu primarily, and OpenSUSE secondarily, and this almost always means Red Hat, Fedora, Debian and SLES provide no real problems.
The LFCS and LFCE exams are on CentOS and Ubuntu and getting absorbed with the variations for Manjaro, Kali, Mint etc may be fun but are unlikely to get much attention here, at least not mine. The same goes for trying to run complex stuff on RPI etc. Have fun but our help will be (consciously) limited.
1 -
Update
I've passed through the external hard drive to a Ubuntu 18.04 server VM and edited the /etc/fstab file as follows:
/dev/disk/by-partlabel/wdbook /mnt ntfs-3g noauto,rw,user,x-systemd.automount,x-systemd.device-timeout=10,x-systemd.idle-timeout=60,nls=utf8,uid=1000,gid=1000,dmask=027,fmask=137,nofail,windows_names,locale=en_US.utf8 0 0The drive is mounted as /dev/sda1:
heiko@worker4:~$ ls -lF /dev/disk/by-partlabel/ total 0 lrwxrwxrwx 1 root root 10 Oct 5 19:30 wdbook -> ../../sda1
Then I entered:
root@worker4:/etc# systemctl daemon-reload root@worker4:/etc# systemctl restart local-fs.target root@worker4:/etc# lsblk -o name,mountpoint,partlabel,fstype NAME MOUNTPOINT PARTLABEL FSTYPE ... sda └─sda1 wdbook ntfs ...
The drive is not mounted automatically, just as expected.
As non-root user I subsequently entered:
heiko@worker4:~$ ls /mnt '$RECYCLE.BIN' 'My File Backup' 'System Volume Information'
and my drive content shows up magically.
heiko@worker4:~$ lsblk -o name,mountpoint,partlabel,fstype NAME MOUNTPOINT PARTLABEL FSTYPE ... sda └─sda1 /mnt wdbook ntfs ... heiko@worker4:~$ cat /proc/mounts | grep mnt systemd-1 /mnt autofs rw,relatime,fd=41,pgrp=1,timeout=60,minproto=5,maxproto=5,direct,pipe_ino=24929 0 0 /dev/sda1 /mnt fuseblk rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
After the specified timeout the drive automatically unmounts:
heiko@worker4:~$ lsblk -o name,mountpoint,partlabel,fstype NAME MOUNTPOINT PARTLABEL FSTYPE ... sda └─sda1 wdbook ntfs ...
Systemd automount works as advertised.
1 -
That's pretty good, @heiko_s !!
I'm glad it worked as advertised, hehehe. Now it's more interesting because you are passing the device through the host to the guest. Oh, I don't forget it's a NTFS fs using the ntfs-3g driver

Many regards,
Luis.0 -
@coop said:
Just a reminder:We make no attempt to make sure anything works on Manjaro or with thunar etc, as we do not try to cover the entire universe of distributions and versions. We test on CentOS and Ubuntu primarily, and OpenSUSE secondarily, and this almost always means Red Hat, Fedora, Debian and SLES provide no real problems.
The LFCS and LFCE exams are on CentOS and Ubuntu and getting absorbed with the variations for Manjaro, Kali, Mint etc may be fun but are unlikely to get much attention here, at least not mine. The same goes for trying to run complex stuff on RPI etc. Have fun but our help will be (consciously) limited.
Thanks for the comment. From now on I will only present issues that pertain to CentOS or Ubuntu. The reason I brought it up was that this was such a basic exercise and something that should just work. Normally I do all my labs and exercises on a Ubuntu or Centos VM, but that harddrive being attached and used by my host OS enticed me to do the exercise on the Manjaro (Arch Linux) host. Lesson learned, as you can see in my previous post.
0 -
I also re tested this on Ubuntu20-04 my fstab:
/dev/nvme0n1p3 /home/win10 ntfs noauto,x-systemd.idle-timeout=30,x-
systemd.automount,rw,relatime,user_id=0,group_id=0,allow_other 0 0As expected it worked as documented, one observation to keep in mind with the idle timer, the gnome GUI keeps the mount active and does not unmount automaticly. If a text console login used the automounter works.
1 -
Thanks Lee, that's good to know. Well, it's the same with trying to umount a drive with an open file browser - it won't work.
1
Categories
- All Categories
- 175 LFX Mentorship
- 175 LFX Mentorship: Linux Kernel
- 745 Linux Foundation IT Professional Programs
- 372 Cloud Engineer IT Professional Program
- 168 Advanced Cloud Engineer IT Professional Program
- 73 DevOps IT Professional Program - Discontinued
- 3 DevOps & GitOps IT Professional Program
- 98 Cloud Native Developer IT Professional Program
- 7.6K Training Courses & Learning Paths
- AI & ML Training
- Blockchain & Decentralized Identity Training
- Cloud & Containers Training
- Cybersecurity Training
- DevOps & Site-Reliability Training
- Linux Kernel Development Training
- Networking Training
- Open Source Best Practice Training
- System Administration Training
- System Engineering Training
- Web & Application Development Training
- 2 LFD103-JP クラス フォーラム
- 4 LFD210-CN Class Forum
- 764 LFD259 Class Forum
- 681 LFS101 Class Forum
- 2 LFS158-JP クラス フォーラム
- 162 LFS207 Class Forum
- 3 LFS207-DE-Klassenforum
- 4 LFS207-JP クラス フォーラム
- 61 LFS241 Class Forum
- 52 LFS242 Class Forum
- 42 LFS243 Class Forum
- 19 LFS244 Class Forum
- 4 LFS250-JP クラス フォーラム
- 166 LFS253 Class Forum
- 19 LFS256 Class Forum
- 1.4K LFS258 Class Forum
- 165 LFS261 Class Forum
- 26 LFS267 Class Forum
- 792 Hardware
- 202 Drivers
- 68 I/O Devices
- 37 Monitors
- 95 Multimedia
- 173 Networking
- 91 Printers & Scanners
- 87 Storage
- 768 Linux Distributions
- 81 Debian
- 67 Fedora
- 22 Linux Mint
- 13 Mageia
- 24 openSUSE
- 150 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 465 Linux System Administration
- 31 Cloud Computing
- 73 Command Line/Scripting
- Github systems admin projects
- 98 Linux Security
- 78 Network Management
- 101 System Management
- 46 Web Management
- 106 Mobile Computing
- 18 Android
- 73 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 392 Off Topic
- 121 Introductions
- 181 Small Talk
- 29 Study Material
- 945 Programming and Development
- 310 Kernel Development
- 617 Software Development
- 977 Software
- 369 Applications
- 182 Command Line
- 5 Compiling/Installing
- 68 Games
- 317 Installation
- Archived
- 2 LFD140 Class Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)

