Skip to content

Commit

Permalink
Move dracut specifics to dracut mount unit
Browse files Browse the repository at this point in the history
Dracut depends on BOOTFS environment variable to be set after pool
import. This dracut specific systemd ExecStartPost command should not be
called for any non-dracut systems, so let's move it to a static systemd
unit that gets pulled in by the generated mount unit.
  • Loading branch information
c0d3z3r0 committed Mar 17, 2019
1 parent 9e63b03 commit 90adaaa
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ AC_CONFIG_FILES([
contrib/dracut/Makefile
contrib/dracut/02zfsexpandknowledge/Makefile
contrib/dracut/90zfs/Makefile
contrib/dracut/systemd/Makefile
contrib/initramfs/Makefile
contrib/initramfs/hooks/Makefile
contrib/initramfs/scripts/Makefile
Expand Down
3 changes: 2 additions & 1 deletion contrib/dracut/90zfs/zfs-generator.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ echo "zfs-generator: writing extension for sysroot.mount to $GENERATOR_DIR"/sysr
{
echo "[Unit]"
echo "Before=initrd-root-fs.target"
echo "After=zfs-import.target"
echo "After=zfs-dracut-bootfs.service zfs-import.target"
echo "Requires=zfs-dracut-bootfs.service"
echo "[Mount]"
if [ "${root}" = "zfs:AUTO" ] ; then
echo "PassEnvironment=BOOTFS"
Expand Down
2 changes: 1 addition & 1 deletion contrib/dracut/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SUBDIRS = 02zfsexpandknowledge 90zfs
SUBDIRS = 02zfsexpandknowledge 90zfs systemd

EXTRA_DIST = README.dracut.markdown
1 change: 1 addition & 0 deletions contrib/dracut/systemd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zfs-dracut-bootfs.service
13 changes: 13 additions & 0 deletions contrib/dracut/systemd/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
systemdunit_DATA = \
zfs-dracut-bootfs.service

EXTRA_DIST = \
$(top_srcdir)/contrib/dracut/systemd/zfs-dracut-bootfs.service.in

$(systemdunit_DATA):%:%.in
-$(SED) -e 's,@bindir\@,$(bindir),g' \
-e 's,@sbindir\@,$(sbindir),g' \
$< >'$@'

distclean-local::
-$(RM) $(systemdunit_DATA)
10 changes: 10 additions & 0 deletions contrib/dracut/systemd/zfs-dracut-bootfs.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Set BOOTFS environment for dracut
Documentation=man:zfs(8)
DefaultDependencies=no
After=zfs-import.target
Requires=zfs-import.target

[Service]
Type=oneshot
ExecStart=/bin/sh -c "/bin/systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | egrep -v '^-$')"
1 change: 0 additions & 1 deletion etc/systemd/system/zfs-import-cache.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ ConditionPathExists=@sysconfdir@/zfs/zpool.cache
Type=oneshot
RemainAfterExit=yes
ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN
ExecStartPost=/bin/sh -c "/bin/systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | egrep -v '^-$')"

[Install]
WantedBy=zfs-import.target
1 change: 0 additions & 1 deletion etc/systemd/system/zfs-import-scan.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ ConditionPathExists=!@sysconfdir@/zfs/zpool.cache
Type=oneshot
RemainAfterExit=yes
ExecStart=@sbindir@/zpool import -aN -o cachefile=none
ExecStartPost=/bin/sh -c "/bin/systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | egrep -v '^-$')"

[Install]
WantedBy=zfs-import.target

0 comments on commit 90adaaa

Please sign in to comment.