You are not logged in.

#1 2015-05-28 22:15:26

Registered: 2014-02-19
Posts: 3

systemd (auto)mount USB fails due to fsck


I am trying to get 'hotplugging' functionality working for usb storage devices with systemd with the ultimate goal of running a backup service via systemd which will require certain devices and mounts to be active.

After a few searchers, I decided the approach of adding the external storage device to fstab with a couple systemd options

Here's the relevant line in my fstab

# USB for data where CoW not desired
UUID=964cc231-af3f-49ef-94f3-f73ffd551fda	/media/storage_nocow	ext4	noauto,x-systemd.automount 	0	2

That worked nicely. The device is mounted anytime the mountpoint is requested (e.g. by cd'ing into that directory) provided that the device has not been unmounted.

If the device has been unmounted (with systemctl stop media-storage_nocow.mount) or removed, and then plugged back in, the mount unit fails with very vague error message. I looked around but didn't find anything definitive on how to address the issue

systemctl status media-storage_nocow.mount | tail -n 2

#May 28 11:40:57 archLenFlex systemd[1]: Dependency failed for /media/storage_nocow.
#May 28 11:40:57 archLenFlex systemd[1]: Job media-storage_nocow.mount/start failed with result 'dependency'.

I checked that the device is active

systemctl status --full dev-disk-by\\x2dlabel-CORSAIR64.device

● dev-disk-by\x2dlabel-CORSAIR64.device - Voyager_VEGA CORSAIR64
   Follow: unit currently follows state of sys-devices-pci0000:00-0000:00:14.0-usb3-3\x2d1-3\x2d1:1.0-host4-target4:0:0-4:0:0:0-block-sdb-sdb1.device
   Loaded: loaded
   Active: active (plugged) since Thu 2015-05-28 15:43:36 EDT; 2h 2min ago
   Device: /sys/devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1

The messages from journalctl were of little help. I dug around into the unit files which are generated from fstab and found that the mount requires a couple services



the requires/after units failed

systemctl status --full systemd-fsck@dev-disk-by\\x2duuid-964cc231\\x2daf3f\\x2d49ef\\x2d94f3\\x2df73ffd551fda.service

● systemd-fsck@dev-disk-by\x2duuid-964cc231\x2daf3f\x2d49ef\x2d94f3\x2df73ffd551fda.service - File System Check on /dev/disk/by-uuid/964cc231-af3f-49ef-94f3-f73ffd551fda
   Loaded: loaded (/usr/lib/systemd/system/systemd-fsck@.service; static; vendor preset: disabled)
   Active: inactive (dead) since Thu 2015-05-28 15:43:26 EDT; 30min ago
     Docs: man:systemd-fsck@.service(8)
  Process: 797 ExecStart=/usr/lib/systemd/systemd-fsck %f (code=exited, status=0/SUCCESS)
 Main PID: 797 (code=exited, status=0/SUCCESS)

May 28 15:31:27 archLenFlex systemd[1]: Starting File System Check on /dev/disk/by-uuid/964cc231-af3f-49ef-94f3-f73ffd551fda...
May 28 15:31:27 archLenFlex systemd-fsck[797]: CORSAIR64: clean, 12/3784704 files, 283568/15123984 blocks
May 28 15:31:27 archLenFlex systemd[1]: Started File System Check on /dev/disk/by-uuid/964cc231-af3f-49ef-94f3-f73ffd551fda.
May 28 15:43:26 archLenFlex systemd[1]: Stopped File System Check on /dev/disk/by-uuid/964cc231-af3f-49ef-94f3-f73ffd551fda.
May 28 15:43:26 archLenFlex systemd[1]: Stopping File System Check on /dev/disk/by-uuid/964cc231-af3f-49ef-94f3-f73ffd551fda...
May 28 15:45:22 archLenFlex systemd[1]: Dependency failed for File System Check on /dev/disk/by-uuid/964cc231-af3f-49ef-94f3-f73ffd551fda.
May 28 15:45:22 archLenFlex systemd[1]: Job systemd-fsck@dev-disk-by\x2duuid-964cc231\x2daf3f\x2d49ef\x2d94f3\x2df73ffd551fda.service/start failed with result 'dependency'.

Looking further into those units - the fsck service has a couple dependencies:

After=%i.device systemd-fsck-root.service

ExecStart=/usr/lib/systemd/systemd-fsck %f

The only one that failed was the sytemd-fsck-root.service - the other two were active/successful.

● systemd-fsck-root.service - File System Check on Root Device
   Loaded: loaded (/usr/lib/systemd/system/systemd-fsck-root.service; static; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd-fsck-root.service(8)

So, I figured I can skip the fsck in fstab and it should work. This is the case, with the following fstab line for the device,

UUID=964cc231-af3f-49ef-94f3-f73ffd551fda	/media/storage_nocow	ext4	noauto,x-systemd.automount 	0	0

From there, requesting the mountpoint activates the mount via the automount, provided the mount unit was stopped but the device wasn't unplugged. If the device is unplugged, it is necessary stop the mount unit and reload the systemctl daemon.

I think it is preferable to have the device fsck'd.

So can anyone advise why the fsck is failing and how to get the mount to work while keeping the fsck option in fstab? Why does the usb device mount even require the root fsck? I would think it should only require its own fsck.

Thanks in advance.

Last edited by akpol (2015-05-28 22:16:44)


Board footer

Powered by FluxBB