X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=mount-latest-subvol;h=93a085a8e20e764e85d43153480f1a58b924507d;hb=ad6ea16ea6f2a8676527257fb6afb659f2cee475;hp=bbcf69bd124ab967a45c589413d4e9c24f601811;hpb=fa5deaee2e0182ddfc7b39eea7ee2acedb259ddf;p=distro-setup diff --git a/mount-latest-subvol b/mount-latest-subvol index bbcf69b..93a085a 100644 --- a/mount-latest-subvol +++ b/mount-latest-subvol @@ -28,8 +28,8 @@ Usage: ${0##*/} [OPTIONS] -v|--verbose Be more verbose -Note, at source location, intentionally not executable, run and read -install-my-scripts. +Note: In git this is not not executable because it's meant to be installed +using ./install-my-scripts Note: Uses util-linux getopt option parsing: spaces between args and options, short options can be combined, options before args. @@ -37,6 +37,8 @@ EOF exit $1 } +all_vols=(q a o i ar qr) + tu() { while read -r line; do @@ -132,6 +134,7 @@ umount-kill() { } # duplicated in check-subvol +# Reassign $1 var from /dev/dm- to corresponding /dev/mapper/ mapper-dev() { local mapdev local -n devref=$1 @@ -185,8 +188,15 @@ if [[ -e /mnt/root/root2-fstab ]]; then mnt /mnt/boot2 fi +do_o=true root_dev=$(awk '$2 == "/" {print $1}' /etc/mtab) mapper-dev root_dev +o_dev=$(awk '$2 == "/mnt/o" {print $1}' /etc/mtab) +mapper-dev o_dev + +if [[ $o_dev == "$root_dev" ]]; then + do_o=false +fi # root2_dev=$(awk '$2 == "/mnt/root2" {print $1}' /etc/mtab) # mapper-dev root2_dev @@ -198,6 +208,7 @@ 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 mopts=,noauto + do_o=false 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 @@ -232,12 +243,29 @@ $crypt_dev /q btrfs noatime,subvol=q,gid=1000$mopts 0 0 EOF fi -f=(/mnt/root/btrbk/o.*); f=${f[0]} +f=(/mnt/root/btrbk/qr.*); f=${f[0]} +if [[ -e $f ]]; then + fstab </dev/null; then continue @@ -308,10 +336,11 @@ for vol in q a o i; do continue fi - if [[ $vol == q ]]; then - # allow to fail, user might not be logged in - x sudo -u $(id -nu 1000) XDG_RUNTIME_DIR=/run/user/1000 systemctl --user stop arbtt ||: - fi + ## not using arbtt at the moment + # if [[ $vol == q ]]; then + # ## allow to fail, user might not be logged in + # x sudo -u $(id -nu 1000) XDG_RUNTIME_DIR=/run/user/1000 systemctl --user stop arbtt ||: + # fi umount_ret=true unmounted=() for dir in $(echo $d ${binds[*]}\ |tac -s\ ); do @@ -365,7 +394,7 @@ for vol in q a o i; do #pi python-jmespath # dependency of btrfs-snapshots-diff # todo: need python3 port of btrfs-snapshots-diff, py2 no exist on nabia parentid=$(btrfs sub show $leaf | awk '$1 == "Parent" && $2 == "UUID:" {print $3}') - bsubs=(/mnt/root/btrbk/$vol.*) + bsubs=(btrbk/$vol.*) bsub= # go in reverse order as its more likely to be at the end for ((i=${#bsubs[@]}-1; i>=0; i--)); do @@ -430,10 +459,13 @@ for vol in q a o i; do for dir in $d ${binds[@]}; do m mnt $dir done - if [[ $vol == q ]]; then - # maybe this will fail if X is not running - x sudo -u $(id -nu 1000) XDG_RUNTIME_DIR=/run/user/1000 systemctl --user start arbtt ||: - fi + + ## arbtt disabled for now + # if [[ $vol == q ]]; then + # # maybe this will fail if X is not running + # x sudo -u $(id -nu 1000) XDG_RUNTIME_DIR=/run/user/1000 systemctl --user start arbtt ||: + # fi + stale_dir=/nocow/btrfs-stale rm -f $stale_dir/$d done