Remove partitions too small/big for their use during mounting menus

This commit is contained in:
natemaia 2019-08-18 13:37:49 -07:00
parent 0bc89ae4b2
commit 27eb375570

View File

@ -5,12 +5,11 @@
# Some ideas and code reworked from other resources # Some ideas and code reworked from other resources
# AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due # AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due
VER="2.0.49" # installer version VER="2.0.50" # installer version
DIST="ArchLabs" # linux distributor DIST="ArchLabs" # linux distributor
MNT="/mnt" # install mountpoint MNT="/mnt" # install mountpoint
ANS="/tmp/ans" # dialog answer file ANS="/tmp/ans" # dialog answer file
# ------------------------------------------------------ # # ------------------------------------------------------ #
# When manually mounting your partitions, you need # When manually mounting your partitions, you need
# to set these values to avoid using the mount menu. # to set these values to avoid using the mount menu.
@ -176,7 +175,7 @@ declare -A WM_EXT=(
# files that can be edited after install is complete { # files that can be edited after install is complete {
declare -A EDIT_FILES=( declare -A EDIT_FILES=(
[login]='' # populated once we know the new username and shell [login]='' # login is populated once we know the username and shell
[fstab]='/etc/fstab' [fstab]='/etc/fstab'
[sudoers]='/etc/sudoers' [sudoers]='/etc/sudoers'
[crypttab]='/etc/crypttab' [crypttab]='/etc/crypttab'
@ -189,7 +188,7 @@ declare -A EDIT_FILES=(
[keyboard]='/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard' [keyboard]='/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard'
) # } ) # }
# mkfs command for formatting each offered filesystem { # mkfs command for filesystem formatting {
declare -A FS_CMDS=( declare -A FS_CMDS=(
[f2fs]='mkfs.f2fs' [f2fs]='mkfs.f2fs'
[jfs]='mkfs.jfs -q' [jfs]='mkfs.jfs -q'
@ -203,7 +202,7 @@ declare -A FS_CMDS=(
[reiserfs]='mkfs.reiserfs -q' [reiserfs]='mkfs.reiserfs -q'
) # } ) # }
# mount options for each offered filesystem (if any) { # mount options for each filesystem (if any) {
declare -A FS_OPTS=( declare -A FS_OPTS=(
[vfat]='' # NA [vfat]='' # NA
[ntfs]='' # NA [ntfs]='' # NA
@ -724,7 +723,7 @@ part_menu()
part_device || return 1 part_device || return 1
device="$DEVICE" device="$DEVICE"
while true; do while :; do
choice="" choice=""
if [[ $DISPLAY && $TERM != 'linux' ]] && hash gparted >/dev/null 2>&1; then if [[ $DISPLAY && $TERM != 'linux' ]] && hash gparted >/dev/null 2>&1; then
dlg choice menu "Edit Partitions" "$_part" \ dlg choice menu "Edit Partitions" "$_part" \
@ -1200,13 +1199,22 @@ select_filesystem()
select_efi_partition() select_efi_partition()
{ {
if (( COUNT == 1 )); then local pts size dev isize bsize ptcount=0
BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
elif [[ $AUTO_BOOT_PART ]]; then # walk partition list and skip ones that are too small/big for boot
BOOT_PART="$AUTO_BOOT_PART" while read -r dev size; do
return 0 # were done here size_t="${size: -1:1}" # size type eg. K, M, G, T
isize=${size:0:-1} # remove trailing size type character
isize=${isize%.*} # remove any decimal (round down)
[[ $size_t =~ [KT] || ($size_t == 'G' && $isize -gt 2) || ($size_t == 'M' && $isize -lt 100) ]] || { pts+=$'\n'"$dev $size"; (( ptcount++ )); }
done <<< "$PARTS"
if [[ $AUTO_BOOT_PART ]]; then
BOOT_PART="$AUTO_BOOT_PART"; return 0 # were done here
elif (( ptcount == 1 )); then
BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$pts")"
else else
dlg BOOT_PART menu "EFI Partition" "$_uefi" $PARTS dlg BOOT_PART menu "EFI Partition" "$_uefi" $pts
fi fi
[[ $BOOT_PART ]] || return 1 [[ $BOOT_PART ]] || return 1
@ -1225,13 +1233,23 @@ select_efi_partition()
select_boot_partition() select_boot_partition()
{ {
local pts size dev isize bsize ptcount=0
# walk partition list and skip ones that are too small/big for boot
while read -r dev size; do
size_t="${size: -1:1}" # size type eg. K, M, G, T
isize=${size:0:-1} # remove trailing size type character
isize=${isize%.*} # remove any decimal (round down)
[[ $size_t =~ [KT] || ($size_t == 'G' && $isize -gt 2) || ($size_t == 'M' && $isize -lt 100) ]] || { pts+=$'\n'"$dev $size"; (( ptcount++ )); }
done <<< "$PARTS"
if [[ $AUTO_BOOT_PART && ! $LVM ]]; then if [[ $AUTO_BOOT_PART && ! $LVM ]]; then
BOOT_PART="$AUTO_BOOT_PART"; return 0 # were done here BOOT_PART="$AUTO_BOOT_PART"; return 0 # were done here
elif [[ $LUKS && ! $LVM ]]; then elif [[ $LUKS && ! $LVM ]]; then
dlg BOOT_PART menu "Boot Partition" "$_biosluks" $PARTS dlg BOOT_PART menu "Boot Partition" "$_biosluks" $pts
[[ $BOOT_PART ]] || return 1 [[ $BOOT_PART ]] || return 1
else else
dlg BOOT_PART menu "Boot Partition" "$_bios" "skip" "don't use a separate boot" $PARTS dlg BOOT_PART menu "Boot Partition" "$_bios" "skip" "don't use a separate boot" $pts
[[ -z $BOOT_PART || $BOOT_PART == "skip" ]] && { BOOT_PART=''; return 0; } [[ -z $BOOT_PART || $BOOT_PART == "skip" ]] && { BOOT_PART=''; return 0; }
fi fi
@ -1248,12 +1266,24 @@ select_boot_partition()
select_root_partition() select_root_partition()
{ {
local pts size dev isize bsize ptcount=0
# walk partition list and skip ones that are too small for / (root)
while read -r dev size; do
size_t="${size: -1:1}" # size type eg. K, M, G, T
isize=${size:0:-1} # remove trailing size type character
isize=${isize%.*} # remove any decimal (round down)
[[ $size_t =~ [MK] || ($size_t == 'G' && $isize -lt 4) ]] || { pts+=$'\n'"$dev $size"; (( ptcount++ )); }
done <<< "$PARTS"
if [[ $AUTO_ROOT_PART && -z $LVM && -z $LUKS ]]; then if [[ $AUTO_ROOT_PART && -z $LVM && -z $LUKS ]]; then
ROOT_PART="$AUTO_ROOT_PART" ROOT_PART="$AUTO_ROOT_PART"
elif (( COUNT == 1 )); then part_mount "$ROOT_PART" || { ROOT_PART=''; return 1; }
ROOT_PART="$(awk 'NR==1 {print $1}' <<< "$PARTS")" return 0 # we're done here
elif (( ptcount == 1 )); then # only one available device
ROOT_PART="$(awk 'NR==1 {print $1}' <<< "$pts")"
else else
dlg ROOT_PART menu "Mount Root" "\nSelect the root (/) partition, this is where $DIST will be installed.\n\nDevices smaller than 8G will not be shown here." $PARTS dlg ROOT_PART menu "Mount Root" "\nSelect the root (/) partition, this is where $DIST will be installed.\n\nDevices smaller than 8G will not be shown here." $pts
fi fi
[[ $ROOT_PART ]] || return 1 [[ $ROOT_PART ]] || return 1
@ -1265,10 +1295,16 @@ select_root_partition()
select_extra_partitions() select_extra_partitions()
{ {
local part local part pts size dev isize bsize ptcount=0
while (( COUNT > 0 )); do
# walk partition list and skip ones that are too small to be usable
while read -r dev size; do
[[ ${size: -1:1} =~ [KM] ]] || { pts+=$'\n'"$dev $size"; (( ptcount++ )); }
done <<< "$PARTS"
while (( ptcount > 0 )); do
part='' part=''
dlg part menu 'Mount Extra' "$_expart" 'done' 'finish mounting step' $PARTS || break dlg part menu 'Mount Extra' "$_expart" 'done' 'finish mounting step' $pts || break
if [[ $part == 'done' ]]; then if [[ $part == 'done' ]]; then
break break
elif select_filesystem "$part" && select_mountpoint && part_mount "$part" "$EXMNT"; then elif select_filesystem "$part" && select_mountpoint && part_mount "$part" "$EXMNT"; then
@ -1301,7 +1337,7 @@ install_main()
chrun "chown -Rf $NEWUSER:users /home/$NEWUSER" chrun "chown -Rf $NEWUSER:users /home/$NEWUSER"
sleep 1 sleep 1
while true; do while :; do
dlg choice menu "Finalization" "$_edit" \ dlg choice menu "Finalization" "$_edit" \
finished "exit the installer and reboot" \ finished "exit the installer and reboot" \
keyboard "${EDIT_FILES[keyboard]}" \ keyboard "${EDIT_FILES[keyboard]}" \
@ -1987,7 +2023,7 @@ get_lv_size()
{ {
local txt="${VGROUP}: ${SIZE}$SIZE_UNIT (${VGROUP_MB}MB remaining).$_lvmlvsize" local txt="${VGROUP}: ${SIZE}$SIZE_UNIT (${VGROUP_MB}MB remaining).$_lvmlvsize"
while true; do while :; do
ERR_SIZE=0 ERR_SIZE=0
dlg VOLUME_SIZE input "$_lvmnew (LV:$VOL_COUNT)" "$txt" '' dlg VOLUME_SIZE input "$_lvmnew (LV:$VOL_COUNT)" "$txt" ''
if [[ -z $VOLUME_SIZE ]]; then if [[ -z $VOLUME_SIZE ]]; then
@ -2612,16 +2648,12 @@ msg "Welcome to the $DIST Installer" "\nThis will help you get $DIST setup on yo
select_keymap || { clear; die 0; } select_keymap || { clear; die 0; }
if lspci -vnn -d 14e4: | grep -q 'BCM4352'; then # try to fix problematic broadcom wireless chipset before network check
load_bcm lspci -vnn -d 14e4: | grep -q 'BCM4352' && load_bcm
fi
if ! net_connect; then net_connect || { msg "Not Connected" "\nThis installer requires an active internet connection.\n\nExiting..\n" 2; die 1; }
msg "Not Connected" "\nThis installer requires an active internet connection.\n\nExiting..\n" 2
die 1
fi
while true; do while :; do
select_main select_main
done done