nuke-graph-directory.sh: Improve subvolume search
This change allows btrfs subvolumes to be found in additional system configurations. The old logic failed to correctly identify subvolumes when the root fs was mounted as a subvolume that was not the btrfs filesystem root. Signed-off-by: Adam Mills <adam@armills.info>
This commit is contained in:
parent
8a8a63aa32
commit
c3aa75c5a7
|
@ -51,13 +51,10 @@ done
|
||||||
|
|
||||||
# now, let's go destroy individual btrfs subvolumes, if any exist
|
# now, let's go destroy individual btrfs subvolumes, if any exist
|
||||||
if command -v btrfs > /dev/null 2>&1; then
|
if command -v btrfs > /dev/null 2>&1; then
|
||||||
root="$(df "$dir" | awk 'NR>1 { print $NF }')"
|
# Find btrfs subvolumes under $dir checking for inode 256
|
||||||
root="${root%/}" # if root is "/", we want it to become ""
|
# Source: http://stackoverflow.com/a/32865333
|
||||||
for subvol in $(btrfs subvolume list -o "$root/" 2>/dev/null | awk -F' path ' '{ print $2 }' | sort -r); do
|
for subvol in $(find "$dir" -type d -inum 256 | sort -r); do
|
||||||
subvolDir="$root/$subvol"
|
( set -x; btrfs subvolume delete "$subvol" )
|
||||||
if dir_in_dir "$subvolDir" "$dir"; then
|
|
||||||
( set -x; btrfs subvolume delete "$subvolDir" )
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue