Skip to content

Simplify booting from block devices #384

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nohajc
Copy link
Contributor

@nohajc nohajc commented Aug 5, 2025

I had an idea how to simplify booting from block devices. Since init.krun is a virtual file implemented in the virtiofs passthrough module, we'd normally have to manually copy it to the device from which we want to boot and also adjust kernel cmdline to override the default root settings.

Instead, if krun_set_root() was never called but there is a block device, we can still create a dummy rootfs just for executing init and then switch to the real root with a similar mechanism initramfs would use.

This relies on setting KRUN_BLOCK_ROOT environment variable (internally) as well as reading /proc/filesystems so we can implement the behavior of mount -t auto for the real root.

I also added another custom ioctl which I use for cleaning up the temporary root when no longer needed.

@nohajc nohajc force-pushed the krun-image-root branch 2 times, most recently from 1f5c68f to c769d7b Compare August 5, 2025 18:40
@nohajc nohajc marked this pull request as draft August 5, 2025 18:50
@nohajc
Copy link
Contributor Author

nohajc commented Aug 5, 2025

Hmm, just realized /dev/vda might not be the best default and we'll need a way to configure it anyway. Also @ggoodman is working on something similar (#346).

@mtjhrc
Copy link
Collaborator

mtjhrc commented Aug 6, 2025

Really cool idea! I'm not sure if we want this enabled implicitly though. Perhaps you could add another API function, something like krun_set_root_disk_remount(ctx_id, "/dev/vda") that enables this functionality and also allows for configuring the disk?

@nohajc
Copy link
Contributor Author

nohajc commented Aug 6, 2025

Sounds good. Perhaps the function could also take the filesystem type (with the auto type accepted too) and other mount options?

@mtjhrc
Copy link
Collaborator

mtjhrc commented Aug 6, 2025

Sounds good. Perhaps the function could also take the filesystem type (with the auto type accepted too) and other mount options?

Sure, sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants