Ask about mounting btrfs subvolumes when skipping formatting

This commit is contained in:
natemaia 2020-05-17 15:51:20 -07:00
parent 203ae18612
commit 1fe5a7ae88

View File

@ -1057,6 +1057,11 @@ part_mount()
mkdir -p "$mntp" mkdir -p "$mntp"
# skipped formatting on existing btrfs partition?
if [[ $fs == 'btrfs' && $BTRFS -eq 0 ]] && yesno "Btrfs Subvolume Mount" "\nDo you have a subvolume on $part that should be mounted at $mntp?\n"; then
btrfs_name "\nEnter the name of initial subvolume on $part to be mounted at $mntp.\n\ne.g. mount -o subvol=YOUR_SUBVOL $part $mntp\n" || return 1
btrfs_mount "$part" "$mntp" "$SUBVOL" || return 1
else
if [[ $BTRFS -ne 2 && $fs && ${FS_OPTS[$fs]} && $part != "$BOOT" && $part != "$AUTO_ROOT" ]] && select_mntopts "$part" "$fs"; then if [[ $BTRFS -ne 2 && $fs && ${FS_OPTS[$fs]} && $part != "$BOOT" && $part != "$AUTO_ROOT" ]] && select_mntopts "$part" "$fs"; then
mount -o $MNT_OPTS "$part" "$mntp" > /dev/null 2> "$ERR" mount -o $MNT_OPTS "$part" "$mntp" > /dev/null 2> "$ERR"
errshow 0 "mount -o $MNT_OPTS $part $mntp" || return 1 errshow 0 "mount -o $MNT_OPTS $part $mntp" || return 1
@ -1065,8 +1070,9 @@ part_mount()
mount "$part" "$mntp" > /dev/null 2> "$ERR" mount "$part" "$mntp" > /dev/null 2> "$ERR"
errshow 0 "mount $part $mntp" || return 1 errshow 0 "mount $part $mntp" || return 1
fi fi
msg "Mount Complete" "\nMounted $part at $mntp\n" 1 msg "Mount Complete" "\nMounted $part at $mntp\n" 1
fi
part_countdec "$part" part_countdec "$part"
part_cryptlv "$part" part_cryptlv "$part"
return 0 return 0
@ -2469,6 +2475,19 @@ btrfs_name()
return 0 return 0
} }
btrfs_mount()
{
local part="$1"
local mntp="$2"
local subvol="$3"
[[ $mntp == "$MNT" ]] && BTRFS_MNT="rootflags=subvol=$subvol"
select_mntopts "$part" 'btrfs' && [[ $MNT_OPTS ]] && MNT_OPTS+=','
mount -o ${MNT_OPTS}subvol="$subvol" "$part" "$mntp" 2> "$ERR"
errshow 0 "mount -o ${MNT_OPTS}subvol=$subvol $part $mntp" || return 1
msg "Mount Complete" "\nMounted $part subvol=$subvol at $mntp\n" 1
}
btrfs_subvols() btrfs_subvols()
{ {
local part="$1" local part="$1"
@ -2477,15 +2496,11 @@ btrfs_subvols()
btrfs_name "\nEnter a name for the initial subvolume on $part e.g. 'subvol_root'." || return 1 btrfs_name "\nEnter a name for the initial subvolume on $part e.g. 'subvol_root'." || return 1
mvol="$SUBVOL" mvol="$SUBVOL"
[[ $mntp == "$MNT" ]] && BTRFS_MNT="rootflags=subvol=$mvol"
btrfs subvolume create "$mntp/$mvol" > /dev/null 2> "$ERR" btrfs subvolume create "$mntp/$mvol" > /dev/null 2> "$ERR"
errshow 0 "btrfs subvolume create $mntp/$mvol" || return 1 errshow 0 "btrfs subvolume create $mntp/$mvol" || return 1
umount_dir "$mntp" || return 1 umount_dir "$mntp" || return 1
select_mntopts "$part" 'btrfs' && [[ $MNT_OPTS ]] && MNT_OPTS+=',' btrfs_mount "$part" "$mntp" "$mvol" || return 1
mount -o ${MNT_OPTS}subvol="$mvol" "$part" "$mntp" 2> "$ERR"
errshow 0 "mount -o ${MNT_OPTS}subvol=$mvol $part $mntp" || return 1
msg "Mount Complete" "\nMounted $part subvol=$mvol at $mntp\n" 1
btrfs_extsubvols "$mntp" "$mvol" || return 1 btrfs_extsubvols "$mntp" "$mvol" || return 1
msg "Btrfs Setup" "\nSubvolume(s) created successfully.\n\nSubvolume root '$mvol' mounted at $mntp\n$([[ $SUBVOL_COUNT -gt 0 ]] && ls -R "$mntp")" msg "Btrfs Setup" "\nSubvolume(s) created successfully.\n\nSubvolume root '$mvol' mounted at $mntp\n$([[ $SUBVOL_COUNT -gt 0 ]] && ls -R "$mntp")"