Created
June 7, 2017 22:31
-
-
Save mika/166940cb886ca8d5402ddda86ebb8baf to your computer and use it in GitHub Desktop.
grml-chroot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mika@heart /home/grml/git-grml/grml-scripts (git)-[master] % g show 38d2e82 | |
commit 38d2e82165e7962687e5275b4f50fa82343849ed | |
Author: Michael Prokop <mika@grml.org> | |
Date: Wed May 10 15:18:13 2017 +0200 | |
grml-chroot: mount /dev/pts as devpts inside chroot | |
Fixes: | |
| E: Can not write log (Is /dev/pts mounted?) - posix_openpt (2: No such file or directory) | |
diff --git a/usr_sbin/grml-chroot b/usr_sbin/grml-chroot | |
index e9c1ae3..ce7c5ca 100755 | |
--- a/usr_sbin/grml-chroot | |
+++ b/usr_sbin/grml-chroot | |
@@ -55,7 +55,10 @@ function mountit | |
function umount_all | |
{ | |
- for i in $MOUNTED_; do | |
+ # we need to unmount /dev/pts before unmounting /dev, so reverse | |
+ # the list of mountpoints to go through it in the according order | |
+ local reverse=$(echo $MOUNTED_ | awk '{ for (i=NF; i>1; i--) printf("%s ",$i); print $1; }') | |
+ for i in $reverse; do | |
umount "${DEST_}/$i" | |
done | |
} | |
@@ -78,6 +81,10 @@ if (( $# < 1 )); then | |
die "Wrong number of arguments." | |
fi | |
+if ! which awk >/dev/null 2>&1 ; then | |
+ die "No awk binary found, required for execution." | |
+fi | |
+ | |
DEST_="$1"; shift | |
if [ ! -d "$DEST_" ]; then | |
@@ -88,6 +95,7 @@ fi | |
mountit "proc" "proc" | |
mountit "sysfs" "sys" | |
mountit "/dev" "dev" "--bind" | |
+mountit "devpts" "dev/pts" | |
WROTE_DEBIAN_CHROOT="" | |
if [ ! -f "$DEST_"/etc/debian_chroot ]; then |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment