Skip to content
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

Building a full OSv image without running it #1068

Closed
nyh opened this issue Dec 23, 2019 · 0 comments
Closed

Building a full OSv image without running it #1068

nyh opened this issue Dec 23, 2019 · 0 comments

Comments

@nyh
Copy link
Contributor

nyh commented Dec 23, 2019

Building an OSv image - one including the OSv kernel and an application - currently requires running OSv. Both scripts/build and Capstan run the OSv kernel, and utilities stored on its ramdisk - namely /tools/mkfs.so (to create a ZFS filesystem) and /tools/cpiod.so - to create a ZFS filesystem on the image and upload files onto it.

In the back of our minds, we always considered the idea of doing the last step - creating the ZFS filesystem and copying files into it - on the Linux build host, without running an OSv guest at all. But this never worked properly, as demonstrated by issue #918. But now that this issue was fixed, we can return to this idea.

Not running the guest to build the filesystem has several advantages. One is making the image smaller - cpiod.so is no longer as big as it was (see #980) but it's still is over 200KB and we put it twice on each image, and some of the other ZFS stuff in bootfs.manifest.skel and usr.manifest.skel might not be needed any more as well.

The second benefit is speeding up the build of OSv images on machines where running a guest is very slow (e.g., VMs with no support for nested virtualization) or not possible at all (e.g., cross-compilation).

I'm marking this issue as "low priority" because the current approach of scripts/build - i.e., running the guest to uploads files onto it - has been working quite well for years, so we're are in no real rush to replace it.

wkozaczuk added a commit that referenced this issue Jul 8, 2022
This patch makes some incremental improvements to the process
of building ZFS images. However, the main driving force here is
to support building and running ZFS images with the kernel built
with most symbols hidden.

The key missing part to support the above is adding libstdc++.so
to the image so that it can be loaded as needed by cpiod.so and mkfs.so.
However, this would make the loader.elf even larger than the non-hidden
version of it. So instead this patch adds new artifact - zfs_builder.elf
- which is intended to be used by upload_manifest.py only to build ZFS-images.

In essence this patch modifies the main makefile to build new zfs_builder.elf
with bootfs populated with all artifacts necessary to build and load ZFS filesystem
(cpiod.so, mkfs.so, etc). At the same time we drop support of building
kernel.elf which became obsolete in favor of standard loader.elf which
now is even leaner - it does not carry the bootfs footprint with ZFS
building tools. On top of that we optimise the build time of ZFS image
by making it run zfs_builder.elf in QEMU kernel direct mode and VGA
console off that cuts boot time to around 20ms.

At the end of the day we come close to satisfying #1068 - "Building a
full OSv image without running it" - we use new OSv-based build tool zfs_builder.elf
to build final ZFS image - usr.img.

Another benefit of this approach is that we can use some "old"
pre-existing version of zfs_builder.elf (possibly retrieved from github)
to build ZFS image that includes new version of kernel (loader.elf).

Refs #1068
Refs #1186

Signed-off-by: Waldemar Kozaczuk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant