From 1fe5a7ae888e29627e3d19510b2a2f9c02fb8e52 Mon Sep 17 00:00:00 2001 From: natemaia Date: Sun, 17 May 2020 15:51:20 -0700 Subject: [PATCH] Ask about mounting btrfs subvolumes when skipping formatting --- installer | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/installer b/installer index 9a43365..1a62a6d 100755 --- a/installer +++ b/installer @@ -1057,16 +1057,22 @@ part_mount() mkdir -p "$mntp" - 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" - errshow 0 "mount -o $MNT_OPTS $part $mntp" || return 1 + # 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 - MNT_OPTS='' - mount "$part" "$mntp" > /dev/null 2> "$ERR" - errshow 0 "mount $part $mntp" || return 1 + 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" + errshow 0 "mount -o $MNT_OPTS $part $mntp" || return 1 + else + MNT_OPTS='' + mount "$part" "$mntp" > /dev/null 2> "$ERR" + errshow 0 "mount $part $mntp" || return 1 + fi + msg "Mount Complete" "\nMounted $part at $mntp\n" 1 fi - msg "Mount Complete" "\nMounted $part at $mntp\n" 1 part_countdec "$part" part_cryptlv "$part" return 0 @@ -2469,6 +2475,19 @@ btrfs_name() 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() { 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 mvol="$SUBVOL" - [[ $mntp == "$MNT" ]] && BTRFS_MNT="rootflags=subvol=$mvol" btrfs subvolume create "$mntp/$mvol" > /dev/null 2> "$ERR" errshow 0 "btrfs subvolume create $mntp/$mvol" || return 1 umount_dir "$mntp" || return 1 - select_mntopts "$part" 'btrfs' && [[ $MNT_OPTS ]] && MNT_OPTS+=',' - 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_mount "$part" "$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")"