Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Ubuntu 20.04 Root on ZFS.rst #122

Closed
wants to merge 1 commit into from

Conversation

OtherJohnGray
Copy link

Hi, I'm not sure if this is correct or not - but this change removes section 4.15, "Patch a dependency loop", as it seems that this is no longer required now that openzfs/zfs#10388 has been merged?

Following the current instructions in 4.15 generates the following console output:

root@rescue ~ # curl https://launchpadlibrarian.net/478315221/2150-fix-systemd-dependency-loops.patch | \
>     sed "s|/etc|/lib|;s|\.in$||" | (cd / ; sudo patch -p1)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1487  100  1487    0     0   4260      0 --:--:-- --:--:-- --:--:--  4260
patching file lib/systemd/system-generators/zfs-mount-generator
Hunk #1 FAILED at 42.
Hunk #2 FAILED at 62.
Hunk #3 succeeded at 157 with fuzz 2 (offset 80 lines).
2 out of 3 hunks FAILED -- saving rejects to file lib/systemd/system-generators/zfs-mount-generator.rej
patching file lib/systemd/system/zfs-mount.service
Hunk #1 FAILED at 6.
1 out of 1 hunk FAILED -- saving rejects to file lib/systemd/system/zfs-mount.service.rej

/lib/systemd/system/zfs-mount.service.rej contains the following:

root@rescue ~ # cat /lib/systemd/system-generators/zfs-mount-generator.rej
--- lib/systemd/system-generators/zfs-mount-generator
+++ lib/systemd/system-generators/zfs-mount-generator
@@ -42,6 +42,8 @@
   do_fail "zero or three arguments required"
 fi

+pools=$(zpool list -H -o name)
+
 # For ZFSs marked "auto", a dependency is created for local-fs.target. To
 # avoid regressions, this dependency is reduced to "wants" rather than
 # "requires". **THIS MAY CHANGE**
@@ -62,6 +64,7 @@
   set -f
   set -- $1
   dataset="${1}"
+  pool="${dataset%%/*}"
   p_mountpoint="${2}"
   p_canmount="${3}"
   p_atime="${4}"

/lib/systemd/system-generators/zfs-mount-generator seems to already contain equivalent code to the rejected hunks, and the accepted hunk seems to generate a code block starting line 160, that seems like a partial and older version of the code block at line 121?

121   # If the pool is already imported, zfs-import.target is not needed.  This
122   # avoids a dependency loop on root-on-ZFS systems:
123   # systemd-random-seed.service After (via RequiresMountsFor) var-lib.mount
124   # After zfs-import.target After zfs-import-{cache,scan}.service After
125   # cryptsetup.service After systemd-random-seed.service.
126   #
127   # Pools are newline-separated and may contain spaces in their names.
128   # There is no better portable way to set IFS to just a newline.  Using
129   # $(printf '\n') doesn't work because $(...) strips trailing newlines.
130   IFS="
131 "
132   for p in $pools ; do
133     if [ "$p" = "$pool" ] ; then
134       after=""
135       wants=""
136       break
137     fi
138   done
. . . . . 
160   # If the pool is already imported, zfs-import.target is not needed.  This
161   # avoids a dependency loop on root-on-ZFS systems:
162   # systemd-random-seed.service After (via RequiresMountsFor) var-lib.mount
163   # After zfs-import.target After zfs-import-{cache,scan}.service After
164   # cryptsetup.service After systemd-random-seed.service.
165   for p in $pools ; do
166     if [ "$p" = "$pool" ] ; then
167       wants=""
168       break
169     fi
170   done

/lib/systemd/system/zfs-mount.service.rej contains the following:

--- lib/systemd/system/zfs-mount.service
+++ lib/systemd/system/zfs-mount.service
@@ -6,7 +6,6 @@
 After=zfs-import.target
 After=systemd-remount-fs.service
 Before=local-fs.target
-Before=systemd-random-seed.service
 After=zfs-load-module.service
 ConditionPathExists=/sys/module/zfs

And /lib/systemd/system/zfs-mount.service does not contain the string "Before=systemd-random-seed.service"

...Is it therefore right to remove section 4.15 from this manual?

Hi, I'm not sure if this is correct or not - but this change removes section 4.15, "Patch a dependency loop", as it seems that this is no longer required now that openzfs/zfs#10388 has been merged?

Following the current instructions in 4.15 generates the following console output:

```
root@rescue ~ # curl https://launchpadlibrarian.net/478315221/2150-fix-systemd-dependency-loops.patch | \
>     sed "s|/etc|/lib|;s|\.in$||" | (cd / ; sudo patch -p1)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1487  100  1487    0     0   4260      0 --:--:-- --:--:-- --:--:--  4260
patching file lib/systemd/system-generators/zfs-mount-generator
Hunk openzfs#1 FAILED at 42.
Hunk openzfs#2 FAILED at 62.
Hunk openzfs#3 succeeded at 157 with fuzz 2 (offset 80 lines).
2 out of 3 hunks FAILED -- saving rejects to file lib/systemd/system-generators/zfs-mount-generator.rej
patching file lib/systemd/system/zfs-mount.service
Hunk openzfs#1 FAILED at 6.
1 out of 1 hunk FAILED -- saving rejects to file lib/systemd/system/zfs-mount.service.rej
```

/lib/systemd/system/zfs-mount.service.rej contains the following:

```
root@rescue ~ # cat /lib/systemd/system-generators/zfs-mount-generator.rej
--- lib/systemd/system-generators/zfs-mount-generator
+++ lib/systemd/system-generators/zfs-mount-generator
@@ -42,6 +42,8 @@
   do_fail "zero or three arguments required"
 fi

+pools=$(zpool list -H -o name)
+
 # For ZFSs marked "auto", a dependency is created for local-fs.target. To
 # avoid regressions, this dependency is reduced to "wants" rather than
 # "requires". **THIS MAY CHANGE**
@@ -62,6 +64,7 @@
   set -f
   set -- $1
   dataset="${1}"
+  pool="${dataset%%/*}"
   p_mountpoint="${2}"
   p_canmount="${3}"
   p_atime="${4}"
```

/lib/systemd/system-generators/zfs-mount-generator seems to already contain equivalent code to the rejected hunks, and the accepted hunk seems to generate a code block starting line 160, that seems like a partial and older version of the code block at line 121?
```
121   # If the pool is already imported, zfs-import.target is not needed.  This
122   # avoids a dependency loop on root-on-ZFS systems:
123   # systemd-random-seed.service After (via RequiresMountsFor) var-lib.mount
124   # After zfs-import.target After zfs-import-{cache,scan}.service After
125   # cryptsetup.service After systemd-random-seed.service.
126   #
127   # Pools are newline-separated and may contain spaces in their names.
128   # There is no better portable way to set IFS to just a newline.  Using
129   # $(printf '\n') doesn't work because $(...) strips trailing newlines.
130   IFS="
131 "
132   for p in $pools ; do
133     if [ "$p" = "$pool" ] ; then
134       after=""
135       wants=""
136       break
137     fi
138   done
. . . . . 
160   # If the pool is already imported, zfs-import.target is not needed.  This
161   # avoids a dependency loop on root-on-ZFS systems:
162   # systemd-random-seed.service After (via RequiresMountsFor) var-lib.mount
163   # After zfs-import.target After zfs-import-{cache,scan}.service After
164   # cryptsetup.service After systemd-random-seed.service.
165   for p in $pools ; do
166     if [ "$p" = "$pool" ] ; then
167       wants=""
168       break
169     fi
170   done
```

/lib/systemd/system/zfs-mount.service.rej contains the following:
```
--- lib/systemd/system/zfs-mount.service
+++ lib/systemd/system/zfs-mount.service
@@ -6,7 +6,6 @@
 After=zfs-import.target
 After=systemd-remount-fs.service
 Before=local-fs.target
-Before=systemd-random-seed.service
 After=zfs-load-module.service
 ConditionPathExists=/sys/module/zfs
```
And /lib/systemd/system/zfs-mount.service does not contain the string "Before=systemd-random-seed.service"


...Is it therefore right to remove section 4.15 from this manual?
@rlaager
Copy link
Member

rlaager commented Feb 21, 2021

What version of zfsutils-linux do you have installed?

On Ubuntu 20.04 (in the Live CD chroot right now), I have this:

root@ubuntu:/# apt-cache policy zfsutils-linux
zfsutils-linux:
  Installed: 0.8.3-1ubuntu12.6
  Candidate: 0.8.3-1ubuntu12.6
  Version table:
 *** 0.8.3-1ubuntu12.6 500
        500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     0.8.3-1ubuntu12 500
        500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages

The patch applies cleanly.

@OtherJohnGray
Copy link
Author

OtherJohnGray commented Feb 22, 2021

I'm really sorry for wasting your time - I found my error: I am having to install from Debian because it's a Hetzner rental server, and I had reconnected after an ssh timeout and did not chroot again before applying the patch - it conflicted with the Debian version (of course):

root@rescue ~ # apt-cache policy zfsutils-linux
zfsutils-linux:
  Installed: 0.8.6-1~bpo10+1
  Candidate: 0.8.6-1~bpo10+1
  Version table:
 *** 0.8.6-1~bpo10+1 990
        100 http://mirror.hetzner.de/debian/packages buster-backports/contrib amd64 Packages
        100 http://deb.debian.org/debian buster-backports/contrib amd64 Packages
        100 /var/lib/dpkg/status
     0.7.12-2+deb10u2 500
        500 http://mirror.hetzner.de/debian/packages buster/contrib amd64 Packages
        500 http://deb.debian.org/debian buster/contrib amd64 Packages

Thanks for this install guide BTW, I really appreciate being able to have a mirrored ZFS root on my various production machines and there is no way I could get there without it. I'm hoping to find some time to make an bash/dialog install script based on your guide to save myself some typing in future - would you mind if I posted that to github as a "partial implementation of OpenZFS on root install instructions" in case others find it helpful?

@OtherJohnGray OtherJohnGray deleted the patch-1 branch February 22, 2021 07:26
@rlaager
Copy link
Member

rlaager commented Feb 22, 2021

A number of people have made scripts of this. If you want to, go ahead. Longer term, I really wish that Ubuntu would add mirrored support to their (server) installer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants