Re: coreutils-9.6 tests/chroot/chroot-credentials failure

"Bruce Dubbs" ([email protected] via lfs-support Mailing List) <[email protected]> Sat, 2 Aug 2025 13:28:26 -0500
Newsgroups gmane.linux.lfs.support
Message-ID <[email protected]>
On 8/2/25 11:26 AM, Rainer Fiebig ([email protected] via lfs-support Mailing List) wrote:

[snip]

>> I'm using the following script to enter the chroot environment, starting from
>> the LFS partition (of which my LFS system is one root partition and one swap
>> partition) already being mounted and the other filesystems not being mounted:

[snip]

When testing I also have some techniques that I'll share here.  I separate the 
mounting from entering chroot.  Doing that, especially for adding BLFS packages where 
I may want to quickly exit to the host and reenter chroot.

  cat mount-virt.sh
#!/bin/bash

function mountbind
{
    if ! mountpoint $LFS/$1 >/dev/null; then
      $SUDO mount --bind /$1 $LFS/$1
      echo $LFS/$1 mounted
    else
      echo $LFS/$1 already mounted
    fi
}

function mounttype
{
    if ! mountpoint $LFS/$1 >/dev/null; then
      $SUDO mount -t $2 $3 $4 $5 $LFS/$1
      echo $LFS/$1 mounted
    else
      echo $LFS/$1 already mounted
    fi
}

if [ $EUID -ne 0 ]; then
   SUDO=sudo
else
   SUDO=""
fi

if [ x$LFS == x ]; then
   echo "LFS not set"
   exit 1
fi

mountbind dev
mountbind /dev/pts
mounttype proc    proc   proc
mounttype sys     sysfs  sysfs
mounttype run     tmpfs  run

if [ -h $LFS/dev/shm ]; then
   mkdir -pv $LFS/$(readlink $LFS/dev/shm)
else
   mounttype dev/shm tmpfs tmpfs -o nosuid,nodev
fi

mountbind usr/src
mountbind boot
mountbind home
if test -e $LFS/build; then mountbind build; fi
=========

Using this allows rerunning if some directories are already mounted. For my purposes, 
the last four directories are specific to my system.

I also have a similar umount-virt.sh script.

For entering chroot, I just use an alias:

alias lfs='sudo /usr/sbin/chroot /mnt/lfs /usr/bin/env -i HOME=/root TERM="$TERM" 
PS1="\u:\w\\\\$ " PATH=/usr/bin:/usr/sbin /usr/bin/bash --login'

I hope this may be useful.

   -- Bruce

-- 
http://lists.linuxfromscratch.org/sympa/info/lfs-support
Unsubscribe: See the above information page