device entries outside /proc with procfs (for chroot)

From: Martin Cracauer <cracauer_at_cons.org>
Date: Mon, 19 Sep 2005 13:08:10 -0400
I noticed the creation of /dev/ entries outside of /dev doesn't work
anymore.  This is needed for chroot environments, which rely on
/dev/null on a regular basis.

I just created the appended message to freebsd-emulation but what I
suggest doesn't work either.  It seems that even with the right major
and minor device number we won't get a working /dev/null outside of
/dev.

Any suggestions? I think it is required to have some capability for
device entries in chrooted environments.

The only working thing I came up with is this:

mkdir /compat/linux/dev
mkdir /compat/linux/dev-hidden
mount -t devfs devfs /compat/linux/dev-hidden
cd /compat/linux/dev
rm -f null zero
ln -s ../dev-hidden/null .
ln -s ../dev-hidden/zero .

Any ill effects to be expected from this hack?




Here's the first message.  Not that what I suggests does not work, I
just include it for reference.

-- cut here --

/usr/ports/emulators/linux_base/pkg-message 
  recommendes:
> You may wish to create and populate /compat/linux/dev/ if you plan to
> chroot
> into your Linux installation.  For example:
>
>         mkdir /compat/linux/dev
>         mknod /compat/linux/dev/null c 2 2
>         chmod 666 /compat/linux/dev/null


That won't work, as the major and minor device numbers are now a
moving target with devfs.

I think the only decent way to do this now is to have
/etc/rc.conf
LINUX_DEV_NULL="yes"

and then

. /etc/rc.conf
if [ "$LINUX_DEV_NULL" != NO ] ; then # insert proper rc.conf parsing
here
        (
                IFS=" ,"
                set -- `ls -l /dev/null`
                rm -f /compat/linux/dev/null
                mknod /compat/linux/dev/null c $5 $6
                chmod 666 /compat/linux/dev/null
        )
fi


-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer_at_cons.org>   http://www.cons.org/cracauer/
FreeBSD - where you want to go, today.      http://www.freebsd.org/



-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer_at_cons.org>   http://www.cons.org/cracauer/
FreeBSD - where you want to go, today.      http://www.freebsd.org/
Received on Mon Sep 19 2005 - 15:08:12 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:43 UTC