[systemd-devel] ConditionPathExists vs mount unit

Andrei Borzenkov arvidjaar at gmail.com
Tue Aug 11 06:32:38 UTC 2020


10.08.2020 20:59, Böszörményi Zoltán пишет:
> Hi,
> 
> I have to use the same OS image tarball (created by Yocto)
> on several machines with different specifications.
> 
> Where they differ is the disk size and partitioning. On the smaller
> machine (a Sicom SL20 POS hardware, boots from CF card) the disk size
> is too small to have separate partitions for certain purposes that are
> on the other hand mandatory on the larger system.
> 
> The shipped disks are mass-produced and are pre-formatted with
> the same UUIDs across all devices so they are interchangeable.
> 
> So, I discovered the mount unit type:
> https://www.freedesktop.org/software/systemd/man/systemd.mount.html
> 
> This page says that the usual [Unit] section options are applicable.
> 
> I was hoping that the missing partitions can be skipped using the
> ConditionPathExists= option but it seems it's not the case.
> 
> On mount unit looks like this:
> ====================================================
> $ cat var.mount
> [Unit]
> Description=Variable Data (/var)
> ConditionPathExists=/dev/disk/by-uuid/e8282db7-dd6d-4231-b2b1-49887648480c
> ConditionPathIsSymbolicLink=!/var
> DefaultDependencies=no
> Conflicts=umount.target
> Before=local-fs.target umount.target
> After=swap.target
> 
> [Mount]
> What=/dev/disk/by-uuid/e8282db7-dd6d-4231-b2b1-49887648480c
> Where=/var
> Options=noatime
> 
> [Install]
> WantedBy=local-fs.target
> ====================================================
> 
> This boots properly on the larger system where the extra /var
> partition exists but the smaller system fails to boot.
> 
> systemctl status var.mount says:
> 
> Dependency failed for Variable Data (/var)
> var.mount: Job var.mount/start failed with result 'dependency'
> 
> Is there a way to describe optional mounts via such Conditions* options?
> 

No the way you are doing it. Device dependency is checked before
Conditions* directives are even looked at.

If your concern is only boot time, you should consider generators that
will create correct mount units for currently present hardware.


More information about the systemd-devel mailing list