By: Andrey (andrey.semashev.delete@this.gmail.com), September 21, 2022 3:45 am
Room: Moderated Discussions
Adrian (a.delete@this.acm.org) on September 20, 2022 8:44 pm wrote:
> Andrey (andrey.semashev.delete@this.gmail.com) on September 20, 2022 9:35 am wrote:
> > Adrian (a.delete@this.acm.org) on September 20, 2022 7:23 am wrote:
> > >
> > > I have never used Debian, but in many Linux distributions you can make a directory, mount there /proc, /sys
> > > and /dev, chroot into it and install there the same Linux
> > > distribution or another one, and also install there
> > > whatever packages you want and test them or use them without modifying in any way your base system.
> >
> > It's not as simple as that. You need /etc, /bin, /usr and /var (at least major parts of them) to
> > be able to run shell, basic shell tools like grep/sed/python/etc. and apt, which also requires network
> > to work. Since you're going to install packages and you don't want to affect the host system, those
> > directories must not be mounts but rather different copies or something like overlayfs.
> >
> > There is a pbuilder tool (or cowbuilder flavor of it) that prepares an environment image automatically,
> > but it is better suited for building packages, not for interactive development.
> >
>
>
> In my experience, it is actually as simple as that.
>
> Maybe there are Linux distributions with weirder requirements, but on all that I
> have used (I never use systemd), it is enough to do this sequence of commands:
>
>
> mkdir /home/user/test_dir
> cd /home/user/test_dir
> mkdir dev etc root proc sys
>
> mount -t proc none proc
> mount --rbind /sys sys
> mount --rbind /dev dev
> cp /etc/resolv.conf etc
>
> env -i HOME=/root TERM=$TERM /bin/chroot . bash -l
>
>
> Copying resolv.conf from the host Linux system is enough to make networking work.
Nope, doesn't work for me:
/usr/sbin/chroot: failed to run command 'bash': No such file or directory
As I said, bash needs to be runnable within the new root. Same with any other program you want to run in the chroot environment.
> Andrey (andrey.semashev.delete@this.gmail.com) on September 20, 2022 9:35 am wrote:
> > Adrian (a.delete@this.acm.org) on September 20, 2022 7:23 am wrote:
> > >
> > > I have never used Debian, but in many Linux distributions you can make a directory, mount there /proc, /sys
> > > and /dev, chroot into it and install there the same Linux
> > > distribution or another one, and also install there
> > > whatever packages you want and test them or use them without modifying in any way your base system.
> >
> > It's not as simple as that. You need /etc, /bin, /usr and /var (at least major parts of them) to
> > be able to run shell, basic shell tools like grep/sed/python/etc. and apt, which also requires network
> > to work. Since you're going to install packages and you don't want to affect the host system, those
> > directories must not be mounts but rather different copies or something like overlayfs.
> >
> > There is a pbuilder tool (or cowbuilder flavor of it) that prepares an environment image automatically,
> > but it is better suited for building packages, not for interactive development.
> >
>
>
> In my experience, it is actually as simple as that.
>
> Maybe there are Linux distributions with weirder requirements, but on all that I
> have used (I never use systemd), it is enough to do this sequence of commands:
>
>
> mkdir /home/user/test_dir
> cd /home/user/test_dir
> mkdir dev etc root proc sys
>
> mount -t proc none proc
> mount --rbind /sys sys
> mount --rbind /dev dev
> cp /etc/resolv.conf etc
>
> env -i HOME=/root TERM=$TERM /bin/chroot . bash -l
>
>
> Copying resolv.conf from the host Linux system is enough to make networking work.
Nope, doesn't work for me:
/usr/sbin/chroot: failed to run command 'bash': No such file or directory
As I said, bash needs to be runnable within the new root. Same with any other program you want to run in the chroot environment.