* Use "umount -l" to clean up.
svn path=/nixos/trunk/; revision=33721
This commit is contained in:
parent
5409e76353
commit
b2025c4687
@ -46,28 +46,16 @@ cat /etc/nsswitch.conf > $mountPoint/etc/nsswitch.conf
|
|||||||
|
|
||||||
# Mount some stuff in the target root directory.
|
# Mount some stuff in the target root directory.
|
||||||
mkdir -m 0755 -p $mountPoint/dev $mountPoint/proc $mountPoint/sys $mountPoint/mnt
|
mkdir -m 0755 -p $mountPoint/dev $mountPoint/proc $mountPoint/sys $mountPoint/mnt
|
||||||
mount --bind /dev $mountPoint/dev
|
mount --rbind /dev $mountPoint/dev
|
||||||
mount --bind /proc $mountPoint/proc
|
mount --rbind /proc $mountPoint/proc
|
||||||
mount --bind /sys $mountPoint/sys
|
mount --rbind /sys $mountPoint/sys
|
||||||
mount --rbind / $mountPoint/mnt
|
mount --rbind / $mountPoint/mnt
|
||||||
|
|
||||||
# Note: probably umount -l is enough. It umounts recursive mount points having been mounted by --rbind!
|
|
||||||
# Probably umountUnder can be removed ?
|
|
||||||
umountUnder() {
|
|
||||||
local dir="$1"
|
|
||||||
for i in $(grep -F " $dir" /proc/mounts \
|
|
||||||
| @perl@/bin/perl -e 'while (<>) { /^\S+\s+(\S+)\s+/; print "$1\n"; }' \
|
|
||||||
| sort -r);
|
|
||||||
do
|
|
||||||
umount $i || true
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
umountUnder $mountPoint/mnt
|
umount -l $mountPoint/mnt
|
||||||
umountUnder $mountPoint/dev
|
umount -l $mountPoint/dev
|
||||||
umountUnder $mountPoint/proc
|
umount -l $mountPoint/proc
|
||||||
umountUnder $mountPoint/sys
|
umount -l $mountPoint/sys
|
||||||
}
|
}
|
||||||
|
|
||||||
trap "cleanup" EXIT
|
trap "cleanup" EXIT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user