fosslinux / live-bootstrap

Use of a Linux initramfs to fully automate the bootstrapping process
286 stars 26 forks source link

When doing a chroot build, the dev nodes aren’t passed into the bootstrap environment. #447

Closed ajherchenroder closed 1 month ago

ajherchenroder commented 4 months ago

I was testing a chroot build when I noticed that the majority of the /dev nodes were missing. I realized that the host’s nodes aren’t passed through and the bootstrap deliberately doesn’t add them during the bootstrap. I made a quick patch that ungates adding the remaining /dev nodes that I can add as a PR if you want. The question is if this is the correct approach? The other alternative is to mount the host OS’s /dev nodes during a chroot. What’s the team’s thoughts on the best way to go?

ajherchenroder commented 3 months ago

Opened PR 450 to fix this issue.

fosslinux commented 3 months ago

What's the usecase for the /dev nodes in chroot? chroot-like modes, such as bubblewrap, where ${CHROOT} = True, cannot use mknod.

ajherchenroder commented 3 months ago

This came up after the bootstrap completed. I tried to mount a usb stick to the completed bootstrap to move some files onto the system. I was unable to so because there were no dev nodes to mount to. I didn’t have any issues with mknod. It worked just fine in a chroot and I was able to mount the usb stick after making the required changes.

fosslinux commented 3 months ago

In general, I don't think we want to have device nodes created in the chroot - rather, /dev should be mounted into the chroot if someone wanted to have a full set of device nodes in the chroot. (Even in the QEMU/bare metal bootstrap, we use devtmpfs in the final system). @Googulator @stikonas thoughts on this?

Side note: mknod does work fine in a chroot, as you said. However, we have multiple chroot-like ways of running the bootstrap, eg --chroot and --bwrap. All of those set ${CHROOT} = True. With --bwrap, mknod cannot be used. See your CI run on your PR as an example, https://github.com/fosslinux/live-bootstrap/actions/runs/8310544927/job/22743172074?pr=450.

stikonas commented 3 months ago

I would lean towards manually creating device nodes after bootstrap. I've done this recently too on a UEFI only system (without kernel bootstrap as this is not supported yet) and for various reasons I had to set CHROOT = True in this mode (mainly to turn off non-working kernel bootstrap). If I remember correctly, after bootstrap I manually created device nodes.

Also as you say bwrap mode does not even support mknod and bwrap is preferred mode for testing on existing Linux as it is rootless.

ajherchenroder commented 1 month ago

Based on the consensus I will close this issue and take care of it in an “after” script