Fix: error in select_filesystem

This commit is contained in:
natemaia 2020-05-14 11:25:10 -07:00
parent 340f6c6aec
commit b7e6c053e1

View File

@ -5,7 +5,7 @@
# Some ideas and code reworked from other resources
# AIF, Calamares, and the Arch Wiki.. Credit where credit is due
# shellcheck disable=SC2086,SC2046,SC2254
# shellcheck disable=SC2086,SC2046,SC2254,SC2164
VER=2.1.49
@ -1013,7 +1013,7 @@ part_swap()
chmod 600 "$swp" 2> "$ERR"
errshow 0 "chmod 600 '$swp'"
else
msg "Swap Setup" "\nActivating swap partition $(part_pretty "$SWAP")\n" 1
msg "Swap Setup" "\nActivating swap partition $SWAP\n" 1
fi
mkswap "$swp" > /dev/null 2> "$ERR"
errshow 0 "mkswap '$swp' > /dev/null"
@ -1026,7 +1026,7 @@ part_mount()
{
local part="$1"
local mntpt="${MNT}$2"
local ignore=''
local ignore=0
[[ $part == "$ROOT" && $3 ]] && ignore=$3
local fs
fs="$(lsblk -lno FSTYPE "$part")"
@ -1041,9 +1041,14 @@ part_mount()
errshow 0 "mount '$part' '$mntpt' > /dev/null" || return 1
fi
msg "Mount Complete" "\n$(part_pretty "$part") mounted at $mntpt\n" 1
if grep -q "$mntpt" /proc/mounts; then
msg "Mount Success" "\n$part mounted at $mntpt\n" 1
part_countdec "$part"
part_cryptlv "$part"
else
msg "Mount Failed" "\nUnable to mount $part at $mntpt\n" 2
return 1
fi
return 0
}
@ -1089,9 +1094,9 @@ part_format()
local delay="$3"
shift 3
msg "File System Format" "\nFormatting\n\npart: $(part_pretty "$part")\n\nfs: $fs\n" 0
msg "File System Format" "\nFormatting $part as $fs\n" 0
mkfs.$fs ${FS_CMD_FLAGS[$fs]} "$part" > /dev/null 2> "$ERR"
errshow 0 "mkfs.$fs ${FS_CMD_FLAGS[$fs]} '$part' > /dev/null" || return 1
errshow 0 "mkfs.$fs ${FS_CMD_FLAGS[$fs]} '$part'" || return 1
sleep "$delay"
}
@ -1283,7 +1288,7 @@ select_boot()
local fs
fs="$(fsck -N "$BOOT")"
if ([[ $SYS == 'BIOS' ]] && grep -q 'ext[34]' <<< "$fs") || ([[ $SYS == 'UEFI' ]] && grep -q 'fat' <<< "$fs"); then
yesno "Format Boot Partition" "\nIMPORTANT: $(part_pretty "$BOOT") $_format" "Format" "Don't Format" 1 || return 0
yesno "Format Boot Partition" "\nIMPORTANT: $BOOT $_format" "Format" "Do Not Format" 1 || return 0
fi
case "$SYS" in
@ -1337,7 +1342,7 @@ select_root()
select_filesystem "$ROOT" || return 1
part_mount "$ROOT" "" $BTRFS || return 1
if (( BTRFS == 2 )); then
btrfs_subvols "" "$ROOT" || return 1
btrfs_subvols "$ROOT" || return 1
fi
fi
# should never reach here unless an error occurred
@ -1412,7 +1417,7 @@ select_extra()
break
elif select_filesystem "$part" && select_mountpoint && part_mount "$part" "$EXMNT" $BTRFS; then
if (( BTRFS == 2 )); then
btrfs_subvols "$EXMNT" "$part" || return 1
btrfs_subvols "$part" "$EXMNT" || return 1
fi
EXMNTS+="$part: $EXMNT "
[[ $EXMNT == '/usr' && $HOOKS != *usr* ]] && HOOKS+=" usr"
@ -1451,19 +1456,18 @@ select_filesystem()
local part="$1"
local fs=''
local cur txt pt
pt="$(part_pretty "$part")"
cur="$(lsblk -lno FSTYPE "$part" 2> /dev/null)"
txt="\nSelect which file system to use\n\npart: $pt\n\nfs default: ext4"
txt="\nSelect which file system to use for $part\n\ndefault: ext4"
if [[ $cur ]]; then
txt+="\nCurrent: $cur"
txt+="\nexisting: $cur"
# bail early if the partition was created in part_auto()
[[ $part == "$AUTO_ROOT" ]] && return 0
fi
BTRFS=0
until [[ $fs ]]; do
dlg fs menu "File System" "$txt" $([[ $cur ]] && printf "skip 'Do not format the current partition'") \
dlg fs menu "File System" "$txt" $([[ $cur ]] && printf 'skip -') \
ext4 "The evolution of the most used Linux file system, successor to Ext3" \
ext3 "Third extended file system, successor to Ext2" \
ext2 "Second extended file system, unlike 3/4 it is not journaled and obsolete" \
@ -1477,7 +1481,7 @@ select_filesystem()
reiserfs "Journaled file system created by a team at Namesys led by Hans Reiser" || return 1
[[ $fs == 'skip' ]] && return 0
yesno "File System" "\nConfirm Format\n\npart: $pt\n\nfs: $fs\n" || fs=''
yesno "File System" "\nFormat $part as $fs?\n" || fs=''
if [[ $fs == 'f2fs' ]]; then
modprobe f2fs
@ -2377,48 +2381,70 @@ btrfs_name()
btrfs_subvols()
{
local mntp="$1"
local part="$2"
local part="$1"
local mntp="$2"
local list=""
local opts=''
local n=1
local txt="\nEnter a name for the initial subvolume.\n\nOnce mounted other subvolumes created for"
MVOL=""
btrfs_name "$txt ${mntp:-/} will branch from it." "" || return 1
MVOL="$SUBVOL"
[[ -z $mntp ]] && BTRFS_MNT="rootflags=subvol=$MVOL"
if [[ $mntp ]]; then
mkdir -p "${MNT}$mntpt" || return 1
cd "$MNT${mntp}" 2> "$ERR"
errshow 0 "cd $MNT${mntp}" || return 1
else
BTRFS_MNT="rootflags=subvol=$MVOL"
fi
# create the main subvolume
mkdir -p "${MNT}$mntpt" || return 1
cd "${MNT}$mntp" || return 1
btrfs subvolume create $MVOL 2> "$ERR"
btrfs subvolume create "$MVOL" > /dev/null 2> "$ERR"
errshow 0 "btrfs subvolume create $MVOL" || return 1
cd / && umount "$part" 2> "$ERR"
errshow 0 "cd / && umount $part" || return 1
cd 2> "$ERR"
errshow 0 "cd" || return 1
umount "$part" 2> "$ERR"
errshow 0 "umount $part" || return 1
if select_mntopts 'btrfs' && [[ $MNT_OPTS ]]; then
mount -o ${MNT_OPTS},subvol=${MVOL} "$part" "$MNT${mntp}" 2> "$ERR"
errshow 0 "mount -o ${MNT_OPTS},subvol=${MVOL} $part $MNT${mntp}" || return 1
opts="${MNT_OPTS},subvol=${MVOL}"
else
mount -o subvol=${MVOL} "$part" "$MNT${mntp}" 2> "$ERR"
errshow 0 "mount -o subvol=${MVOL} $part $MNT${mntp}" || return 1
opts="subvol=${MVOL}"
fi
if [[ $mntp ]]; then
mount -o $opts "$part" "$MNT${mntp}" 2> "$ERR" || mount -o $opts "$part" "$MNT${mntp}" 2> "$ERR"
errshow 0 "mount -o $opts $part $MNT${mntp}" || return 1
grep -q "$MNT${mntp}" /proc/mounts || { msg "Mount Failed" "\nUnable to mount $part at $MNT${mntp}\n" 2; return 1; }
msg "Mount Complete" "\nSubvolume $MVOL mounted at $MNT${mntp}\n" 1
else
mount -o $opts "$part" "$MNT" 2> "$ERR" || mount -o $opts "$part" "$MNT" 2> "$ERR"
errshow 0 "mount -o $opts $part $MNT" || return 1
grep -q "$MNT" /proc/mounts || { msg "Mount Failed" "\nUnable to mount $part at $MNT\n" 2; return 1; }
msg "Mount Complete" "\nSubvolume $MVOL mounted at $MNT\n" 1
fi
cd "$MNT${mntp}" 2> "$ERR"
errshow 0 "cd $MNT${mntp}" || return 1
# create the subvolume(s)
cd ${MNT}$mntp || return 1
SUBVOL=''
until [[ $SUBVOL == '*' ]]; do
local txt="\nEnter a name for the subvolume $n to create within $MVOL."
txt+="\n\nThis process will be repeated until an asterisk (*) subvolume name is entered."
local txt="\nEnter a name for subvolume $n within '$MVOL' subvolume."
txt+="\n\nThis process will be repeated until an asterisk (*) is entered as the subvolume name."
btrfs_name "$txt\n\nCreated subvolumes: ${list:-none}\n" "$list" || return 1
btrfs subvolume create $SUBVOL 2> "$ERR"
btrfs subvolume create $SUBVOL > /dev/null 2> "$ERR"
errshow 0 "btrfs subvolume create $SUBVOL" || return 1
(( n++ ))
list+="$SUBVOL "
done
msg "Btrfs Setup Complete" "\nBtrfs subvolumes:\n\n$(ls)"
cd / || return 1
cd 2> "$ERR"
errshow 0 "cd" || return 1
}
###############################################################################