Hi,

Quoting Christoph Groth (2022-09-15 16:31:18)
> Johannes Schauer Marin Rodrigues wrote:
> 
> > Yes. This is because if you just run "mmdebstrap --unshare-helper
> > /usr/sbin/chroot" then it will do nothing else then do a chroot into
> > the given directory. Since you cannot create any device nodes as the
> > unshared user, /dev/null is missing. You can either bind-mound
> > /dev/null and all the other device nodes from the outside yourself or
> > you can use another trick and enter a chroot tarball like this:
> >
> > mmdebstrap --variant=custom --skip=update \
> >     --setup-hook='tar-in chroot.tar /' \
> >     --customize-hook='chroot "$1" bash' \
> >     unstable /dev/null
> 
> Hmm, I tried the above only now and it fails with the following output
> 
> I: automatically chosen mode: unshare

in unshare mode, mknod cannot work. So if you try to "tar-in" a tarball with
device nodes, then you will get that failure. You can remove all entries of the
tarball that are device nodes by puttin mmtarfilter into the pipeline like
this:

mmdebstrap unstable | mmtarfilter --path-exclude='/dev/*' > chroot.tar

> I: chroot architecture amd64 is equal to the host's architecture
> I: automatically chosen format: tar
> I: using /tmp/mmdebstrap.ZYXCWIX0Ip as tempdir
> I: running special hook: tar-in chroot.tar /
> tar: ./dev/console: Cannot mknod: Operation not permitted
> tar: ./dev/full: Cannot mknod: Operation not permitted
> tar: ./dev/null: Cannot mknod: Operation not permitted
> tar: ./dev/ptmx: Cannot mknod: Operation not permitted
> tar: ./dev/random: Cannot mknod: Operation not permitted
> tar: ./dev/tty: Cannot mknod: Operation not permitted
> tar: ./dev/urandom: Cannot mknod: Operation not permitted
> tar: ./dev/zero: Cannot mknod: Operation not permitted
> tar: Exiting with failure status due to previous errors
> E: hookhelper failed: E: tar failed
> E: special hook failed with exit code 512
> I: removing tempdir /tmp/mmdebstrap.ZYXCWIX0Ip...
> 
> The file chroot.tar was created by
> 
>   mmdebstrap unstable chroot.tar
> 
> And the following also works
> 
>   mmdebstrap --customize-hook='chroot "$1" /bin/bash' unstable /dev/null

If you use the "tar-in" method with the automatically selected unshare mode,
then you do not need the device nodes, because they will automatically be
bind-mounted by mmdebstrap once the --customize-hook is run.

You can also read the mmdebstrap man page for "mmtarfilter
--path-exclude='/dev/*'" examples.

Thanks!

cheers, josch

Attachment: signature.asc
Description: signature

Reply via email to