-
Notifications
You must be signed in to change notification settings - Fork 296
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
ostree on Beaglebone Black #2357
Comments
Step one would be to commit your rootfs into an ostree. You will have to adapt it so ostree will deploy it correctly
|
Thanks @wmanley! When it says:
Do I need to ensure my initrd does that? |
I don't know about initrd as I don't use it. See #1401. |
This meta layer https://github.com/advancedtelematic/meta-updater is a good example of OSTree application for full system atomic updates, and this is an example of its utilization in the scope of an end-to-end product https://github.com/foundriesio/lmp-manifest. |
@jallwine for the uEnv.txt, I was sure we had managed the environment variables at Endless, but when I looked closer there wasn't any of that. Apparently we've always just embedded the correct details into u-boot or something like that since we've controlled the hardware. However, since we initially started using ostree, what you can do is populate |
I've taken my first concrete steps towards trying to get an OSTree managed Beaglebone image going. I've posted on the Beaglebone forums about it here: https://forum.beagleboard.org/t/ostree-on-beaglebone-boards/30458 If anyone has any information that could help, I'd appreciate it! |
When you create the initramfs, you need to put the stuff from ostree in it. What the ostree initramfs integration does is run |
That makes sense! Do you know of documentation or an example of this somewhere? I've never had to mess with initramfs. |
It's pretty system dependent, but ostree's initramfs integration is provided by dracut. The way you'd probably do this is |
It sounds like surgery may be necessary. The ostree docs mention switchroot. So I could expand the initramfs and copy that over to it, but how do I ensure it runs? Beaglebone does use systemd, is there some magic that could be done with systemd without dracut? |
Looks like sticking it in /scripts/init-bottom allows it to run. Now I need to dial in what it's supposed to do. |
It booted! I had to insert the switchroot.sh script in between the overlayroot and udev scripts in the ORDER file in /scripts/init-bottom. Making progress... |
Now I need to figure out how to properly mount all the necessary directories. /var seems particularly important to get right as it's one of the few writable locations (and seems to contain other important directories such as /home), so let's start there. The switchroot.ch script I'm using (the original is here) performs a bind mount for /var. I switched out the $sysroot variable for $rootmnt, as that's what I seemed to have access to in the initramfs. Unfortunately, $rootmnt seems to be read only, so the |
Adding a |
I have a symbolic link for /lib directly into the deployment as U-boot is looking for overlay files in /lib/firmware prior to the kernel loading or initramfs. I'd like to link to a location that won't change (or rather will automatically change) when a new deployment is made active. I'm looking for something similar to how the /boot/loader folder is automatically switched to point to /boot/loader.1 or /boot/loader.0. Is there something comparable for the root directory of the active deployment? |
When I boot into the Beaglebone with my makeshift ostree setup, I'm unable to run |
I don't think there is
Sounds like your makeshift setup isn't creating /run/ostree-booted. Why don't you use ostree-prepare-root and ostree-system-generator? https://github.com/ostreedev/ostree/tree/main/src/switchroot |
I think the best practice is that, in the OS image, /var should be an empty mount point. You should have something to populate /var on first boot. For example, systemd-tmpfiles or an init script that copies a default "/var" layout from /usr |
What is your initramfs like? Does it have systemd embedded in it? Something else? What does the initramfs do for you outside of an OSTree system? Why not use dracut? |
I'd be happy to with some instruction. I spliced in the switchroot.sh script into my initramfs, which runs and sets up my root directory such that my system starts, but I don't know how to use the other parts.
I'm not sure how to answer those. I'm not familiar with initramfs, so I'm largely wandering in the dark. I'm doing what I can to adapt existing Beaglebone images to work with an OSTree managed system. Scripts in this repository generate the Beaglebone images. I'm trying to take an existing Beaglebone image and convert it to an image suitable to be managed with OSTree. It doesn't seem like those scripts use dracut. This is the original initramfs and this one is largely the same, but with the switchroot.sh script spliced in (this one is a tar.gz file rather than a cpio archive if that's easier). |
@jallwine If you use dracut, ostree support should come basically for free. Your initramfs looks super custom, and I have no idea how it works. However, no dracut and no systemd. However, you can probably add "touch /run/ostree-booted" somewhere during your boot process (maybe even in switchroot.sh) to fix the "not booted with ostree" error. Or just port to dracut. It seems like you're trying to do just that based on your GitHub activity |
Thanks Adrian! Yeah, I’m giving dracut a shot. My initial test for a regular running system seemed to work fine when I installed dracut and generated the initramfs with it. The version of OSTree on my system, though, wasn’t built with dracut support so I’m going through the process of building it from source and then seeing how it works with the ostree-managed system. I’d like to use well supported tools where possible, so this seems like the better route if I get it working. |
That seems to work flawlessly! I have my system booting up like a regular image. All services seem to start up properly and I'm able to connect like normal. I believe I'm to the point that I need to implement a custom bootloader configuration into ostree. @wmanley, in this thread, you offered to help guide the implementation of a Raspberry Pi bootloader. I believe I need to do the same thing for the Beaglebone. I have a running ostree system with a loader directory that I manually set up (see here). I think those steps need to be performed by |
I could be wrong, but seeing as you have a ostree/src/libostree/ostree-bootloader-uboot.c Lines 56 to 57 in 87db562
|
The official BeagleBone images use a custom version of U-Boot that look for specific variables defined in the uEnv.txt file and expect certain files to be in /boot so I need to make a few extra symlinks to other files and directories. |
It would be nice to be able to run a bash script to help prepare the loader directory rather than implementing everything in C. This would make it a lot more flexible as any language could be used and it would be a lot easier to implement simple things like generating symlinks or parsing a file, etc. |
Thanks @AdrianVovk, that sounds promising, I’ll take a look. |
It looks like I may be able to simply use that bootloader and provide an executable called |
I think you could probably use switchroot.sh like you were trying, but I think it's been unmaintained for a while. So it's likely missing some more recent changes like I also agree with using the u-boot loader provided with ostree. You can optionally provide |
Thanks @dbnicholson! I had success using dracut, so I think I’m going to stick with that. As for the boot loader, I’ll give /usr/lib/ostree-boot/uEnv.txt a shot, but I also need to create a number of symlinks in order for the BeagleBone U-Boot to boot the way a normal image does. I could manually create them after an ostree admin deploy, but ideally, the creation of these links would happen prior to the /boot/loader symlink changing to be as atomic as possible. It sounds like I’ll need a new boot loader configuration that is a combination of the current U-Boot and zipl ones. |
Alternatively, if the loader directory automatically symlinked to the deployment directory (i.e. /boot/loader/deploy symlinked to /ostree/boot.#/STATE_ROOT/CHECKSUM/0) then I could create permanent symlinks in the real /boot and I wouldn’t need a special boot loader configuration. |
I modified the OSTree U-Boot bootloader configuration to check for the existence of a /usr/lib/ostree-boot/setup.sh script and run it if it exists, after writing the uEnv.txt file to the loader directory. This allows the setup script to completely replace the uEnv.txt file if it requires (like in my case). The script is passed the sysroot path, the deployment path and the /boot/loader.# path so any symlinks to various files/directories can be created in the correct locations. https://github.com/PocketNC/ostree/blob/main/src/libostree/ostree-bootloader-uboot.c |
I'm looking into what it would take to use ostree to manage full system atomic updates on Beaglebone boards. The official Beaglebone images for their boards are generated using scripts from this repository: https://github.com/beagleboard/image-builder
They create a root filesystem using debootstrap and apt-get and create a /boot directory where the kernel, initrd, device trees and device tree overlays are placed. A /boot/uEnv.txt file is created with a number of environment variables that specify which device tree to load and which overlays to apply. I'm trying to figure out how to adapt those scripts to make the rootfs and boot process work with ostree. Does anyone have any insights into what needs to happen to make that work?
The text was updated successfully, but these errors were encountered: