Merge ~maciek-borzecki/ubuntu-core-initramfs:bboozzoo/recover-mode into ~canonical-foundations/ubuntu-core-initramfs:master

Proposed by Maciej Borzecki
Status: Merged
Approved by: Dimitri John Ledkov
Approved revision: 7993523b9939da2883694cd06cb32c933ffef957
Merged at revision: 7993523b9939da2883694cd06cb32c933ffef957
Proposed branch: ~maciek-borzecki/ubuntu-core-initramfs:bboozzoo/recover-mode
Merge into: ~canonical-foundations/ubuntu-core-initramfs:master
Diff against target: 245 lines (+25/-18)
8 files modified
dev/null (+0/-6)
factory/usr/lib/systemd/system/basic.target.wants/the-tool.service (+1/-0)
factory/usr/lib/systemd/system/populate-writable.service (+2/-2)
factory/usr/lib/systemd/system/run-mnt-ubuntu\\x2dseed.mount.d/override.conf" (+4/-0)
factory/usr/lib/systemd/system/sysroot-writable.mount (+2/-2)
factory/usr/lib/systemd/system/the-tool.service (+4/-1)
factory/usr/lib/the-modeenv (+0/-3)
factory/usr/lib/the-tool (+12/-4)
Reviewer Review Type Date Requested Status
Ian Johnson (community) Approve
Michael Vogt (community) Approve
Dimitri John Ledkov Pending
Review via email: mp+382415@code.launchpad.net

Description of the change

Simplify the initrd mount operation and drop the templates.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Fwiw, this looks very nice, thank you!

review: Approve
Revision history for this message
Ian Johnson (anonymouse67) wrote :

This looks great with the caveat that it should error out at some point in the-tool.service, otherwise we may have an infinite loop of broken things if snap-bootstrap is broken.

I think we can figure out later what to do if we hit the loop, maybe we should try rebooting at that point? For now it would be fine to just give up and let the user do something with the initramfs shell.

review: Needs Fixing
Revision history for this message
Ian Johnson (anonymouse67) wrote :

Disregard my previous review, it works as expected (I had something else wrong)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/factory/usr/lib/systemd/system/basic.target.wants/initrd-pick-mode@install.service b/factory/usr/lib/systemd/system/basic.target.wants/initrd-pick-mode@install.service
2deleted file mode 120000
3index fa2a481..0000000
4--- a/factory/usr/lib/systemd/system/basic.target.wants/initrd-pick-mode@install.service
5+++ /dev/null
6@@ -1 +0,0 @@
7-../initrd-pick-mode@.service
8\ No newline at end of file
9diff --git a/factory/usr/lib/systemd/system/basic.target.wants/initrd-pick-mode@run.service b/factory/usr/lib/systemd/system/basic.target.wants/initrd-pick-mode@run.service
10deleted file mode 120000
11index fa2a481..0000000
12--- a/factory/usr/lib/systemd/system/basic.target.wants/initrd-pick-mode@run.service
13+++ /dev/null
14@@ -1 +0,0 @@
15-../initrd-pick-mode@.service
16\ No newline at end of file
17diff --git a/factory/usr/lib/systemd/system/basic.target.wants/the-tool.service b/factory/usr/lib/systemd/system/basic.target.wants/the-tool.service
18new file mode 120000
19index 0000000..2c4adf3
20--- /dev/null
21+++ b/factory/usr/lib/systemd/system/basic.target.wants/the-tool.service
22@@ -0,0 +1 @@
23+../the-tool.service
24\ No newline at end of file
25diff --git a/factory/usr/lib/systemd/system/initrd-mode@.target b/factory/usr/lib/systemd/system/initrd-mode@.target
26deleted file mode 100644
27index 77a8343..0000000
28--- a/factory/usr/lib/systemd/system/initrd-mode@.target
29+++ /dev/null
30@@ -1,6 +0,0 @@
31-[Unit]
32-OnFailure=emergency.target
33-OnFailureJobMode=replace-irreversibly
34-Wants=basic.target
35-After=basic.target
36-Wants=the-tool@%i.service
37diff --git "a/factory/usr/lib/systemd/system/initrd-mode@install.target.requires/run-mnt-ubuntu\\x2dseed.mount" "b/factory/usr/lib/systemd/system/initrd-mode@install.target.requires/run-mnt-ubuntu\\x2dseed.mount"
38deleted file mode 120000
39index 0b7be5a..0000000
40--- "a/factory/usr/lib/systemd/system/initrd-mode@install.target.requires/run-mnt-ubuntu\\x2dseed.mount"
41+++ /dev/null
42@@ -1 +0,0 @@
43-../run-mnt-ubuntu\x2dseed.mount
44\ No newline at end of file
45diff --git "a/factory/usr/lib/systemd/system/initrd-mode@run.target.requires/run-mnt-ubuntu\\x2dboot.mount" "b/factory/usr/lib/systemd/system/initrd-mode@run.target.requires/run-mnt-ubuntu\\x2dboot.mount"
46deleted file mode 120000
47index 3e2a163..0000000
48--- "a/factory/usr/lib/systemd/system/initrd-mode@run.target.requires/run-mnt-ubuntu\\x2dboot.mount"
49+++ /dev/null
50@@ -1 +0,0 @@
51-../run-mnt-ubuntu\x2dboot.mount
52\ No newline at end of file
53diff --git "a/factory/usr/lib/systemd/system/initrd-mode@run.target.requires/run-mnt-ubuntu\\x2dseed.mount" "b/factory/usr/lib/systemd/system/initrd-mode@run.target.requires/run-mnt-ubuntu\\x2dseed.mount"
54deleted file mode 120000
55index 0b7be5a..0000000
56--- "a/factory/usr/lib/systemd/system/initrd-mode@run.target.requires/run-mnt-ubuntu\\x2dseed.mount"
57+++ /dev/null
58@@ -1 +0,0 @@
59-../run-mnt-ubuntu\x2dseed.mount
60\ No newline at end of file
61diff --git a/factory/usr/lib/systemd/system/initrd-pick-mode@.service b/factory/usr/lib/systemd/system/initrd-pick-mode@.service
62deleted file mode 100644
63index 141970c..0000000
64--- a/factory/usr/lib/systemd/system/initrd-pick-mode@.service
65+++ /dev/null
66@@ -1,10 +0,0 @@
67-[Unit]
68-OnFailure=emergency.target
69-OnFailureJobMode=replace-irreversibly
70-DefaultDependencies=no
71-ConditionKernelCommandLine=snapd_recovery_mode=%i
72-
73-[Service]
74-Type=oneshot
75-RemainAfterExit=true
76-ExecStart=/usr/bin/systemctl start --no-block initrd-mode@%i.target
77diff --git a/factory/usr/lib/systemd/system/populate-writable.service b/factory/usr/lib/systemd/system/populate-writable.service
78index 579befa..30d9ae3 100644
79--- a/factory/usr/lib/systemd/system/populate-writable.service
80+++ b/factory/usr/lib/systemd/system/populate-writable.service
81@@ -2,18 +2,18 @@
82 OnFailure=emergency.target
83 OnFailureJobMode=replace-irreversibly
84 Before=initrd-cleanup.target
85-After=the-tool@data.service
86 After=run-mnt-ubuntu\x2dseed.mount
87 After=run-mnt-ubuntu\x2ddata.mount
88 After=run-mnt-base.mount
89 After=sysroot.mount
90 After=sysroot-writable.mount
91-Requires=the-tool@data.service
92 Requires=run-mnt-ubuntu\x2dseed.mount
93 Requires=run-mnt-ubuntu\x2ddata.mount
94 Requires=run-mnt-base.mount
95 Requires=sysroot.mount
96 Requires=sysroot-writable.mount
97+Wants=the-tool.service
98+After=the-tool.service
99
100 [Service]
101 Type=oneshot
102diff --git "a/factory/usr/lib/systemd/system/run-mnt-ubuntu\\x2dboot.mount" "b/factory/usr/lib/systemd/system/run-mnt-ubuntu\\x2dboot.mount"
103deleted file mode 100644
104index da4ff67..0000000
105--- "a/factory/usr/lib/systemd/system/run-mnt-ubuntu\\x2dboot.mount"
106+++ /dev/null
107@@ -1,13 +0,0 @@
108-[Unit]
109-Before=local-fs.target
110-Requires=systemd-fsck@dev-disk-by\x2dlabel-ubuntu\x2dboot.service
111-After=systemd-fsck@dev-disk-by\x2dlabel-ubuntu\x2dboot.service
112-After=systemd-modules-load.service
113-Wants=systemd-moudles-load.service
114-Before=the-tool@run.service
115-
116-[Mount]
117-Where=/run/mnt/ubuntu-boot
118-What=/dev/disk/by-label/ubuntu-boot
119-Type=ext4
120-Options=rw
121diff --git "a/factory/usr/lib/systemd/system/run-mnt-ubuntu\\x2ddata.mount.wants/the-tool@data.service" "b/factory/usr/lib/systemd/system/run-mnt-ubuntu\\x2ddata.mount.wants/the-tool@data.service"
122deleted file mode 120000
123index 809d8c5..0000000
124--- "a/factory/usr/lib/systemd/system/run-mnt-ubuntu\\x2ddata.mount.wants/the-tool@data.service"
125+++ /dev/null
126@@ -1 +0,0 @@
127-../the-tool@.service
128\ No newline at end of file
129diff --git "a/factory/usr/lib/systemd/system/run-mnt-ubuntu\\x2dseed.mount" "b/factory/usr/lib/systemd/system/run-mnt-ubuntu\\x2dseed.mount"
130deleted file mode 100644
131index 0a58e65..0000000
132--- "a/factory/usr/lib/systemd/system/run-mnt-ubuntu\\x2dseed.mount"
133+++ /dev/null
134@@ -1,14 +0,0 @@
135-[Unit]
136-Before=local-fs.target
137-Requires=systemd-fsck@dev-disk-by\x2dlabel-ubuntu\x2dseed.service
138-After=systemd-fsck@dev-disk-by\x2dlabel-ubuntu\x2dseed.service
139-After=systemd-modules-load.service
140-Wants=systemd-moudles-load.service
141-Before=the-tool@run.service
142-Before=the-tool@install.service
143-
144-[Mount]
145-Where=/run/mnt/ubuntu-seed
146-What=/dev/disk/by-label/ubuntu-seed
147-Type=vfat
148-Options=rw,umask=0077
149diff --git "a/factory/usr/lib/systemd/system/run-mnt-ubuntu\\x2dseed.mount.d/override.conf" "b/factory/usr/lib/systemd/system/run-mnt-ubuntu\\x2dseed.mount.d/override.conf"
150new file mode 100644
151index 0000000..34ed571
152--- /dev/null
153+++ "b/factory/usr/lib/systemd/system/run-mnt-ubuntu\\x2dseed.mount.d/override.conf"
154@@ -0,0 +1,4 @@
155+[Unit]
156+Before=local-fs.target
157+Requires=systemd-fsck@dev-disk-by\x2dlabel-ubuntu\x2dseed.service
158+After=systemd-fsck@dev-disk-by\x2dlabel-ubuntu\x2dseed.service
159diff --git a/factory/usr/lib/systemd/system/sysroot-writable.mount b/factory/usr/lib/systemd/system/sysroot-writable.mount
160index 77caaca..8d614a5 100644
161--- a/factory/usr/lib/systemd/system/sysroot-writable.mount
162+++ b/factory/usr/lib/systemd/system/sysroot-writable.mount
163@@ -3,11 +3,11 @@ Before=initrd-cleanup.target
164 After=run-mnt-ubuntu\x2ddata.mount
165 After=run-mnt-base.mount
166 After=sysroot.mount
167-After=the-tool@data.service
168+After=the-tool.service
169 Requires=run-mnt-ubuntu\x2ddata.mount
170 Requires=run-mnt-base.mount
171 Requires=sysroot.mount
172-Requires=the-tool@data.service
173+Requires=the-tool.service
174 Wants=populate-writable.service
175 [Mount]
176 What=/run/mnt/ubuntu-data
177diff --git a/factory/usr/lib/systemd/system/the-tool@.service b/factory/usr/lib/systemd/system/the-tool.service
178similarity index 80%
179rename from factory/usr/lib/systemd/system/the-tool@.service
180rename to factory/usr/lib/systemd/system/the-tool.service
181index 7fbd24a..db27847 100644
182--- a/factory/usr/lib/systemd/system/the-tool@.service
183+++ b/factory/usr/lib/systemd/system/the-tool.service
184@@ -4,7 +4,10 @@ OnFailureJobMode=replace-irreversibly
185 DefaultDependencies=no
186 After=systemd-tmpfiles-setup.service
187
188+Requires=systemd-fsck@dev-disk-by\x2dlabel-ubuntu\x2dseed.service
189+After=systemd-fsck@dev-disk-by\x2dlabel-ubuntu\x2dseed.service
190+
191 [Service]
192 Type=oneshot
193 RemainAfterExit=true
194-ExecStart=/usr/lib/the-tool %i
195+ExecStart=/usr/lib/the-tool
196diff --git a/factory/usr/lib/systemd/system/the-tool@data.service.d/override.conf b/factory/usr/lib/systemd/system/the-tool@data.service.d/override.conf
197deleted file mode 100644
198index fe5929d..0000000
199--- a/factory/usr/lib/systemd/system/the-tool@data.service.d/override.conf
200+++ /dev/null
201@@ -1,6 +0,0 @@
202-[Unit]
203-Wants=run-mnt-ubuntu\x2data.mount
204-After=run-mnt-ubuntu\x2data.mount
205-After=the-tool@run.service
206-After=the-tool@install.service
207-
208diff --git a/factory/usr/lib/the-modeenv b/factory/usr/lib/the-modeenv
209index b958663..4b428dd 100755
210--- a/factory/usr/lib/the-modeenv
211+++ b/factory/usr/lib/the-modeenv
212@@ -8,6 +8,3 @@ fi
213 mount -o bind /run/image.fstab /sysroot/etc/fstab
214 umount -lf /sysroot/run
215 cp /run/systemd/transient/*.mount /etc/systemd/system
216-# write modeenv
217-/usr/lib/snapd/snap-bootstrap initramfs-mounts
218-
219diff --git a/factory/usr/lib/the-tool b/factory/usr/lib/the-tool
220index f295c21..a78c266 100755
221--- a/factory/usr/lib/the-tool
222+++ b/factory/usr/lib/the-tool
223@@ -3,10 +3,18 @@ set -e
224
225 # Run snap-bootstrap
226 cmd="systemd-mount --no-pager --no-ask-password "
227-/usr/lib/snapd/snap-bootstrap initramfs-mounts | sed "s/^/$cmd/" > /root/bootstrap.cmds.$1
228-set +e
229-. /root/bootstrap.cmds.$1
230-set -e
231+pass=0
232+while true; do
233+ needed="$(/usr/lib/snapd/snap-bootstrap initramfs-mounts)"
234+ if [ -z "$needed" ]; then
235+ break
236+ fi
237+ echo "$needed" | sed "s/^/$cmd/" > "/root/bootstrap.cmds.$pass"
238+ set +e
239+ . /root/bootstrap.cmds.$pass
240+ set -e
241+ pass=$((pass + 1))
242+done
243
244 mkdir -p /run/systemd/system/initrd-fs.target.d
245 cat >/run/systemd/system/initrd-fs.target.d/core.conf <<EOF

Subscribers

People subscribed via source and target branches