buildroot/package/skeleton-init-systemd/overlayfs/prepare-var-overlay.service

20 lines
852 B
SYSTEMD

[Unit]
Description=Variable storage overlay setup
ConditionPathIsSymbolicLink=!/var
DefaultDependencies=no
RequiresMountsFor=/run/buildroot/mounts/var
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/mkdir -p /run/buildroot/mounts/var/lower /run/buildroot/mounts/var/upper /run/buildroot/mounts/var/work
# Ideally, we would like to use a systemd mount unit to manage the bind
# mount. Unfortunately, that creates a circular dependency: such a unit
# would have What=/var while var.mount has Where=/var so that introduces
# an implicit dependency from that unit to var.mount, but var.mount
# would have an explicit dependency to be ordered after that unit.
# So we handle the bind mount manually.
ExecStart=/usr/bin/mount -n -o bind,private /var /run/buildroot/mounts/var/lower
ExecStop=/usr/bin/umount -l /run/buildroot/mounts/var/lower