Repository navigation
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? |
bgilbert
left a comment
There was a problem hiding this comment.
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.)
| } | ||
|
|
||
| fn ensure_mounted_esp(&self) -> Result<()> { | ||
| let mount_point = &Path::new("/").join(MOUNT_PATH); |
There was a problem hiding this comment.
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.
We should probably add PrivateTmp=yes too. (EDIT: already is there)
There was a problem hiding this comment.
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.
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.
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.
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.
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. |
cgwalters
left a comment
There was a problem hiding this comment.
Thanks for working on this!
| } | ||
|
|
||
| fn ensure_mounted_esp(&self) -> Result<()> { | ||
| let mount_point = &Path::new("/").join(MOUNT_PATH); |
There was a problem hiding this comment.
We should probably add PrivateTmp=yes too. (EDIT: already is there)
| } | ||
|
|
||
| fn ensure_mounted_esp(&self) -> Result<()> { | ||
| let mount_point = &Path::new("/").join(MOUNT_PATH); |
There was a problem hiding this comment.
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).
| ReadOnlyPaths=/usr | ||
| PrivateTmp=yes | ||
| PrivateNetwork=yes | ||
| ProtectClock=yes |
There was a problem hiding this comment.
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.
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.
cgwalters
left a comment
There was a problem hiding this comment.
One minor must fix for the crate ref, everything else is optional or can be followup.
Thanks for working on this!
| } | ||
|
|
||
| # Mount the EFI partition at a temporary location. | ||
| tmpefimount=/tmp/efi |
There was a problem hiding this comment.
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.
| use openat_ext::OpenatDirExt; | ||
|
|
||
| use chrono::prelude::*; | ||
| use structopt::lazy_static::lazy_static; |
There was a problem hiding this comment.
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
|
[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 DetailsNeeds 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-SYSTEMif one exists.ProtectClock=yesinbootupd.serviceis preventing the ESP frombeing mounted, remove that for now.