-
Notifications
You must be signed in to change notification settings - Fork 310
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
[merged] ostree-prepare-root as init #403
Conversation
Can one of the admins verify this patch?
|
bot, test pull request |
Awesome stuff. I have this item on my TODO list as well (https://bugreports.qt.io/browse/QTBUG-52758). I can help with testing the patch set on my reference devices. I should have some time for this during the next week. |
@@ -221,16 +220,6 @@ main(int argc, char *argv[]) | |||
|
|||
deploy_path = resolve_deploy_path (root_mountpoint); | |||
|
|||
/* Create a temporary target for our mounts in the initramfs; this will | |||
* be moved to the new system root below. |
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 code was written for a reason in 4f75d4e - are you sure it won't reintroduce that bug?
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 code was written for a reason in 4f75d4e - are you sure it won't reintroduce that bug?
I've pushed a fixup that should fix this but haven't yet tested it explicitly.
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've added a TODO list item to test this.
Your commit messages are excellent and the code style/changes look really good at a high level. What I'm a lot less certain about is whether this is (as you have on your checklist) going to break the initrd case. I'll do some testing with this too myself. (Semi-related; I'm guessing if you're not using an initrd you also don't have a |
The current patch set on systemd+dracut based images results in: |
Maybe it's simplest in the end to basically fork the current |
I think that could result in too much duplicated code - kernel command line parsing, mounting /boot when single partition system, the overlay (ostree admin unlock) handling logic, and etc. |
Verified also the initramfs-less booting, worked seamlessly. |
struct stat stbuf; | ||
|
||
if (argc < 2) | ||
root_mountpoint = "/sysroot"; |
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.
Would it make more sense to have root_mountpoint = "/"
as the default value, when ostree-prepare-root called without args?
I think this kernel command line looks better:
init=/ostree/boot.1/qt-os/aad0fb830ecea8c807dcdbbd93a88c65dd7489bb6532ef48eb3dc19cae3a7b22/0/usr/sbin/ostree-prepare-root
then:
init=/ostree/boot.1/qt-os/aad0fb830ecea8c807dcdbbd93a88c65dd7489bb6532ef48eb3dc19cae3a7b22/0/usr/sbin/ostree-prepare-root /
All the existing code does ostree-prepare-root sysroot/
from initramfs, so it won't be affected.
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.
Would it make more sense to have
root_mountpoint = "/"
as the default value, when ostree-prepare-root called without args?
I've remembered why this wasn't a problem for me. I have a symlink /sysroot -> .
on my rootfs, so this was being resolved to /
.
Also for kernel to be able to use ostree-prepare-root as PID-1, it needs to be a static binary. As you have already mentioned. Further questions are:
|
@gatispaeglis Are you aware of a distribution which supports both initrd and no-initrd that doesn't build from source (i.e. isn't like OpenEmbedded/Buildroot)? At least for my use case (Fedora/CentOS) we're pretty initrd-centric. I guess one could manually set it up with our binaries, but it's not supported by the installer (Anaconda) for example. @wmanley Do you think you can pick up debugging the initrd case? If not, I can probably give it a shot sometime later this week...let me know so we don't conflict. |
Agreed, fixed. |
I haven't because I haven't completed bootloader integration yet. For playing with this I've been booting with init=/bin/bash and running The Tegra TK1 uses u-boot but is configured to boot from an extlinux configuration file in |
I would disagree. There would be a lot of common code between the two, and this will be a pure generalisation. This means that it's more likely to work or behave helpfully for other more exotic configurations, e.g. booting distros that use an initrd but not systemd/dracut. |
I suspected this might be the case. I've reintroduced I'll have to fiddle with the commit messages when squashing at the end. |
{ | ||
perrorv ("Failed to MS_MOVE %s to '%s'", root_mountpoint, destpath); | ||
exit (EXIT_FAILURE); | ||
if (chdir ("/sysroot.tmp") < 0) |
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'm not sure if this chdir
is necessary. I haven't tried this yet. I'd like to remove it if it works without.
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.
My automated test passes without it so I've removed it.
Some data on file sizes built for AMD64 with -O2 and stripped:
|
I've given it a crack, but I haven't had a chance to test it yet. I'm going to have a play around with using |
All these fixups are getting a little silly so I'll do a rebase and push -f unless anyone has any objections? This will be necessary eventually to drop 3d935aa: "ostree-prepare-root: Don't bother creating /sysroot.tmp" |
Agreed it's force push 🔨 time. (Also, note one can't |
With the latest patch set this works as expected.
Checked this as well. The patch does not reintroduce the bug fixed in 4f75d4e.
I had a specific (corner case) use case in mind, but probably this is not relevant for the upstream ostree project. I mentioned "an installer", but maybe my use case is better described as a "converter" - a script that converts OpemEmbedded distro into ostree-based distro. Therefore I wanted to provide statically and dynamically build binaries, but I start to think that I can use a static binary for both - initramfs and initramfs-less booting. |
This was fixed in git 1.8.4. See the release notes:
|
Regarding static linking - this does seem like an obvious use case for musl. I have absolutely no problem with whatever autoconf bits we need for that. |
4d0150f
to
5cbfc82
Compare
I think one more item that needs to be done here to simplify integration with bootloaders includes updating boot/loader/entries/*.conf files. An example of what it currently contains:
When initramfs-* not provided in the tree, assume that booting with
The current workaround with Does this sound reasonable? |
This supports running ostree on embedded platforms without an initrd. Specificially I'm trying to do bringup on an NVidia Tegra based Jetson TK1 dev board.
When trying to read kernel command-line.
Typically we have our ready made-up up root at `/sysroot/ostree/deploy/.../` (`deploy_path`) and the real rootfs at `/sysroot` (`root_mountpoint`). We want to end up with our made-up root at `/sysroot/` and the real rootfs under `/sysroot/sysroot` as systemd will be responsible for moving `/sysroot` to `/`. We need to do this in 3 moves to avoid trying to move `/sysroot` under itself: 1. `/sysroot/ostree/deploy/...` -> `/sysroot.tmp` 2. `/sysroot` -> `/sysroot.tmp/sysroot` 3. `/sysroot.tmp` -> `/sysroot` This is a refactoring to group all these operations together so I can implement an alternative in terms of `pivot_root`.
...for simplicity. This way we don't need to keep concatenating deploy_path to everything. We can just refer relative to the current working directory. We need to do this after bind-mounting it over itself otherwise our cwd is still on the non-bind-mounted filesystem below.
…d at / This allows ostree-prepare-root outside of the initramfs context where the real rootfs is already mounted at /. We can't use `mount --move` in this case because we would be trying to move / into a subdirectory of itself.
There seemed to be more lower case first letters so I've standardised on that.
af967c5
to
f3f80d8
Compare
Great, thanks for these patches! Looking forward to iterating from here - I may get some time this week to look at #268 |
I'll reuse this for a new ostree-init. Closes: #403 Approved by: cgwalters
This supports running ostree on embedded platforms without an initrd. Specificially I'm trying to do bringup on an NVidia Tegra based Jetson TK1 dev board. Closes: #403 Approved by: cgwalters
When trying to read kernel command-line. Closes: #403 Approved by: cgwalters
Typically we have our ready made-up up root at `/sysroot/ostree/deploy/.../` (`deploy_path`) and the real rootfs at `/sysroot` (`root_mountpoint`). We want to end up with our made-up root at `/sysroot/` and the real rootfs under `/sysroot/sysroot` as systemd will be responsible for moving `/sysroot` to `/`. We need to do this in 3 moves to avoid trying to move `/sysroot` under itself: 1. `/sysroot/ostree/deploy/...` -> `/sysroot.tmp` 2. `/sysroot` -> `/sysroot.tmp/sysroot` 3. `/sysroot.tmp` -> `/sysroot` This is a refactoring to group all these operations together so I can implement an alternative in terms of `pivot_root`. Closes: #403 Approved by: cgwalters
...for simplicity. This way we don't need to keep concatenating deploy_path to everything. We can just refer relative to the current working directory. We need to do this after bind-mounting it over itself otherwise our cwd is still on the non-bind-mounted filesystem below. Closes: #403 Approved by: cgwalters
…d at / This allows ostree-prepare-root outside of the initramfs context where the real rootfs is already mounted at /. We can't use `mount --move` in this case because we would be trying to move / into a subdirectory of itself. Closes: #403 Approved by: cgwalters
There seemed to be more lower case first letters so I've standardised on that. Closes: #403 Approved by: cgwalters
Closes: #403 Approved by: cgwalters
Closes: #403 Approved by: cgwalters
☀️ Test successful - status-atomicjenkins |
@wmanley This is what works well for me. Let me know if you agree with this once your are done with your experimenting. I can do a PR for this, unless you disagree?
|
@gatispaeglis: Go ahead and raise a PR. I think it would be better to discuss this on it's own PR rather than this one :). This particular patch won't work for me because of the hard-coded path to One fix might be to require that I've built ostree and its deps into |
Another downside with this approach would be that whenever Maybe a symlink in |
These commits generalise
ostree-prepare-root
for the purposes of using it to boot Linux for Tegra (Ubuntu 14.04) on the Nvidia Tegra TK1 dev-boards. On the Tegra we don't use an initrd or systemd so the existing way thatostree-prepare-root
is integrated is insufficient.This has required 3 main generalisations. They are mostly separable:
exec
a new init rather thanexit
ing./proc
not having been mounted for the purposes of reading/proc/cmdline
/
rather than/sysroot
by usingpivot_root
where appropriateI'm aware this has been discussed on the mailing list last October.
I do rather like this ostree model. The main ostree binary itself takes advantage of various complex dependencies for it's advanced behaviour, but I can easily build
ostree-prepare-root
statically for boot integration.These changes seem to work well on the device. I've not completed the bootloader integration for this board but I think this work on
ostree-prepare-root
stands for itself.I've opened this PR to gain some early feedback such as:
I'm not sure that this is the workflow that ostree follows but it seemed to be consistent with some of the other PRs open at the moment.
TODO:
overlayfs
integration/sysroot
For future PRs
ostree-prepare-root
as a static binary