[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master b80b1ae 7/7: Experiment with bind mounts
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master b80b1ae 7/7: Experiment with bind mounts |
Date: |
Fri, 4 Oct 2019 19:21:00 -0400 (EDT) |
branch: master
commit b80b1ae2edfabd6eb84a9c2db1320a64085674e8
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Experiment with bind mounts
It takes a little over forty minutes to run 'install_centos.sh'.
Perhaps it would be faster if the host system's /var/cache could
be used for apt and yum inside the (nested) chroots.
---
install_centos.sh | 111 +++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 102 insertions(+), 9 deletions(-)
diff --git a/install_centos.sh b/install_centos.sh
index 0bec8e7..1dee78d 100755
--- a/install_centos.sh
+++ b/install_centos.sh
@@ -44,6 +44,21 @@ rinse --arch amd64 --distribution centos-7 \
--directory /srv/chroot/centos7lmi \
--mirror http://mirror.net.cen.ct.gov/centos/7.7.1908/os/x86_64/Packages \
+# There should be no bind mounts yet:
+findmnt --kernel -n --list | grep '\['
+
+# Now centos has its own cache directory, with subdirectories:
+ls /srv/chroot/centos7lmi/var/cache/yum
+ls /srv/chroot/centos7lmi/var/cache/yum/x86_64/7/
+# There's very little there--perhaps 49272 bytes:
+du -sb /srv/chroot/centos7lmi/var/cache/yum
+
+mkdir -p /var/cache/centos_lmi
+du -sb /var/cache/centos_lmi
+# 'rbind' seems necessary because centos uses subdirs
+mount --rbind /var/cache/centos_lmi /srv/chroot/centos7lmi/var/cache/yum ||
echo "Oops"
+findmnt --kernel -n --list | grep '\['
+
cat >/srv/chroot/centos7lmi/tmp/setup0.sh <<EOF
#!/bin/sh
set -evx
@@ -66,36 +81,55 @@ getent passwd greg || useradd --gid=1000 --groups=greg
--uid=1000 \
mountpoint /dev/pts || mount -t devpts -o rw,nosuid,noexec,relatime,mode=600
devpts /dev/pts
mountpoint /proc || mount -t proc -o rw,nosuid,nodev,noexec,relatime proc
/proc
+du -sb /var/cache/yum
+
yum --assumeyes install ncurses-term zsh
chsh -s /bin/zsh root
chsh -s /bin/zsh greg
+du -sb /var/cache/yum
+
yum --assumeyes install centos-release-scl
yum-config-manager --enable rhel-server-rhscl-7-rpms
+
+du -sb /var/cache/yum
+
yum --assumeyes install devtoolset-8 rh-git218
# In order to use the tools on the three preceding lines, do:
# scl enable devtoolset-8 rh-git218 $SHELL
# and then they'll be available in that environment.
+du -sb /var/cache/yum
+
# Install "EPEL". See:
# https://lists.nongnu.org/archive/html/lmi/2019-09/msg00037.html
yum --assumeyes install ca-certificates curl nss-pem
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
+du -sb /var/cache/yum
+
yum --assumeyes install schroot
# To show available debootstrap scripts:
# ls /usr/share/debootstrap/scripts
+du -sb /var/cache/yum
+
# Install a debian chroot inside this centos chroot.
yum --assumeyes install debootstrap.noarch
mkdir -p /srv/chroot/"${CHRTNAME}"
debootstrap "${CODENAME}" /srv/chroot/"${CHRTNAME}"
http://deb.debian.org/debian/
+
+du -sb /var/cache/yum
+
echo Installed debian "${CODENAME}".
EOF
chmod +x /srv/chroot/centos7lmi/tmp/setup0.sh
schroot --chroot=centos7lmi --user=root --directory=/tmp ./setup0.sh
+du -sb /var/cache/centos_lmi
+du -sb /srv/chroot/centos7lmi/var/cache/yum
+
cp -a ~/.zshrc /srv/chroot/centos7lmi/root/.zshrc
cp -a ~/.zshrc /srv/chroot/centos7lmi/home/greg/.zshrc
@@ -110,13 +144,20 @@ root-groups=root
type=plain
EOF
-mount --bind /var/cache/"${CODENAME}"
/srv/chroot/centos7lmi/var/cache/apt/archives || echo "Oops"
-mount --bind /var/cache/"${CODENAME}"
/srv/chroot/centos7lmi/var/cache/bullseye || echo "Oops"
-# It would also be interesting to ascertain where the centos chroot
-# caches its files: /srv/chroot/centos7lmi/var/cache/yum/x86_64/ seems
-# likely, but is empty? No, wait:
-# #du -sb /srv/chroot/centos7lmi/var/cache/yum
-# 119535116 /srv/chroot/centos7lmi/var/cache/yum
+# This seems to work perfectly:
+mkdir /srv/chroot/centos7lmi/srv/chroot/"${CHRTNAME}"/cache_for_lmi
+mount --bind /srv/cache_for_lmi
/srv/chroot/centos7lmi/srv/chroot/"${CHRTNAME}"/cache_for_lmi || echo "Oops"
+findmnt --kernel -n --list | grep '\['
+
+# At this point, the debian chroot's /var/cache/apt/archives/
+# directory exists, but is empty:
+du -sb /srv/chroot/centos7lmi/srv/chroot/"${CHRTNAME}"/var/cache/apt/archives
+# The host's apt archives contain:
+du -sb /var/cache/"${CODENAME}"
+findmnt --kernel -n --list | grep '\['
+
+mount --bind /var/cache/"${CODENAME}"
/srv/chroot/centos7lmi/srv/chroot/"${CHRTNAME}"/var/cache/apt/archives || echo
"Oops"
+findmnt --kernel -n --list | grep '\['
cat >/srv/chroot/centos7lmi/tmp/setup1.sh <<EOF
#!/bin/sh
@@ -138,8 +179,19 @@ chmod +x lmi_setup_*.sh
. ./lmi_setup_inc.sh
-mkdir -p /var/cache/"${CODENAME}"
-mount --bind /var/cache/"${CODENAME}"
/srv/chroot/"${CHRTNAME}"/var/cache/apt/archives || echo "Oops"
+set -vx
+
+# Just get rid of this stanza?
+# mkdir -p /var/cache/"${CODENAME}"
+# mountpoint /var/cache/apt/archives || mount --bind /var/cache/"${CODENAME}"
/srv/chroot/"${CHRTNAME}"/var/cache/apt/archives || echo "Oops"
+# mountpoint: /var/cache/apt/archives: No such file or directory
+# This stanza (now suppressed) looks like a possible cause of the
+# circular bind mounts demonstrated below (search for "eraseme-findmnt"):
+# + mount --bind /var/cache/bullseye
/srv/chroot/lmi_bullseye_1/var/cache/apt/archives
+
+# At this point, the debian chroot's /var/cache/apt/archives/
+# directory exists, but is empty:
+du -sb /srv/chroot/"${CHRTNAME}"/var/cache/apt/archives
# ./lmi_setup_10.sh
# ./lmi_setup_11.sh
@@ -156,9 +208,50 @@ EOF
chmod +x /srv/chroot/centos7lmi/tmp/setup1.sh
schroot --chroot=centos7lmi --user=root --directory=/tmp ./setup1.sh
+du -sb /srv/chroot/centos7lmi/srv/chroot/"${CHRTNAME}"/var/cache/apt/archives
+du -sb /var/cache/"${CODENAME}"
+findmnt --kernel -n --list | grep '\['
+
stamp1=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo "Finished: $stamp1"
seconds=$(($(date '+%s' -d "$stamp1") - $(date '+%s' -d "$stamp0")))
elapsed=$(date -u -d @"$seconds" +'%H:%M:%S')
echo "Elapsed: $elapsed"
+
+cat >/tmp/eraseme-findmnt <<EOF
+/root[0]#findmnt --kernel -n --list | grep '\[' |sort
+/srv/chroot/centos7lmi/srv/chroot/lmi_bullseye_1/var/cache/apt/archives
/dev/sdb5[/srv/chroot/centos7lmi/var/cache/bullseye] ext4
rw,relatime,errors=remount-ro
+/srv/chroot/centos7lmi/srv/chroot/lmi_bullseye_1/var/cache/apt/archives
/dev/sdb5[/var/cache/bullseye] ext4
rw,relatime,errors=remount-ro
+/var/cache/bullseye
/dev/sdb5[/srv/chroot/centos7lmi/var/cache/bullseye] ext4
rw,relatime,errors=remount-ro
+/root[0]#
+/root[0]#du -sb
/srv/chroot/centos7lmi/srv/chroot/lmi_bullseye_1/var/cache/apt/archives
+593658728
/srv/chroot/centos7lmi/srv/chroot/lmi_bullseye_1/var/cache/apt/archives
+/root[0]#du -sb /srv/chroot/centos7lmi/var/cache/bullseye
+593658728 /srv/chroot/centos7lmi/var/cache/bullseye
+/root[0]#du -sb /var/cache/bullseye
+593658728 /var/cache/bullseye
+/root[0]#
+/root[0]#umount /var/cache/bullseye
+/root[0]#du -sb /var/cache/bullseye
+682609842 /var/cache/bullseye
+/root[0]#
+/root[0]#findmnt --kernel -n --list | grep '\[' |sort
+/srv/chroot/centos7lmi/srv/chroot/lmi_bullseye_1/var/cache/apt/archives
/dev/sdb5[/var/cache/bullseye] ext4 rw,relatime,errors=remount-ro
+/root[0]#du -sb
/srv/chroot/centos7lmi/srv/chroot/lmi_bullseye_1/var/cache/apt/archives
+682609842
/srv/chroot/centos7lmi/srv/chroot/lmi_bullseye_1/var/cache/apt/archives
+/root[0]#du -sb /srv/chroot/centos7lmi/var/cache/bullseye
+593658728 /srv/chroot/centos7lmi/var/cache/bullseye
+/root[0]#
+/root[0]#du -sb
/srv/chroot/centos7lmi/srv/chroot/lmi_bullseye_1/var/cache/apt/archives
+682609842
/srv/chroot/centos7lmi/srv/chroot/lmi_bullseye_1/var/cache/apt/archives
+/root[0]#du -sb /srv/chroot/centos7lmi/var/cache/bullseye
+593658728 /srv/chroot/centos7lmi/var/cache/bullseye
+/root[0]#umount
/srv/chroot/centos7lmi/srv/chroot/lmi_bullseye_1/var/cache/apt/archives
+/root[0]#du -sb
/srv/chroot/centos7lmi/srv/chroot/lmi_bullseye_1/var/cache/apt/archives
+49157474
/srv/chroot/centos7lmi/srv/chroot/lmi_bullseye_1/var/cache/apt/archives
+/root[0]#du -sb /srv/chroot/centos7lmi/var/cache/bullseye
+593658728 /srv/chroot/centos7lmi/var/cache/bullseye
+/root[0]#du -sb /var/cache/bullseye
+682609842 /var/cache/bullseye
+EOF
- [lmi-commits] [lmi] master updated (3f01703 -> b80b1ae), Greg Chicares, 2019/10/04
- [lmi-commits] [lmi] master d8e9f2d 2/7: Install EPEL before schroot: apparently required for centos, Greg Chicares, 2019/10/04
- [lmi-commits] [lmi] master 564f492 5/7: Assume presence of a local file, Greg Chicares, 2019/10/04
- [lmi-commits] [lmi] master 0b88770 3/7: Allow a script to fail, at least for now, Greg Chicares, 2019/10/04
- [lmi-commits] [lmi] master b80b1ae 7/7: Experiment with bind mounts,
Greg Chicares <=
- [lmi-commits] [lmi] master 1777663 1/7: Choose a more distinctive chroot name, Greg Chicares, 2019/10/04
- [lmi-commits] [lmi] master cec4ea5 6/7: Test an alternative to a failing mount command, Greg Chicares, 2019/10/04
- [lmi-commits] [lmi] master 32c2f24 4/7: Temporarily allow a command to fail, Greg Chicares, 2019/10/04