Bug 242955 - kld loading broken inside chroot
Summary: kld loading broken inside chroot
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
Depends on:
Reported: 2019-12-29 11:15 UTC by Edward Tomasz Napierala
Modified: 2021-04-21 11:59 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Edward Tomasz Napierala freebsd_committer 2019-12-29 11:15:22 UTC
It seems loading kernel modules is broken when triggered inside a chroot.  This includes both loading them using kldload(8), and autoloading triggered by eg mount(8).
Comment 1 Conrad Meyer freebsd_committer 2019-12-31 02:24:05 UTC
Why would you want to load kernel modules in a chrooted filesystem namespace?
Comment 2 Edward Tomasz Napierala freebsd_committer 2019-12-31 08:20:45 UTC
Same reason as outside - in my particular case to make “mount -t ext2fs” work.

Note that I’m not talking about loading modules somehow located in a file inside the chroot, I’m talking about triggering the load of the module at its usual, non-chrooted path, from inside the chroot.
Comment 3 commit-hook freebsd_committer 2021-04-21 11:59:27 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=45aec46246fe61a3f45cf7da1c80850dc226f609

commit 45aec46246fe61a3f45cf7da1c80850dc226f609
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-04-21 11:54:29 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2021-04-21 11:54:37 +0000

    rc: make the 'linux' script explicitly load filesystem modules

    This removes a minor annoyance with Linux jails, where you often
    want linux_mounts_enable="NO", yet you want those filesystems
    available for mounting in jails; normally mount(8) would result
    in kernel automatically loading the KLD, but this doesn't work
    inside jails or chroots.

    PR:             242955
    Sponsored By:   EPSRC
    Differential Revision:  https://reviews.freebsd.org/D29725

 libexec/rc/rc.d/linux | 6 ++++++
 1 file changed, 6 insertions(+)