X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=mount-latest-subvol;h=96210c4424907040ae4f284bf88ae330158d977d;hb=90bd397922e7240c41377e7404f79f190bfbc9d8;hp=2ebcca04be243ec5497ce5cc330444c1ed7e9db4;hpb=c0cc9bcf08d865418a403297d83801417e85bfb3;p=distro-setup diff --git a/mount-latest-subvol b/mount-latest-subvol index 2ebcca0..96210c4 100644 --- a/mount-latest-subvol +++ b/mount-latest-subvol @@ -14,6 +14,9 @@ # limitations under the License. # usage: mount-latest-subvol +# +# Note, at source location, intentionally not executable, run and read +# install-my-scripts. cd / [[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@" @@ -86,7 +89,7 @@ pid-check() { for p in ${pids}; do for m in ${my_pids[@]}; do if (( p == m )); then - echo "$0: error: pids to kill includes our pid or a parent" >&2 + echo "$0: error: pids to kill includes our pid or a parent. ps output:" >&2 ps -f -p $p exit 1 fi @@ -126,9 +129,25 @@ fi ret=0 ##### begin setup fstab for subvols we care about ###### -first_root_crypt=$(awk '$2 == "/" {print $1}' /etc/mtab) +root_dev=$(awk '$2 == "/" {print $1}' /etc/mtab) + + +if cryptsetup status $root_dev &>/dev/null; then + crypt_dev=$root_dev +else # if we are in a recovery boot, find the next best crypt device + noauto=,noauto + for dev in $(dmsetup ls --target crypt | awk '{print $1}'); do + dev=/dev/mapper/$dev + if awk '{print $1}' /etc/mtab | grep -Fx $dev &>/dev/null; then + crypt_dev=$dev + break + fi + done +fi + + fstab <