Discussion:
Auto fsck on hotplug
(too old to reply)
Andy Pieters
2017-09-22 14:21:24 UTC
Permalink
Raw Message
Hi all

Apologies if already covered or not suitable for this mailing list.

As the title says, does anyone have any ideas on autofsck on hotplugging a
USB storage device containing jfs.

Mount always fails if the jfs is dirty, but a single fsck is all that is
needed to make it mountable again...

Thanks

Andy
Lennart Poettering
2017-09-22 14:51:01 UTC
Permalink
Raw Message
Post by Andy Pieters
Hi all
Apologies if already covered or not suitable for this mailing list.
As the title says, does anyone have any ideas on autofsck on hotplugging a
USB storage device containing jfs.
Mount always fails if the jfs is dirty, but a single fsck is all that is
needed to make it mountable again...
You can put something together using the SYSTEMD_WANTS udev property,
and pull in a systemd-***@.service instance for your device from
there.

That said, I'd suggest going the other way, and just using
"systemd-mount" instead for mounting the device. It has a couple of
benefits: first of all it will automatically do an fsck before
mounting the device. But secondly it can do autofs mounts, so that the
file system only remains mounted as long as it is accessed, and is
unmounted automatically a short time after the last access
happened. That way you get the biggest chance that the file system
remains clean and should it not be clean is automatically corrected.

Lennart
--
Lennart Poettering, Red Hat
Andy Pieters
2017-09-22 15:03:59 UTC
Permalink
Raw Message
Post by Lennart Poettering
Post by Andy Pieters
Hi all
Apologies if already covered or not suitable for this mailing list.
As the title says, does anyone have any ideas on autofsck on hotplugging
a
Post by Andy Pieters
USB storage device containing jfs.
Mount always fails if the jfs is dirty, but a single fsck is all that is
needed to make it mountable again...
You can put something together using the SYSTEMD_WANTS udev property,
there.
That said, I'd suggest going the other way, and just using
"systemd-mount" instead for mounting the device. It has a couple of
benefits: first of all it will automatically do an fsck before
mounting the device. But secondly it can do autofs mounts, so that the
file system only remains mounted as long as it is accessed, and is
unmounted automatically a short time after the last access
happened. That way you get the biggest chance that the file system
remains clean and should it not be clean is automatically corrected.
Lennart
​I'm liking this idea. Thank you Lennart :)​
Andy Pieters
2017-09-22 21:17:46 UTC
Permalink
Raw Message
Post by Andy Pieters
Post by Andy Pieters
Post by Andy Pieters
Hi all
Apologies if already covered or not suitable for this mailing list.
As the title says, does anyone have any ideas on autofsck on
hotplugging a
Post by Andy Pieters
USB storage device containing jfs.
Mount always fails if the jfs is dirty, but a single fsck is all that is
needed to make it mountable again...
You can put something together using the SYSTEMD_WANTS udev property,
there.
That said, I'd suggest going the other way, and just using
"systemd-mount" instead for mounting the device. It has a couple of
benefits: first of all it will automatically do an fsck before
mounting the device. But secondly it can do autofs mounts, so that the
file system only remains mounted as long as it is accessed, and is
unmounted automatically a short time after the last access
happened. That way you get the biggest chance that the file system
remains clean and should it not be clean is automatically corrected.
Lennart
​I'm liking this idea. Thank you Lennart :)​
Just a quick follow-up to say I got the automount working but the fsck not.
Basically what happens is I do a pm-suspend on my computer with my usb disk
mounted. When I resume my computer I often forget to power on my external
disk before resuming. With the consequence that the JFS is dirty.

Sep 22 22:08:42 AndyPieters.me.uk systemd[1]:
run-media-Andy-Happy.automount: Got automount request for
/run/media/Andy/Happy, triggered by 14275 (vdir)
Sep 22 22:08:42 AndyPieters.me.uk systemd[1]: Mounting Mount the Happy
device...
Sep 22 22:08:42 AndyPieters.me.uk systemd[1]: run-media-Andy-Happy.mount:
Mount process exited, code=exited status=32
Sep 22 22:08:42 AndyPieters.me.uk systemd[1]: Failed to mount Mount the
Happy device.

[***@AndyPieters system]# systemctl cat run-media-Andy-Happy.mount
# /etc/systemd/system/run-media-Andy-Happy.mount
# Automount unit for the Happy device onto /run/media/Andy/Happy

[Unit]
Description=Mount the Happy device

[Mount]
What=/dev/disk/by-label/Happy
Where=/run/media/Andy/Happy
Type=jfs

[***@AndyPieters system]# systemctl cat run-media-Andy-Happy.automount
# /etc/systemd/system/run-media-Andy-Happy.automount
# Automount unit for the Happy device onto /run/media/Andy/Happy

[Unit]
Description=Automatically mount the Happy device

[Automount]
Where=/run/media/Andy/Happy

Loading...