[systemd-devel] Masking mount units
Phillip Susi
phill at thesusis.net
Mon Nov 11 13:34:32 UTC 2024
Lennart Poettering <lennart at poettering.net> writes:
>> I'm reading between the lines a bit, but my guess is that libparted
>> always opens the device writable in case you start issuing actual
>> partitioning commands.
>
> That sounds like a bug though. They should open the device for write
> only when they need to make changes.
It opens all of the partitions in write mode in order to flush the
cache. I believe this was put in as a workaround to the Linux cache
coherency problem that caused reads through the whole disk not to see the
recently written filesystem superblock after running mkfs.
>> To support "parted print doesn't trigger udev
>> events", I think you'd have to change libparted so that it opens the
>> device for read first (potentially with a shared lock) and then
>> reopens it for write (with an exclusive lock) when needed (e.g. when
>> using the mkpart command in the interactive session). Without that, I
>> think you're always going to need workarounds such as masking mount
>> units.
>
> Yeah, what you are proposing sounds like it is the way to go indeed,
> if parted really is not doing this already right now.
The bsd lock only *delays* the auto mounting, it does not prevent it, so
it seems that there is nothing libparted can do to prevent auto mounting
other than getting rid of the cache flushes and accepting the old
problem with cache cohernecy.
I thought that perhaps a runtime override of RequiredBy=local-fs.target
and WantedBy=dev-sdb1.device ( equivalent to the noauto mount option in
/etc/fstab ) would do it, but apparently you can't actully set most
properties at runtime. Why is that?
Also, again, why does a udev CHANGE event on sdb1.device trigger auto
mount? Shouldn't that only be done for ADD?
More information about the systemd-devel
mailing list