add sanity checks for ROOT DEVICE and ESP

This commit is contained in:
Tobias Powalowski 2023-02-03 07:33:13 +01:00
parent 0446d99b0f
commit b0bf38d4d6

View file

@ -411,6 +411,24 @@ _mkfs() {
_dialog --msgbox "Error mounting ${3}${5}" 0 0 _dialog --msgbox "Error mounting ${3}${5}" 0 0
return 1 return 1
fi fi
# check if /boot exists on ROOT DEVICE
if [[ -z "${_ASK_MOUNTPOINTS}" && "${5}" = "/" && ! -d "${3}${5}/boot" ]]; then
_dialog --msgbox "Error: ROOT DEVICE ${3}${5} does not contain /boot directory." 0 0
_umountall
return 1
fi
# check on /EFI on /efi mountpoint
if [[ -z "${_ASK_MOUNTPOINTS}" && "${5}" = "/efi" && ! -d "${3}${5}/EFI" ]]; then
_dialog --msgbox "Error: EFI SYSTEM PARTITION (ESP) ${3}${5} does not contain /EFI directory." 0 0
_umountall
return 1
fi
# check on /EFI on /boot
if [[ -z "${_ASK_MOUNTPOINTS}" && "${5}" = "/boot" && -n "${_UEFI_BOOT}" && ! $(mountpoint /efi > "${_NO_LOG}") && ! -d "${3}${5}/EFI" ]]; then
_dialog --msgbox "Error: EFI SYSTEM PARTITION (ESP) ${3}${5} does not contain /EFI directory." 0 0
_umountall
return 1
fi
# btrfs needs balancing on fresh created raid, else weird things could happen # btrfs needs balancing on fresh created raid, else weird things could happen
[[ "${2}" == "btrfs" && -n "${4}" ]] && btrfs balance start --full-balance "${3}""${5}" &>"${_LOG}" [[ "${2}" == "btrfs" && -n "${4}" ]] && btrfs balance start --full-balance "${3}""${5}" &>"${_LOG}"
fi fi