-
Notifications
You must be signed in to change notification settings - Fork 24
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
Ensure ESP is mounted #127
Ensure ESP is mounted #127
Conversation
Kola tests pass with a local FCOS build with coreos/fedora-coreos-config#794. |
9dc090a
to
2359f12
Compare
Hmm, could you expand on this? Why do these conflict? |
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.
Unfortunately there are deeper architectural consequences to having multiple ESPs. Every operation will need to iterate over all ESPs, and cannot assume that the ESPs are all in the same state. (There's a reasonable argument that if the ESPs get desynced, fixing it isn't our responsibility, but it'd be better UX if we handled it anyway.)
src/efi.rs
Outdated
let sysroot = openat::Dir::open("/")?; | ||
let esp = sysroot.sub_dir(&self.esp_path())?; | ||
Ok(esp) | ||
} | ||
|
||
fn ensure_mounted_esp(&self) -> Result<()> { | ||
let mount_point = &Path::new("/").join(MOUNT_PATH); |
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.
Probably we should create a temporary directory to use as a mountpoint, and then clean it up afterward.
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.
We should probably add PrivateTmp=yes
too. (EDIT: already is there)
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.
Yeah if we use PrivateTmp
then we can rely on systemd to clean up our tempdir.
Then I'd use https://docs.rs/tempfile/3.1.0/tempfile/struct.TempDir.html#method.into_path (i.e. make a tempdir, mount on it and then return the path).
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.
What do you think about only updating ESP's that are listed in NVRAM? Non-UEFI is trickier, risky to step on all BIOS Boot or MBR gaps with grub-install.
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.
For CoreOS, at least, we can make some simplifying assumptions. We own the whole system, so we can update every ESP and BIOS Boot partition we see. CoreOS boots via Default Boot Behavior and doesn't set Boot NVRAM variables at all.
If bootupd is going to generalize beyond CoreOS, of course, those assumptions may no longer be workable.
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.
Yep, I'm thinking the idea to rebase Silverblue on CoreOS.
That use case includes dual boot, so I think "fair game" includes overwriting the MBR gap, BIOS Boot, and ESP:/EFI/fedora/
on the drive that contains the current active /
; but not anything else. i.e. EFI/fedora is owned but not the entire ESP. There's a low, but non-zero, chance of USB sticks, SD Cards, external drives or even other internal drives, are present and used to boot another OS; and also can't be touched.
Another possible use case is Silverblue (or Workstation) running from an SD Card or USB stick. It's a use case we're more seriously considering for Workstation as a way to maybe reduce dependency on dual-boot installations.
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.
Right, so far bootupd is Fedora CoreOS specific but the idea from the start is it could generalize indeed to other rpm-ostree systems (i.e. not necessarily coreos-assembler generated) as well as even not rpm-ostree systems (traditional yum/dnf/zypper/apt).
It's still not clear to me that the latter effort is really worth it but I don't want to exclude it.
Admittedly, it was just trial and error. The tests passed when I removed this; otherwise, there were some permission issues. |
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 working on this!
src/efi.rs
Outdated
let sysroot = openat::Dir::open("/")?; | ||
let esp = sysroot.sub_dir(&self.esp_path())?; | ||
Ok(esp) | ||
} | ||
|
||
fn ensure_mounted_esp(&self) -> Result<()> { | ||
let mount_point = &Path::new("/").join(MOUNT_PATH); |
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.
We should probably add PrivateTmp=yes
too. (EDIT: already is there)
src/efi.rs
Outdated
let sysroot = openat::Dir::open("/")?; | ||
let esp = sysroot.sub_dir(&self.esp_path())?; | ||
Ok(esp) | ||
} | ||
|
||
fn ensure_mounted_esp(&self) -> Result<()> { | ||
let mount_point = &Path::new("/").join(MOUNT_PATH); |
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.
Yeah if we use PrivateTmp
then we can rely on systemd to clean up our tempdir.
Then I'd use https://docs.rs/tempfile/3.1.0/tempfile/struct.TempDir.html#method.into_path (i.e. make a tempdir, mount on it and then return the path).
@@ -19,7 +19,6 @@ ProtectHome=yes | |||
ReadOnlyPaths=/usr | |||
PrivateTmp=yes | |||
PrivateNetwork=yes | |||
ProtectClock=yes |
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.
Probably something going wrong in the seccomp policy systemd makes. It's...about time...we looked at that.
0b875d0
to
a4b2255
Compare
|
||
fn ensure_mounted_esp(&self) -> Result<()> { | ||
let mount_point = &Path::new("/").join(&*MOUNT_PATH); | ||
let output = std::process::Command::new("mountpoint") |
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 isn't bad, but now that we know our process is the only one doing the mount (in our mount namespace), I think it'd be better to have a something like Arc<Mutex<Option<PathBuf>>>
or...actually there's a lazy_init crate for that even.
Basically do the tempdir creation + mount as a single locked unit instead.
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.
One minor must fix for the crate ref, everything else is optional or can be followup.
Thanks for working on this!
tests/kola/data/libtest.sh
Outdated
@@ -81,3 +81,10 @@ assert_not_file_has_content_literal () { | |||
done | |||
} | |||
|
|||
# Mount the EFI partition at a temporary location. | |||
tmpefimount=/tmp/efi |
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 know this is just the test suite, but I try as a general rule to avoid predictably named temporary files. We could have this code mirror the main logic and use e.g. $(mktemp -d)
and "return" it by printing, so
callers do e.g.:
tmpefimount=$(mount_tmp_efi)
etc.
Not a blocker, just noting.
src/efi.rs
Outdated
@@ -14,6 +14,7 @@ use anyhow::{bail, Context, Result}; | |||
use openat_ext::OpenatDirExt; | |||
|
|||
use chrono::prelude::*; | |||
use structopt::lazy_static::lazy_static; |
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.
We should add the dependency to Cargo.toml
directly; it looks like a bug that structopt is re-exporting it.
Following coreos/fedora-coreos-config#794, the ESP will no longer be mounted by default in FCOS. Mount the ESP at a directory with a random name in bootupd's sandboxed /tmp ourselves before reading from/writing to it. Note that ESPs on redundant disks is not yet supported, this commit simply mounts the device with part-label `EFI-SYSTEM` if one exists. `ProtectClock=yes` in `bootupd.service` is preventing the ESP from being mounted, remove that for now.
Following coreos/fedora-coreos-config#794, the ESP will no longer be mounted in /boot. Adjust tests to mount it before reading from it.
a4b2255
to
644180e
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cgwalters, kelvinfan001 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Moved the ProtectClock issue to systemd/systemd#18142 |
Following coreos/fedora-coreos-config#794,
the ESP will no longer be mounted by default in FCOS. Mount the
ESP at a directory with a random name in bootupd's sandboxed /tmp
ourselves before reading from/writing to it.
Note that ESPs on redundant disks is not yet supported, this commit
simply mounts the device with part-label
EFI-SYSTEM
if one exists.ProtectClock=yes
inbootupd.service
is preventing the ESP frombeing mounted, remove that for now.