aboutsummaryrefslogtreecommitdiff
path: root/release/tools/vmimage.subr
diff options
context:
space:
mode:
authorColin Percival <cperciva@FreeBSD.org>2015-03-30 08:33:19 +0000
committerColin Percival <cperciva@FreeBSD.org>2015-03-30 08:33:19 +0000
commit963412283a1752b3b6f67bb86940c9d166a59e67 (patch)
tree1a1d91ee338a1789f30818991c4df1ceac5046eb /release/tools/vmimage.subr
parentdf62b8a25f4792a6cd788a2b8e9982466b0ebcb3 (diff)
downloadsrc-963412283a1752b3b6f67bb86940c9d166a59e67.tar.gz
src-963412283a1752b3b6f67bb86940c9d166a59e67.zip
Clean up filesystem unmounting in vmimage builds:
* Remove vm_umount_base function which is currently unused. * Add umount_loop function which loops attempting to unmount one filesystem. * Replace calls to umount with calls to umount_loop. * Don't attempt to unmount ${DESTDIR}/dev if it isn't mounted. The looping is necessary because sometimes umount fails due to filesystems being busy. The most common cause of such busyness is periodic(8) jobs running `find / ...`. Reviewed by: gjb
Notes
Notes: svn path=/head/; revision=280840
Diffstat (limited to 'release/tools/vmimage.subr')
-rw-r--r--release/tools/vmimage.subr25
1 files changed, 14 insertions, 11 deletions
diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr
index 828db355aedf..84e718412d31 100644
--- a/release/tools/vmimage.subr
+++ b/release/tools/vmimage.subr
@@ -45,8 +45,10 @@ err() {
}
cleanup() {
- umount ${DESTDIR}/dev 2>/dev/null
- umount ${DESTDIR}
+ if mount | grep -qE "devfs on ${DESTDIR}/dev"; then
+ umount_loop ${DESTDIR}/dev 2>/dev/null
+ fi
+ umount_loop ${DESTDIR}
if [ ! -z "${mddev}" ]; then
mdconfig -d -u ${mddev}
fi
@@ -86,11 +88,11 @@ vm_copy_base() {
tar -cf- -C ${DESTDIR}/old . | tar -xf- -C ${DESTDIR}/new
- umount /dev/${mdold}
+ umount_loop /dev/${mdold}
rmdir ${DESTDIR}/old
mdconfig -d -u ${mdold}
- umount /dev/${mdnew}
+ umount_loop /dev/${mdnew}
rmdir ${DESTDIR}/new
mdconfig -d -u ${mdnew}
mv ${VMBASE}.tmp ${VMBASE}
@@ -117,7 +119,7 @@ vm_install_base() {
mount -t devfs devfs ${DESTDIR}/dev
chroot ${DESTDIR} /usr/bin/newaliases
chroot ${DESTDIR} /etc/rc.d/ldconfig forcestart
- umount ${DESTDIR}/dev
+ umount_loop ${DESTDIR}/dev
cp /etc/resolv.conf ${DESTDIR}/etc/resolv.conf
@@ -152,7 +154,7 @@ vm_extra_install_packages() {
/usr/sbin/pkg bootstrap -y
chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \
/usr/sbin/pkg install -y ${VM_EXTRA_PACKAGES}
- umount ${DESTDIR}/dev
+ umount_loop ${DESTDIR}/dev
return 0
}
@@ -181,16 +183,17 @@ vm_extra_pkg_rmcache() {
return 0
}
-vm_umount_base() {
+umount_loop() {
+ DIR=$1
i=0
sync
- while ! umount ${DESTDIR}/dev ${DESTDIR}; do
+ while ! umount ${DIR}; do
i=$(( $i + 1 ))
if [ $i -ge 10 ]; then
# This should never happen. But, it has happened.
- msg="Cannot umount(8) ${DESTDIR}\n"
- msg="${msg}Something has gone horribly wrong."
- err "${msg}"
+ echo "Cannot umount(8) ${DIR}"
+ echo "Something has gone horribly wrong."
+ return 1
fi
sleep 1
done