deboostrap of debian guest shows recursive symlnks according to lsof ouput which interferes with unmounting chroot
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
debootstrap (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
This paste expires on 2022-06-22 17:43:10.762812. Remove now. Repaste, or download this paste. Toggle word wrap. Pasted through web.
NOTE: the temporary exit of this script at the line:
' echo "temporary exit to make sure nothing else is screwing it up" && exit '
produces this error:
command: sudo lsof -x +D /root/uml-
lsof: WARNING: can't stat(/root/
lsof: WARNING: can't stat(/root/
Which in turn causes chroots not to fully dismount, leaving proc and sys vulnerable to corruption on deleting the build directory.
#!/bin/bash -x
function aptUpdate_Inner {
DEBIAN_
apt-get update \
-o Dpkg::Options:
-y --allow-downgrades --allow-
}
aptUpdate_Inner
# https:/
logfile=
[ -e ~/"$logfile" ] || rm -rf "$logfile"
exec > >(tee -a "$logfile") 2> >(tee -a "$logfile" >&2)
basedir=
thePrefix=
function finish_Inner_Func {
pushd ~
lsof ~/"$basedir"
echo ~/"$basedir"
lsof ~/"$basedir"
lsof ~/"$basedir"
read -r "Press any key to resume ..."
read -r "Press any key to resume ..."
read -r "Press any key to resume ..."
echo "Trying to clean up Chroots that are left hanging..."
umount ~/"$basedir"
umount ~/"$basedir"
umount ~/"$basedir"
umount ~/"$basedir"
umount ~/"$basedir"
umount --recursive /root/"
umount --recursive /root/"
umount --recursive /root/"$basedir"
umount ~/"$basedir"
pushd ~ || exit
umount ~/"$basedir"
echo ~/"basedir"
lsof ~/"$basedir"
echo ~/"$basedir"
lsof ~/"$basedir"
}
#trap finish_Inner_Func EXIT
function old_kill_proc {
thePrefix=
whatsFound=0
for root_file_Systems in /proc/*/root; do
theLinks=
if [ "$theLinks" != "x" ]; then
if [ "${theLinks:
# this process is in the chroot...
kill -9 "$thePID"
fi
fi
done
if [ "$whatsFound" = "x1" ]; then
while grep -q "$thePrefix" /proc/mounts; do
counters=
if [ "$counters" -ge 20 ]; then
echo "failed to umount $thePrefix"
if [ -x /usr/bin/lsof ]; then
fi
fi
grep "$thePrefix" /proc/mounts | \
cut -d\ -f2 | LANG=C sort -r | xargs -r -n 1 umount || sleep 1
done # repeat the above, the script I'm cargo-culting this from just re-execs itself
fi
}
# -o Dpkg::Options:
function chroot_Function {
success_chroot=0
echo "made it to build root?"
mount --rbind /dev ~/"$basedir"
mount devpts -t devpts --rbind /dev/pts ~/"$basedir"
mount --rbind /proc -t proc ~/"$basedir"
mount --rbind /sys ~/"$basedir"
if ((! success_
printf 'setting up bindings for the chrooot was unsuccessful\n' 1>&2
exit 1
fi
}
if [[ -d ~/"$basedir" ]]
then
printf '%s exists on your filesystem ... removing:\n ' "$basedir" && finish_Inner_Func && mkdir ~/"$basedir"
else
printf 'basedir: does not exist so I will create root %s\n ' "$basedir" && mkdir ~/"$basedir"
fi
#chown -R "$USER:$USER" buster-uml
#chmod a+rwx buster-uml
fallocate -l 2G ~/"$basedir"
mkfs -t ext4 ~/"$basedir"
mkdir ~/"$basedir"
mount -t ext4 ~/"$basedir"
mount -o remount, rw ~/"$basedir"
pushd ~/"$basedir" || printf 'failed to change the directory: /root/ %s \n' ~/"$basedir"
/usr/sbin/
echo "temporary exit to make sure nothing else is screwing it up" && exit
#rsync --verbose --archive --one-file-system --xattrs --hard-links --numeric-ids --sparse --acls buster-uml/ root_fs/
echo '/dev/ubd0 ext4 discard,
#if ! chroot ~/"$basedir"
# printf 'failed to successfully execute the chroot\n' 1>&2
# exit 1
#fi
#if ! source /etc/environment; then
# printf 'failed to source environment\n' 1>&2
# exit 1
#fi
chroot_Function
if ! DEBIAN_
printf 'unable to install apt updates' 1>&2
exit 1
fi
if ! DEBIAN_
printf 'unable to install networking properly\n' 1>&2
exit 1
fi
random_
random_
if ! echo "$random_hostname" > ~/"$basedir"
printf 'failed to install random hostname\n' 1>&2
exit 1
fi
~/"$basedir"
# legacy UML network devices
auto eth0
iface eth0 inet dhcp
# vector UML network devices
auto vec0
iface vec0 inet dhcp
interfaces_EOF
if ! mkdir -p ~/"$basedir"
printf 'failed to create lib modules directory\n' 1>&2
exit 1
fi
#if ! rsync -raHAXS /lib/modules/ ~/"$basedir"
# printf 'rsync was not succesful files not propelry copied to the image file\n' 1>&2
# exit 1
#fi
echo 'End of SCRIPT_Inner...'
finish_Inner_Func
summary: |
deboostrap of debian guest shows recursive symlnks according to lsof - ouput which interfears with unmounting chroot + ouput which interferes with unmounting chroot |
description: | updated |
Never mind, thanks anyway, this bug is caused by mounting /sys and proc for the chroot with --rbind instead of --bind