-
Notifications
You must be signed in to change notification settings - Fork 53
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
Refactor early system mounting #1866
Conversation
d67b798
to
6938616
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1866 +/- ##
==========================================
- Coverage 75.96% 72.39% -3.58%
==========================================
Files 66 68 +2
Lines 6912 7277 +365
==========================================
+ Hits 5251 5268 +17
- Misses 1290 1631 +341
- Partials 371 378 +7 ☔ View full report in Codecov by Sentry. |
c7b5bcc
to
1804b1f
Compare
42243d2
to
43ecf6c
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.
This is nearly impossible to review. 😞
Approving anyways - if it fails, you're the one to fix it 😉
6fb5af6
to
6cd4bd6
Compare
The mount command mounts the system and is meant to run in an initrd to actually mount the root filesystem and use systemd to switch-root into it. It also optionally writes an /etc/fstab file to the newly mounted system so that systemd will mount the system after switching root. The command is used in the new dracut module elemental-rootfs, which will coexist with immutable-rootfs (they are functionally the same) until immutable-rootfs can be deprecated. Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Add tmpfs overlay mount Mounts a tmpfs to /run/elemental/overlay with size= flag set Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Examples use the new elemental-rootfs Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Add persistent overlay mounts Persistent mounts use the /run/elemental/persistent/.state directory to store upper and work dirs. Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Add sentinel files Write sentinel file (active_mode, passive_mode, recovery_mode) to /run/cos or /run/elemental based on which kernel cmdline is used (cos-img/filename or elemental.image) Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Read kernel cmdline for mount This commit adds capabilities to the mount command to read configuration from the kernel cmdline. The supported parameters are: * elemental.disable + rd.cos.disable * elemental.image + cos-img/filename * elemental.oemlabel + rd.cos.oemlabel In the new elemental.image parameter we can specify active|passive|recovery instead of the path to the image. Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Enable recovery booting and reset Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Load env vars Currently supported: * OVERLAY * RW_PATHS * PERSISTENT_STATE_PATHS * PERSISTENT_STATE_BIND Loaded from files (if they exist): * /run/elemental/layout.env * /run/cos/cos-layout.env Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Run rootfs stage inside mount command Since the rootfs stage should be run between mounting the image and mounting the rest of the system I added a call to RunStage that takes care of this and then uses godotenv dependency to actually load /run/elemental/layout.env and /run/cos/cos-layout.env. This means the old way of generating layout files will still work with the new mount-command. The caveat here is that in the current implementation the rootfs stage will run twice, once from the elemental-setup-rootfs service and once from this command. I would say the easiest way forward is to remove the elemental-setup-rootfs when switching to elemental-rootfs as the default mounting module. Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Add persistent bind mounts Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Add block overlay Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Use registry.opensuse.org for example images Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Minor changes to get tests working Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Fsck partitions before mounting Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Fix for fsck Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> More mount tests Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Comment mount example configuration Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Add elemental-setup services to elemental-rootfs The elemental-setup and rootfs features are heavily dependent on each other. This commit copies the elemental-setup feature into elemental-rootfs, and changes the mount-command to actually start the elemental-setup-rootfs service during mount to not run the yip rootfs stage twice. Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> Fix lint goconst Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
58f1a8b
to
314938d
Compare
The features elemental-sysroot, elemental-rootfs and elemental-setup are used for mounting the root filesystem and all overlays. elemental-sysroot is used for mounting state/recovery partition to /run/elemental/state, and then mounting the image from the partition based on kernel parameters. elemental-setup actually runs the different stages of boot using elemental run-stage command. elemental-rootfs runs the 'elemental mount' command to mount tmpfs overlays, persistent overlays and then writes the /etc/fstab to actually mount when pivoting to the new root. Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
This commit goes through the early systemd services run in dracut and adds Wants,Before,Requires to each step to make them run during the correct stage of the bootup (man dracut.bootup). We also change all the /run/cos and /run/initramfs/cos-state to the new /run/elemental and /run/initramfs/elemental-state directories. Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
Tests still use /run/cos, this commit adds back /run/cos/active|passive|recovery_mode files Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
This commit makes the immutable-rootfs module forwards compatible with the other changes in mount, elemental-sysroot and elemental-setup. It uses the new elemental.image and elemental.oemlabel cmdline paramters if found, otherwise falls back to the old parameters and also sets the /run/elemental/active|passive|recovery_mode files. Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
314938d
to
6664c06
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.
Looks good to me
Just some minor comments here and there. Little things I am also fine to address them in follow up PRs, so we make further changes more manageable and reviewable.
ActiveImgFile = "active.img" | ||
PassiveImgFile = "passive.img" | ||
RecoveryImgFile = "recovery.img" | ||
TransitionImgFile = "transition.img" | ||
ActiveImgPath = "/cOS/active.img" |
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.
nit: I think we should rewrite those as
ActiveImgPath = "/cOS/" + ActiveImgFile
Or even consider having only another constant as ImagesPath = "/cOS"
and simple unify both when needed.
- /var | ||
- /etc | ||
- /srv | ||
persistent: |
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.
Where is the persistent block device defined? I think this should be configurable and probably default to our persistent partition so it can be omitted from the config file, but still configurable.
mount: | ||
sysroot: /sysroot # Path to mount system to | ||
write-fstab: true # Write fstab into sysroot/etc/fstab | ||
overlay: |
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 am wondering if this is the right name. I mean if we have persistent
then probably we should have something like transient
or ephemeral
. Otherwise one could think this overlay device setting is for the persistent data.
|
||
# Include utilities required for elemental-setup services, | ||
# probably a devoted dracut module makes sense | ||
inst_multiple -o \ |
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 think this list needs to be revisited, most of this tools are not needed at all. It should only include the tools required for the elemental-rootfs.service, probably none.
declare systemdsystemunitdir=${systemdsystemunitdir} | ||
|
||
inst_multiple \ | ||
mount mountpoint sort rmdir findmnt rsync cut realpath basename lsblk |
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.
same as below, this list feels outdated. Be aware that these might be required to be included to some other module then.
Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
This should fix installer-tests in CI since the /oem might not exist when booting from ISO. Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
160ffd1
to
1b00b6c
Compare
An updated mount command (from #1837).
Adds a new feature/dracut-module
elemental-sysroot
responsible for mounting the correct image as a base.The
elemental-rootfs
feature actually mounts the elemental overlays.This also reworks the kernel parameters used by elemental.
And also starts to move the active|passive|recovery_mode files to /run/elemental with all the overlay and other mounts.
Fixes #1781, #1830