163 lines
4.9 KiB
Plaintext
163 lines
4.9 KiB
Plaintext
module start "disk" "Partition disk"
|
|
|
|
|
|
# find all disks
|
|
declare -A disk_tmp=()
|
|
declare -A disk=()
|
|
index=0
|
|
for i in $(find /dev/disk/by-id/ -type l -printf "%P\n"|grep -v "part" |tac); do
|
|
name="$(readlink -f /dev/disk/by-id/"${i}")"
|
|
if [[ "${name}" =~ *"^[0-9]+$"* ]]; then
|
|
continue
|
|
fi
|
|
if [[ "${name}" == *"dm"* ]]; then
|
|
continue
|
|
fi
|
|
if [[ "${name}" == *"/dev/sr"* ]]; then
|
|
continue
|
|
fi
|
|
# if [[ ! "${i}" == "usb"* ]] && [[ ! "${i}" == "ata"* ]]; then
|
|
# continue
|
|
# fi
|
|
index=$(( index + 1 ))
|
|
size="$(fdisk -l "${name}" | head -n1 | awk '{print $3}')"
|
|
size=$(awk "BEGIN { printf(\"%.0f\n\", ${size}); }")
|
|
size="$(( size - 1 ))"
|
|
disk_tmp+=( [${index}.id]="${i}" [${index}.name]="${name}" [${index}.size]="${size}" )
|
|
done
|
|
disk_tmp+=( [count]="${index}" )
|
|
|
|
# show devices
|
|
echo "Devices:"
|
|
for i in $(seq 1 "${disk_tmp[count]}"); do
|
|
echo "${disk_tmp[${i}.id]}" "${disk_tmp[${i}.name]}" "${disk_tmp[${i}.size]}"
|
|
done
|
|
|
|
# if set device on commandline, use this as default
|
|
if [[ -z "${extern_device}" ]]; then
|
|
device="${disk_tmp[1.id]}"
|
|
else
|
|
device="${extern_device}"
|
|
fi
|
|
|
|
# choose device
|
|
found=""
|
|
while input "Which Device?" "${device}"; do
|
|
test -z "${output}" && output="${default}"
|
|
for i in $(seq 1 "${disk_tmp[count]}"); do
|
|
if [[ "${disk_tmp[${i}.id]}" == "${output}" ]] || [[ "${disk_tmp[${i}.name]}" == "${output}" ]]; then
|
|
found=1
|
|
disk+=( [id]="${disk_tmp[${i}.id]}" )
|
|
disk+=( [name]="${disk_tmp[${i}.name]}" )
|
|
disk+=( [size]="${disk_tmp[${i}.size]}" )
|
|
break
|
|
fi
|
|
done
|
|
[[ "${found}" == "1" ]] && break
|
|
echo "${output} not found"
|
|
done
|
|
|
|
# if there are partitions, show them and warn
|
|
# user choose between exit und wipe
|
|
partitions=""
|
|
index=""
|
|
for i in "$(lsblk -n -l "${disk[name]}" | tail -n +2 | grep part)"; do
|
|
echo "${i}"
|
|
index=$(( index + 1 ))
|
|
done
|
|
|
|
if [[ "${#partitions[@]}" -gt 0 ]]; then
|
|
echo "there are partitions"
|
|
while input "wipe or quit?" "wipe"; do
|
|
case "${output}" in
|
|
w*|*p*|*W*|*P*)
|
|
setconf add wipe "1"
|
|
break
|
|
;;
|
|
q*|*u*|*t*|*Q*|*U*|*T*)
|
|
echo mount / under /mnt
|
|
echo mount /boot under /mnt/boot
|
|
echo mount /home under /mnt/home
|
|
echo create swap
|
|
echo start again with -m
|
|
exit
|
|
;;
|
|
*) echo "please enter wipe or quit"
|
|
;;
|
|
esac
|
|
done
|
|
fi
|
|
|
|
echo "######"
|
|
echo "With Full Disk Encryption the whole disk will be encrypted,"
|
|
echo "including /boot. Unlike Ubuntu."
|
|
echo "If you choose FDE, you have to enter the password for the"
|
|
echo "disc twice, unless you save the key on an usbstick or"
|
|
echo "include it into initramfs."
|
|
echo "If its included, remember: grub only knows us keylayout: no umlauts"
|
|
echo "If you choose to enter once, kernel (/boot) is unencrypted on disk."
|
|
echo "You can turn off encryption."
|
|
echo "######"
|
|
|
|
multiplechoice "fde_key_store" "initramfs" "usb" "once" "twice" "notencrypted"
|
|
|
|
if [[ "${cfg[fde_key_store]}" == "notencrypted" ]]; then
|
|
setconf add "fde_key_store" "none"
|
|
fi
|
|
|
|
if [[ ! "${cfg[fde_key_store]}" == "none" ]]; then
|
|
addpkg "cryptsetup"
|
|
#input_pw "Disk Password"
|
|
output="oem"
|
|
#setconf "add" "diskpw" "${output}"
|
|
cfg+=( [diskpw]="${output}" )
|
|
fi
|
|
|
|
if check yesno "Do you want to hibernate?" "y"; then
|
|
hibernate=1
|
|
setconf "add" "hibernate" "1"
|
|
fi
|
|
|
|
ramsize="$(($(getconf _PHYS_PAGES) * $(getconf PAGE_SIZE) / (1024 * 1024)))"
|
|
ramsize="$(awk "BEGIN { printf(\"%.0f\n\", ${ramsize}/1024); }")"
|
|
|
|
if [[ "${ramsize}" -gt "0" ]] || [[ "${ramsize}" -le "2" ]]; then
|
|
test -z "${hibernate}" && swapsize="$(( ramsize * 2 ))"
|
|
test -z "${hibernate}" || swapsize="$(( ramsize * 3 ))"
|
|
elif [[ "${ramsize}" -gt "2" ]] && [[ "${ramsize}" -le "8" ]]; then
|
|
test -z "${hibernate}" && swapsize="${ramsize}"
|
|
test -z "${hibernate}" || swapsize="$(( ramsize * 2 ))"
|
|
elif [[ "${ramsize}" -gt "8" ]] && [[ "${ramsize}" -le "15" ]]; then
|
|
test -z "${hibernate}" && swapsize="${ramsize}"
|
|
test -z "${hibernate}" || swapsize="$(awk "BEGIN { printf(\"%.0f\n\", ${ramsize}*1.5); }")"
|
|
elif [[ "${ramsize}" -gt "15" ]]; then
|
|
test -z "${hibernate}" && swapsize="4"
|
|
test -z "${hibernate}" || read -p "hibernate not recommended, turning off" empty && hibernate="" && swapsize="4"
|
|
fi
|
|
|
|
setconf "add" "bootsize" "4"
|
|
|
|
echo Configure rootfssize
|
|
while input "Size in G? [$(( disk[size] - swapsize - bootsize ))|rest]" "rest"; do
|
|
test -z "${output}" && output="${default}"
|
|
case "${output}" in
|
|
rest) rootfssize="${output}" && break ;;
|
|
esac
|
|
if [[ "${output}" =~ ^[0-9]+$ ]] && [[ "${output}" -le "$(( disk[size] - cfg[swapsize] - cfg[bootsize] ))" ]]; then
|
|
rootfssize="${output}"
|
|
break
|
|
fi
|
|
done
|
|
|
|
setconf "add" "fde_key_store" "${cfg[fde_key_store]}"
|
|
setconf "add" "fde_keystore" "${cfg[fde_key_store]}"
|
|
setconf "add" "FDE_KEY_STORE" "${cfg[fde_key_store]}"
|
|
setconf "add" "diskid" "${disk[id]}"
|
|
setconf "add" "swapsize" "${swapsize}"
|
|
setconf "add" "rootfssize" "${rootfssize}"
|
|
setconf "add" "wipe" "${cfg[wipe]}"
|
|
setconf "add" "diskname" "${disk[name]}"
|
|
setconf "add" "bootsize" "4"
|
|
setconf "add" "target_part" "2"
|
|
module end
|