-
Notifications
You must be signed in to change notification settings - Fork 29
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
Install in initrd #169
Install in initrd #169
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nitpick - also a question, how much is the initramfs increased with these changes?
Also, maybe expand a little bit the commit message and mention the binaries that are now added to the image, which seem to be:
- cryptsetup
- sfdisk
- partx
- tar
- mkfs.ext4
debian/control
Outdated
@@ -60,7 +60,7 @@ Build-Depends: debhelper-compat (= 12), dh-python, python3:any, dracut-core, qui | |||
squashfs-tools, | |||
snapd (>= 2.50+20.04), | |||
systemd-bootchart, | |||
golang-go, indent, libapparmor-dev, libcap-dev, libfuse-dev, libglib2.0-dev, liblzma-dev, liblzo2-dev, libseccomp-dev, libudev-dev, openssh-client, pkg-config, python3, python3-docutils, python3-markdown, squashfs-tools, tzdata, udev, xfslibs-dev | |||
golang-go, indent, libapparmor-dev, libcap-dev, libfuse-dev, libglib2.0-dev, liblzma-dev, liblzo2-dev, libseccomp-dev, libudev-dev, openssh-client, pkg-config, python3, python3-docutils, python3-markdown, squashfs-tools, tzdata, udev, xfslibs-dev, cryptsetup-bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move cryptsetup-bin
to a different line - the deps on this line come from the time when we had a fork of snap-bootstrap for cloud images, which fortunately is not the case anymore, and afaik were kept intentionally on just one line so they could be removed easily. So actually, hopefully the full line of deps can be dropped now (we can do that in another PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/usr/bin/unsquashfs \ | ||
/usr/lib/snapd/info \ | ||
/usr/lib/snapd/snap-bootstrap \ | ||
/usr/sbin/mkfs.ext4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reformatting this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to reverse logic and use
/run/mnt/data/system-data/var/lib/snapd/modeen
as primary source of truth and only if not accessible to fallback to /proc/cmdline
this will make it also lot easier to address other modes like factory-reset
factory/usr/lib/the-modeenv
Outdated
@@ -5,10 +5,19 @@ cp /sysroot/run/image.fstab /run/ | |||
# TODO:UC20: move this logic into snap-bootstrap to be incorporated with | |||
# initramfs-mounts | |||
|
|||
if grep -q snapd_recovery_mode=run /proc/cmdline; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we not use /run/mnt/ubuntu-data/system-data/var/lib/snapd/modeenv
as primary source of truth?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense.
factory/usr/lib/the-modeenv
Outdated
if grep -q snapd_recovery_mode=run /proc/cmdline; then | ||
run_mode=1 | ||
elif grep -q snapd_recovery_mode=install /proc/cmdline; then | ||
if grep -q mode=run /run/mnt/ubuntu-data/system-data/var/lib/snapd/modeenv; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this condition is too restrictive.
What if snapd_recovery_mode=factory-reset
?
factory/usr/lib/the-modeenv
Outdated
run_mode=1 | ||
fi | ||
fi | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about using this instead:
# Always prefer to use modeevn, if it is available
if [ -e "/run/mnt/data/system-data/var/lib/snapd/modeenv" ]; then
run_mode="$(sed -n 's/mode=\([^[:space:]]*\)/\1/p' /run/mnt/data/system-data/var/lib/snapd/modeenv)"
else
run_mode="$(sed 's/.*snapd_recovery_mode=\([^[:space:]]*\)[[:space:]].*/\1/' /proc/cmdline))"
fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmdline is more complex. It could be the last argument. In 22 branch we have a shell script that properly parses and we can use that there.
I will propose something different tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean /usr/libexec/core/get
?
Yeah in 22 I used
run_mode="$(/usr/libexec/core/get-arg snapd_recovery_mode || true)"
If we can backport that script, of course even better, then you can do
if [ -e "/run/mnt/data/system-data/var/lib/snapd/modeenv" ]; then
run_mode="$(sed -n 's/mode=\([^[:space:]]*\)/\1/p' /run/mnt/data/system-data/var/lib/snapd/modeenv)"
else
run_mode="$(/usr/libexec/core/get-arg snapd_recovery_mode || true)"
fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed it. Take a look.
factory/usr/lib/the-modeenv
Outdated
# Always bind-mount all the host filesystems | ||
mkdir -p /run/mnt/host | ||
echo '/run/mnt/host /host none rbind 0 0' >> /run/image.fstab | ||
if grep -q snapd_recovery_mode=run /proc/cmdline; then | ||
if [ -n "${run_mode-}" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and then using
if [ "${run_mode}" = "run" ]; then
@alfonsosanchezbeato with |
Fwiw, this looks fine to me |
03c4c56
to
047640b
Compare
I have split it into 2 commits. So now the patch show what is added. |
I had to add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just missing /usr/libexec/core/get-mode
file to review.
@@ -5,10 +5,12 @@ cp /sysroot/run/image.fstab /run/ | |||
# TODO:UC20: move this logic into snap-bootstrap to be incorporated with | |||
# initramfs-mounts | |||
|
|||
mode="$(/usr/libexec/core/get-mode mode)" || mode="$(/usr/libexec/core/get-arg snapd_recovery_mode)" || mode="unknown" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this.
I cannot find /usr/libexec/core/get-mode
though. Have you forgot to include it in the commit?
047640b
to
1f2f111
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very clean, thanks! Approving, but please check question.
@@ -8,6 +8,7 @@ ahci | |||
libahci | |||
usb-storage | |||
nls_iso8859-1 | |||
kmod-nls-cp437 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this now? Maybe it should have its own commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is fsck.vfat. I am not totally sure what change required that. But it does make sense since we mount the ESP. Not sure why we did not need it before. I will add some comment.
1f2f111
to
2f3051d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
No description provided.