arch-chroot: warn when chrooting into a non-mountpoint
Amend the --help to explain why this is bad.
This commit is contained in:
parent
c568e9059c
commit
85e73df200
@ -13,6 +13,13 @@ usage: ${0##*/} chroot-dir [command]
|
|||||||
|
|
||||||
If 'command' is unspecified, ${0##*/} will launch /bin/bash.
|
If 'command' is unspecified, ${0##*/} will launch /bin/bash.
|
||||||
|
|
||||||
|
Note that when using arch-chroot, the target chroot directory *should* be a
|
||||||
|
mountpoint. This ensures that tools such as pacman(8) or findmnt(8) have an
|
||||||
|
accurate hierarchy of the mounted filesystems within the chroot.
|
||||||
|
|
||||||
|
If your chroot target is not a mountpoint, you can bind mount the directory on
|
||||||
|
itself to make it a mountpoint, i.e. 'mount --bind /your/chroot /your/chroot'.
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +77,10 @@ shift
|
|||||||
|
|
||||||
[[ -d $chrootdir ]] || die "Can't create chroot on non-directory %s" "$chrootdir"
|
[[ -d $chrootdir ]] || die "Can't create chroot on non-directory %s" "$chrootdir"
|
||||||
|
|
||||||
|
if ! mountpoint "$chrootdir"; then
|
||||||
|
warning "$chrootdir is not a mountpoint. This may have undesirable side effects."
|
||||||
|
fi
|
||||||
|
|
||||||
chroot_setup "$chrootdir" || die "failed to setup chroot %s" "$chrootdir"
|
chroot_setup "$chrootdir" || die "failed to setup chroot %s" "$chrootdir"
|
||||||
chroot_add_resolv_conf "$chrootdir" || die "failed to setup resolv.conf"
|
chroot_add_resolv_conf "$chrootdir" || die "failed to setup resolv.conf"
|
||||||
|
|
||||||
|
1
common
1
common
@ -46,6 +46,7 @@ declare -A fsck_types=([cramfs]=1
|
|||||||
|
|
||||||
out() { printf "$1 $2\n" "${@:3}"; }
|
out() { printf "$1 $2\n" "${@:3}"; }
|
||||||
error() { out "==> ERROR:" "$@"; } >&2
|
error() { out "==> ERROR:" "$@"; } >&2
|
||||||
|
warning() { out "==> WARNING:" "$@"; } >&2
|
||||||
msg() { out "==>" "$@"; }
|
msg() { out "==>" "$@"; }
|
||||||
msg2() { out " ->" "$@";}
|
msg2() { out " ->" "$@";}
|
||||||
die() { error "$@"; exit 1; }
|
die() { error "$@"; exit 1; }
|
||||||
|
Loading…
Reference in New Issue
Block a user