You are not logged in.

#1 2022-01-02 20:43:17

arturro
Member
Registered: 2022-01-02
Posts: 10

Mount usb drive configured with systemd.automount also during startup.

Hi.
I have USB drive configured with systemd.automount feature (fstab options: defaults,nofail,x-systemd.device-timeout=5,x-systemd.automount) and it works as described in manual. When I access mountpoint, system automatically mounts fs. The problem is that I also need  this fs to be mounted during startup if only drive is connected. I can of course  remove x-systemd.automount option and fs is mounted on start, but it disables automount feature.

Exactly same config works in Ubuntu but Arch behaves differently so maybe you can give me some suggestions where to find solution. To be more clear, below sample scenarios from both systems:

Ubuntu
Drive connected during startup -> partition mounted
Drive hot-pugged -> partition mounted

Arch
Drive connected during startup -> partition not mounted until "cd /mount/point" 
Drive hot-pugged -> partition not mounted until "cd /mount/point" 

Of course, to be sure that nothing triggers systemd.automount unit in Ubuntu, I checked that none of system process is accessing files below mountpoint, so I think that's not the point.

Offline

#2 2022-01-02 21:38:15

seth
Member
Registered: 2012-09-03
Posts: 49,970

Re: Mount usb drive configured with systemd.automount also during startup.

I'd say that ubuntu uses some udev driven automounter?
https://wiki.archlinux.org/title/Udisks - that's not really a difference between the distros but your setups.

Online

#3 2022-01-03 20:45:12

arturro
Member
Registered: 2022-01-02
Posts: 10

Re: Mount usb drive configured with systemd.automount also during startup.

Thank you for reply. I know that it can be achieved with udev but I was rather looking for something more straightforward smile I tried: "auto,x-systemd.automount" in fstab, thinking that maybe "defaults" parameter means something different in both systems but lately I discovered that "noauto" and "auto" options are skipped in combination with x-systemd.automount.
I still suspect that this is some kind of difference in both systems because I do not see any traces of such udev or automunting software config in Ubuntu, but maybe I have to spent more time on investigation smile

Offline

#4 2022-01-03 20:47:31

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Mount usb drive configured with systemd.automount also during startup.

Perhaps I'm missing something, but why do you want / need it mounted at boot if no process is going to access anything at all on the drive?  If any process tries to access it, it will be (auto)mounted, right?  So why mount it when it's explicitly not needed or used?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2022-01-03 21:10:36

seth
Member
Registered: 2012-09-03
Posts: 49,970

Re: Mount usb drive configured with systemd.automount also during startup.

Depending on what "ubuntu" means you could also have some automounting capacity in the DE (eg. gnome) but if this wasn't a purely academic question, but you're actually trying to solve a problem, I'm w/ Trilby and you'll have to explain what you're actually trying to achieve this way.

I tried: "auto,x-systemd.automount" in fstab, thinking that maybe "defaults" parameter means something different in both systems but lately I discovered that "noauto" and "auto" options are skipped in combination with x-systemd.automount.

That doesn't explain the ubuntu runtime behavior, but is also not the documented nor experienced behavior.
"auto,x-systemd.automount" should™ get you the device mounted *if* it is available during the boot (what might not be the case) and "noauto" will prevent that (eg. it's common to use "noauto,x-systemd.automount" w/ network devices to not stall the boot process.

Online

#6 2022-01-06 12:37:34

arturro
Member
Registered: 2022-01-02
Posts: 10

Re: Mount usb drive configured with systemd.automount also during startup.

It was DE automounter. I missed that, because I use system with ubuntu only through ssh but it also has X installed with session autostart feature so I thought that it was mounted during startup.

OK I explains difference between both systems. Now back to my initial problem. It is hard to explain smile In this particular setup I need this drive to behave differently based on "how/when" it is connected. If it is present during startup it should work as internal drive and be accessible immediately. As far as I know  systemd.automount runs fsck before it mounts fs, so sometimes it can lead to long delays (big drive with lots of data) before process can access files. On the other hand when I connect drive after startup it should behave as typical usb flash memory.

Gathering all this assumptions and our previous talk I should setup udev rules and rather leave systemd.automount in peace smile

BTW

seth wrote:

"auto,x-systemd.automount" should™ get you the device mounted *if* it is available during the boot (what might not be the case) and "noauto" will prevent that (eg. it's common to use "noauto,x-systemd.automount" w/ network devices to not stall the boot process.

This is only true for remote filesystems but I think it should also apply to externally attached drives (more flexible solution). When using block devices it works differently (according to: https://www.suse.com/support/kb/doc/?id=000020402)

Thank you for all suggestions!

Offline

#7 2022-01-06 15:07:26

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Mount usb drive configured with systemd.automount also during startup.

So the goal of mounting at boot if the device is present is just to avoid having to wait for a fsck when it is later accessed?

In that case, I'd just create a service that runs on boot that does nothing by cd's into a directory on that device.  This will trigger the automount and fsck.

You could also configure it to just not automatically fsck the device but I'm not sure that'd be a wise in the long run.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2022-01-13 21:31:07

arturro
Member
Registered: 2022-01-02
Posts: 10

Re: Mount usb drive configured with systemd.automount also during startup.

"Simplicity is the ultimate sophistication" smile

Offline

Board footer

Powered by FluxBB