Commit 4195a4f0 authored by Andrew Klassen's avatar Andrew Klassen

Merge branch 'raid_support' into 'master'

ready for review

See merge request !252
parents e888d212 52139ded
......@@ -3,7 +3,7 @@ CLI net-installer for Manjarolinux, forked from Carl Duff's Architect
This installer provides netinstallation for different manjaro editions. It sources the iso-profiles git repo, so it should be always up to date.
**menu overview of v0.9.9:**
**menu overview of v0.9.10:**
```
Main Menu
......@@ -12,6 +12,7 @@ Main Menu
| ├── Set Virtual Console
| ├── List Devices
| ├── Partition Disk
| ├── RAID
| ├── LUKS Encryption
| ├── Logical Volume Management
| ├── Mount Partitions
......
......@@ -552,3 +552,23 @@ _DataRecMenu="Data recovery" # translate me !
_DataRecBody="Various tools for data backup and recovery" # translate me !
_HostCache="Choose pacman cache" # translate me !
_HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me !
#RAID menu
_PrepRAID="RAID (optional)" # translate me !
_RAIDLevelTitle="Select a RAID level." # translate me !
_RAIDLevel0="disk striping" # translate me !
_RAIDLevel1="mirroring" # translate me !
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me !
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me !
_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me !
_PartitionSelectTitle="Partion Select" # translate me !
_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me !
_DeviceNameTitle="Device Name" # translate me !
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me !
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me !
_ArrayCreatedTitle="Array Created" # translate me !
_ArrayCreatedDescription="The RAID array has been created successfully." # translate me !
......@@ -549,3 +549,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me !
_HostCache="Choose pacman cache" # translate me !
_HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me !
#RAID menu
_PrepRAID="RAID (optional)" # translate me !
_RAIDLevelTitle="Select a RAID level." # translate me !
_RAIDLevel0="disk striping" # translate me !
_RAIDLevel1="mirroring" # translate me !
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me !
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me !
_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me !
_PartitionSelectTitle="Partion Select" # translate me !
_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me !
_DeviceNameTitle="Device Name" # translate me !
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me !
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me !
_ArrayCreatedTitle="Array Created" # translate me !
_ArrayCreatedDescription="The RAID array has been created successfully." # translate me !
......@@ -552,3 +552,22 @@ _DataRecBody="Various tools for data backup and recovery"
_HostCache="Choose pacman cache"
_HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation."
#RAID menu
_PrepRAID="RAID (optional)"
_RAIDLevelTitle="Select a RAID level."
_RAIDLevel0="disk striping"
_RAIDLevel1="mirroring"
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)"
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)"
_RAIDLevel10="raid 1+0, (requires 4 disks)"
_PartitionSelectTitle="Partion Select"
_PartitionSelectDescription="Select the partitions you want to use for this RAID array."
_DeviceNameTitle="Device Name"
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. "
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)"
_ArrayCreatedTitle="Array Created"
_ArrayCreatedDescription="The RAID array has been created successfully."
......@@ -553,3 +553,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me !
_HostCache="Choose pacman cache" # translate me !
_HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me !
#RAID menu
_PrepRAID="RAID (optional)" # translate me !
_RAIDLevelTitle="Select a RAID level." # translate me !
_RAIDLevel0="disk striping" # translate me !
_RAIDLevel1="mirroring" # translate me !
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me !
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me !
_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me !
_PartitionSelectTitle="Partion Select" # translate me !
_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me !
_DeviceNameTitle="Device Name" # translate me !
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me !
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me !
_ArrayCreatedTitle="Array Created" # translate me !
_ArrayCreatedDescription="The RAID array has been created successfully." # translate me !
......@@ -546,3 +546,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me !
_HostCache="Choose pacman cache" # translate me !
_HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me !
#RAID menu
_PrepRAID="RAID (optional)" # translate me !
_RAIDLevelTitle="Select a RAID level." # translate me !
_RAIDLevel0="disk striping" # translate me !
_RAIDLevel1="mirroring" # translate me !
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me !
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me !
_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me !
_PartitionSelectTitle="Partion Select" # translate me !
_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me !
_DeviceNameTitle="Device Name" # translate me !
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me !
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me !
_ArrayCreatedTitle="Array Created" # translate me !
_ArrayCreatedDescription="The RAID array has been created successfully." # translate me !
......@@ -550,3 +550,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me !
_HostCache="Choose pacman cache" # translate me !
_HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me !
#RAID menu
_PrepRAID="RAID (optional)" # translate me !
_RAIDLevelTitle="Select a RAID level." # translate me !
_RAIDLevel0="disk striping" # translate me !
_RAIDLevel1="mirroring" # translate me !
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me !
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me !
_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me !
_PartitionSelectTitle="Partion Select" # translate me !
_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me !
_DeviceNameTitle="Device Name" # translate me !
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me !
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me !
_ArrayCreatedTitle="Array Created" # translate me !
_ArrayCreatedDescription="The RAID array has been created successfully." # translate me !
......@@ -549,3 +549,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me !
_HostCache="Choose pacman cache" # translate me !
_HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me !
#RAID menu
_PrepRAID="RAID (optional)" # translate me !
_RAIDLevelTitle="Select a RAID level." # translate me !
_RAIDLevel0="disk striping" # translate me !
_RAIDLevel1="mirroring" # translate me !
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me !
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me !
_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me !
_PartitionSelectTitle="Partion Select" # translate me !
_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me !
_DeviceNameTitle="Device Name" # translate me !
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me !
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me !
_ArrayCreatedTitle="Array Created" # translate me !
_ArrayCreatedDescription="The RAID array has been created successfully." # translate me !
......@@ -549,3 +549,23 @@ _DataRecBody="Różne narzędzia przydatne przy odzyskiwaniu danych i tworzenia
_HostCache="Wybierz pacman cache"
_HostCacheBody="Czy chcesz użyć pacman cache działającego systemu zamiast zajmować się celem instalacyjnym? Takie działanie może zredukować rozmiar wymaganych pobrań podczas instalacji"
#RAID menu
_PrepRAID="RAID (optional)" # translate me !
_RAIDLevelTitle="Select a RAID level." # translate me !
_RAIDLevel0="disk striping" # translate me !
_RAIDLevel1="mirroring" # translate me !
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me !
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me !
_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me !
_PartitionSelectTitle="Partion Select" # translate me !
_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me !
_DeviceNameTitle="Device Name" # translate me !
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me !
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me !
_ArrayCreatedTitle="Array Created" # translate me !
_ArrayCreatedDescription="The RAID array has been created successfully." # translate me !
......@@ -548,3 +548,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me !
_HostCache="Choose pacman cache" # translate me !
_HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me !
#RAID menu
_PrepRAID="RAID (optional)" # translate me !
_RAIDLevelTitle="Select a RAID level." # translate me !
_RAIDLevel0="disk striping" # translate me !
_RAIDLevel1="mirroring" # translate me !
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me !
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me !
_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me !
_PartitionSelectTitle="Partion Select" # translate me !
_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me !
_DeviceNameTitle="Device Name" # translate me !
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me !
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me !
_ArrayCreatedTitle="Array Created" # translate me !
_ArrayCreatedDescription="The RAID array has been created successfully." # translate me !
......@@ -551,3 +551,23 @@ _DataRecBody="Várias ferramentas para backup e recuperação de dados"
_HostCache="Choose pacman cache" # translate me !
_HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me !
#RAID menu
_PrepRAID="RAID (optional)" # translate me !
_RAIDLevelTitle="Select a RAID level." # translate me !
_RAIDLevel0="disk striping" # translate me !
_RAIDLevel1="mirroring" # translate me !
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me !
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me !
_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me !
_PartitionSelectTitle="Partion Select" # translate me !
_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me !
_DeviceNameTitle="Device Name" # translate me !
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me !
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me !
_ArrayCreatedTitle="Array Created" # translate me !
_ArrayCreatedDescription="The RAID array has been created successfully." # translate me !
......@@ -553,3 +553,23 @@ _DataRecBody="Различные инструменты для резервно
_HostCache="Выберите кэш pacman"
_HostCacheBody="Хотите ли вы использовать кэш pacman запущенной системы вместо кэша устанавливаемой системы? Это может уменьшить количество необходимых для скачивания файлов."
#RAID menu
_PrepRAID="RAID (optional)" # translate me !
_RAIDLevelTitle="Select a RAID level." # translate me !
_RAIDLevel0="disk striping" # translate me !
_RAIDLevel1="mirroring" # translate me !
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me !
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me !
_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me !
_PartitionSelectTitle="Partion Select" # translate me !
_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me !
_DeviceNameTitle="Device Name" # translate me !
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me !
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me !
_ArrayCreatedTitle="Array Created" # translate me !
_ArrayCreatedDescription="The RAID array has been created successfully." # translate me !
......@@ -549,3 +549,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me !
_HostCache="Choose pacman cache" # translate me !
_HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me !
#RAID menu
_PrepRAID="RAID (optional)" # translate me !
_RAIDLevelTitle="Select a RAID level." # translate me !
_RAIDLevel0="disk striping" # translate me !
_RAIDLevel1="mirroring" # translate me !
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me !
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me !
_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me !
_PartitionSelectTitle="Partion Select" # translate me !
_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me !
_DeviceNameTitle="Device Name" # translate me !
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me !
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me !
_ArrayCreatedTitle="Array Created" # translate me !
_ArrayCreatedDescription="The RAID array has been created successfully." # translate me !
......@@ -503,3 +503,22 @@ _DataRecBody="Veri yedekleme ve kurtarma için çeşitli araçlar"
_HostCache="Pacman önbelleğini seç"
_HostCacheBody="Kurulum hedefi yerine çalışan sistemin pacman önbelleğini kullanmak ister misiniz? Bu, kurulumda gerekli indirmelerin boyutunu azaltabilir."
#RAID menu
_PrepRAID="RAID (optional)" # translate me !
_RAIDLevelTitle="Select a RAID level." # translate me !
_RAIDLevel0="disk striping" # translate me !
_RAIDLevel1="mirroring" # translate me !
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me !
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me !
_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me !
_PartitionSelectTitle="Partion Select" # translate me !
_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me !
_DeviceNameTitle="Device Name" # translate me !
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me !
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me !
_ArrayCreatedTitle="Array Created" # translate me !
_ArrayCreatedDescription="The RAID array has been created successfully." # translate me !
......@@ -550,3 +550,23 @@ _DataRecBody="Різні утиліти для копіювання та від
_HostCache="Виберіть кеш pacman "
_HostCacheBody="Ви хочете використовувати кеш pacman з працюючої системи, замість кешу системи цільового встановлення? Це може зменшити розмір необхідних завантажень в процесі встановлення."
#RAID menu
_PrepRAID="RAID (optional)" # translate me !
_RAIDLevelTitle="Select a RAID level." # translate me !
_RAIDLevel0="disk striping" # translate me !
_RAIDLevel1="mirroring" # translate me !
_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me !
_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me !
_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me !
_PartitionSelectTitle="Partion Select" # translate me !
_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me !
_DeviceNameTitle="Device Name" # translate me !
_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me !
_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me !
_ArrayCreatedTitle="Array Created" # translate me !
_ArrayCreatedDescription="The RAID array has been created successfully." # translate me !
......@@ -308,6 +308,67 @@ install_base() {
;;
esac
# check to see if raid is needed for boot
# if mount point is on raid then it is needed
if [[ $(lsblk -lno TYPE,MOUNTPOINT | grep -E "raid.*${MOUNTPOINT}" | wc -l)> 0 ]]; then
raid_needed=true
# put all the lines of lsblk, before the mountpoint, into an array
# iterate through the array backwards util a partition is reached
# if raid was involved anywere between the mountpoint and partition,
# then inital ramdisk configuration for raid is need
else
old_ifs="$IFS"
IFS=$'\n'
lsblk_lines=($(lsblk -lno TYPE,NAME,MOUNTPOINT | sed "/\/${MOUNTPOINT:1}$/q"))
IFS="$old_ifs"
for (( i=${#lsblk_lines[@]}-1 ; i>=0 ; i-- )) ; do
if [[ $(echo ${lsblk_lines[i]} | grep "^lvm" | wc -l) > 0 ]]; then
sed -i 's/\<block\>/& lvm2/' ${MOUNTPOINT}/etc/mkinitcpio.conf
continue
fi
if [[ $(echo ${lsblk_lines[i]} | grep "^crypt" | wc -l) > 0 ]]; then
sed -i 's/\<block\>/& encrypt/' ${MOUNTPOINT}/etc/mkinitcpio.conf
sed -i 's/\<autodetect\>/& keymap/' ${MOUNTPOINT}/etc/mkinitcpio.conf
sed -i 's/\<autodetect\>/& keyboard/' ${MOUNTPOINT}/etc/mkinitcpio.conf
continue
fi
if [[ $(echo ${lsblk_lines[i]} | grep "^raid" | wc -l) > 0 ]]; then
raid_needed=true
raid_device_name=$(echo ${lsblk_lines[i]} | cut -f2 -d' ')
continue
fi
if [[ $(echo ${lsblk_lines[i]} | grep "^part" | wc -l) > 0 ]]; then
break
fi
done
fi
# add mkinitcpio raid binary and hook, if root partition is on raid
if [ "$raid_needed" = true ]; then
# auto assemble raid
mdadm --detail --scan >> ${MOUNTPOINT}/etc/mdadm.conf
# add raid initramfs hook
sed -i 's/\<block\>/& mdadm_udev/' ${MOUNTPOINT}/etc/mkinitcpio.conf
binaries_line_number=$(grep -n "^BINARIES=(" ${MOUNTPOINT}/etc/mkinitcpio.conf | cut -f1 -d':')
sed -i "${binaries_line_number}s/^\(.\{10\}\)/\1mdmon/" ${MOUNTPOINT}/etc/mkinitcpio.conf
# get newest kernel and initramfs
newest_kernel=$(ls ${MOUNTPOINT}/lib/modules | grep '^[0-9]' | sort | tail -n 1)
newest_initramfs=$(ls ${MOUNTPOINT}/boot | grep "initramfs" | grep -v "fallback"| sort | tail -n 1)
# initramfs needs to be recomiled with raid support
manjaro-chroot ${MOUNTPOINT} mkinitcpio -c /etc/mkinitcpio.conf -g /boot/${newest_initramfs} -k ${newest_kernel}
fi
recheck_luks
......@@ -362,6 +423,39 @@ install_bootloader() {
else
HIGHLIGHT_SUB=2
fi
# put all the lines of lsblk, before the mountpoint, into an array
# iterate through the array backwards util a partition is reached
# if luks and raid was involved anywere between the mountpoint and partition,
# then grub configuration for raid and luks is needed
old_ifs="$IFS"
IFS=$'\n'
lsblk_lines=($(lsblk -lno TYPE,NAME,MOUNTPOINT | sed "/\/${MOUNTPOINT:1}$/q"))
IFS="$old_ifs"
for (( i=${#lsblk_lines[@]}-1 ; i>=0 ; i-- )) ; do
if [[ $(echo ${lsblk_lines[i]} | grep "^crypt" | wc -l) > 0 ]]; then
luks_device_name=$(echo ${lsblk_lines[i]} | cut -f2 -d' ')
luks_needed=true
continue
fi
if [[ $(echo ${lsblk_lines[i]} | grep "^raid" | wc -l) > 0 ]]; then
raid_device_name=$(echo ${lsblk_lines[i]} | cut -f2 -d' ')
raid_needed=true
continue
fi
if [[ $(echo ${lsblk_lines[i]} | grep "^part" | wc -l) > 0 ]]; then
break
fi
done
# update grub for luks if needed
if [ "$luks_needed" = true ] && [ "$raid_needed" = true ]; then
sed -i "s/^GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"cryptdevice=\/dev\/md\/${raid_device_name}:${luks_device_name}\"/g" ${MOUNTPOINT}/etc/default/grub
manjaro-chroot ${MOUNTPOINT} update-grub
fi
}
uefi_bootloader() {
......
......@@ -367,7 +367,68 @@ install_desktop() {
;;
esac
# check to see if raid is needed for boot
# if mount point is on raid then it is needed
if [[ $(lsblk -lno TYPE,MOUNTPOINT | grep -E "raid.*${MOUNTPOINT}" | wc -l)> 0 ]]; then
raid_needed=true
# put all the lines of lsblk, before the mountpoint, into an array
# iterate through the array backwards util a partition is reached
# if raid was involved anywere between the mountpoint and partition,
# then inital ramdisk configuration for raid is need
else
old_ifs="$IFS"
IFS=$'\n'
lsblk_lines=($(lsblk -lno TYPE,NAME,MOUNTPOINT | sed "/\/${MOUNTPOINT:1}$/q"))
IFS="$old_ifs"
for (( i=${#lsblk_lines[@]}-1 ; i>=0 ; i-- )) ; do
if [[ $(echo ${lsblk_lines[i]} | grep "^lvm" | wc -l) > 0 ]]; then
sed -i 's/\<block\>/& lvm2/' ${MOUNTPOINT}/etc/mkinitcpio.conf
continue
fi
if [[ $(echo ${lsblk_lines[i]} | grep "^crypt" | wc -l) > 0 ]]; then
sed -i 's/\<block\>/& encrypt/' ${MOUNTPOINT}/etc/mkinitcpio.conf
sed -i 's/\<autodetect\>/& keymap/' ${MOUNTPOINT}/etc/mkinitcpio.conf
sed -i 's/\<autodetect\>/& keyboard/' ${MOUNTPOINT}/etc/mkinitcpio.conf
continue
fi
if [[ $(echo ${lsblk_lines[i]} | grep "^raid" | wc -l) > 0 ]]; then
raid_needed=true
raid_device_name=$(echo ${lsblk_lines[i]} | cut -f2 -d' ')
continue
fi
if [[ $(echo ${lsblk_lines[i]} | grep "^part" | wc -l) > 0 ]]; then
break
fi
done
fi
# add mkinitcpio raid binary and hook, if root partition is on raid
if [ "$raid_needed" = true ]; then
# auto assemble raid
mdadm --detail --scan >> ${MOUNTPOINT}/etc/mdadm.conf
# add raid initramfs hook
sed -i 's/\<block\>/& mdadm_udev/' ${MOUNTPOINT}/etc/mkinitcpio.conf
binaries_line_number=$(grep -n "^BINARIES=(" ${MOUNTPOINT}/etc/mkinitcpio.conf | cut -f1 -d':')
sed -i "${binaries_line_number}s/^\(.\{10\}\)/\1mdmon/" ${MOUNTPOINT}/etc/mkinitcpio.conf
# get newest kernel and initramfs
newest_kernel=$(ls ${MOUNTPOINT}/lib/modules | grep '^[0-9]' | sort | tail -n 1)
newest_initramfs=$(ls ${MOUNTPOINT}/boot | grep "initramfs" | grep -v "fallback"| sort | tail -n 1)
# initramfs needs to be recomiled with raid support
manjaro-chroot ${MOUNTPOINT} mkinitcpio -c /etc/mkinitcpio.conf -g /boot/${newest_initramfs} -k ${newest_kernel}
fi
recheck_luks
# add luks and lvm hooks as needed
......
......@@ -134,6 +134,18 @@ find_partitions() {
partition_list=$(lsblk -lno NAME,SIZE,TYPE | grep $INCLUDE_PART | sed 's/part$/\/dev\//g' | sed 's/lvm$\|crypt$/\/dev\/mapper\//g' | \
awk '{print $3$1 " " $2}' | awk '!/mapper/{a[++i]=$0;next}1;END{while(x<length(a))print a[++x]}' ; zfs list -Ht volume -o name,volsize 2>/dev/null | awk '{printf "/dev/zvol/%s %s\n", $1, $2}')
# create a raid partition list
old_ifs="$IFS"
IFS=$'\n'
raid_partitions=($(lsblk -lno NAME,SIZE,TYPE | grep raid | awk '{print $1,$2}' | uniq))
IFS="$old_ifs"
# add raid partitions to partition_list
for i in "${raid_partitions[@]}"
do
partition_list="${partition_list} /dev/md/${i}"
done
for i in ${partition_list}; do
PARTITIONS="${PARTITIONS} ${i}"
NUMBER_PARTITIONS=$(( NUMBER_PARTITIONS + 1 ))
......@@ -494,6 +506,93 @@ make_swap() {
ini mount.swap "${PARTITION}"
}
raid_level_menu() {
declare -i loopmenu=1
while ((loopmenu)); do
RAID_OPT=""
DIALOG "RAID" --menu "\n$_RAIDLevelTitle\n" 20 75 6 \
"0" "$_RAIDLevel0" \
"1" "$_RAIDLevel1" \
"5" "$_RAIDLevel5" \
"6" "$_RAIDLevel6" \
"10" "$_RAIDLevel10" \
"$_Back" "-" 2>${ANSWER}
case $(cat ${ANSWER}) in
"0") raid_array_menu 0
;;
"1") raid_array_menu 1
;;
"5") raid_array_menu 5
;;
"6") raid_array_menu 6
;;
"10") raid_array_menu 10
;;
*) loopmenu=0
return 0
;;
esac
done
}
raid_create() {
RAID_DEVICES=${1}
RAID_DEVICE_NUMBER=$(echo ${1} | wc -w)
RAID_LEVEL=${2}
RAID_DEVICE_NAME=${3}
# creates the array
mdadm --create --level=${RAID_LEVEL} --metadata=1.2 --raid-devices=${RAID_DEVICE_NUMBER} /dev/md/${RAID_DEVICE_NAME} ${RAID_DEVICES}
# array is disassembled and reassembled to prevent the array from being named /dev/md/md127
# the check of /etc/mdadm.conf is preformed to prevent the user from adding duplicate entries
if [[ $(cat /etc/mdadm.conf | grep "/dev/md/${RAID_DEVICE_NAME}" | wc -l) == 0 ]]; then
mdadm --detail --scan | grep -e "/dev/md/${RAID_DEVICE_NAME}" -e "/dev/md/md127" >> /etc/mdadm.conf
mdadm --stop /dev/md/${RAID_DEVICE_NAME}
mdadm --assemble --scan
fi
DIALOG "$__ArrayCreatedTitle" --msgbox "\n$_ArrayCreatedDescription\n\nmdadm --create --level=${RAID_LEVEL} --metadata=1.2 --raid-devices=${RAID_DEVICE_NUMBER} /dev/md/${RAID_DEVICE_NAME} ${RAID_DEVICES}\n" 0 0
}
raid_get_array_name() {
DIALOG "$_DeviceNameTitle" --inputbox "\n$_DeviceNameDescription\n\n$_DeviceNamePrefixWarning\n" 0 0 2>${ANSWER}
raid_device_name=$(cat ${ANSWER})
if [[ ${raid_device_name} != "" ]]; then
raid_create "${1}" ${2} ${raid_device_name}
fi
}
raid_array_menu() {
# find raid partitions.
INCLUDE_PART='part\|crypt'
umount_partitions
find_partitions
# Amend partition(s) found for use in check list
PARTITIONS=$(echo $PARTITIONS | sed 's/M\|G\|T/& off/g')
RAID_LEVEL=${1}
# select partitions for the array
echo "" > $ANSWER
while [[ $(cat ${ANSWER}) == "" ]]; do
DIALOG "$_PartitionSelectTitle" --checklist "\n$__PartitionSelectDescription\n\n$_UseSpaceBar\n " 0 0 12 ${PARTITIONS} 2> ${ANSWER}
done
ANSWERS=$(cat ${ANSWER})
raid_get_array_name "${ANSWERS[@]}" ${RAID_LEVEL}
}
luks_menu() {
declare -i loopmenu=1
while ((loopmenu)); do
......
......@@ -223,20 +223,21 @@ prep_menu() {
local PARENT="$FUNCNAME"
declare -i loopmenu=1
while ((loopmenu)); do
submenu 13
submenu 14
DIALOG " $_PrepMenuTitle " --default-item ${HIGHLIGHT_SUB} --menu "\n$_PrepMenuBody\n " 0 0 0 \
"1" "$_VCKeymapTitle" \
"2" "$_DevShowOpt" \
"3" "$_PrepPartDisk|>" \
"4" "$_PrepLUKS|>" \
"5" "$_PrepLVM $_PrepLVM2|>" \
"6" "$_PrepZFS|>" \
"7" "$_PrepMntPart" \
"8" "$_PrepMirror|>" \
"9" "$_PrepPacKey" \
"10" "$_HostCache" \
"11" "Enable fsck hook" \
"12" "$_Back" 2>${ANSWER}
"4" "$_PrepRAID|>" \
"5" "$_PrepLVM $_PrepLVM2|>" \
"6" "$_PrepLUKS|>" \
"7" "$_PrepZFS|>" \
"8" "$_PrepMntPart" \
"9" "$_PrepMirror|>" \
"10" "$_PrepPacKey" \
"11" "$_HostCache" \
"12" "Enable fsck hook" \
"13" "$_Back" 2>${ANSWER}
HIGHLIGHT_SUB=$(cat ${ANSWER})
case $(cat ${ANSWER}) in
......@@ -248,17 +249,19 @@ prep_menu() {
"3") umount_partitions
select_device && create_partitions
;;
"4") luks_menu
"4") raid_level_menu
;;
"5") lvm_menu
;;
"6") zfs_menu
"6") luks_menu
;;
"7") mount_partitions
"7") zfs_menu
;;
"8") configure_mirrorlist
"8") mount_partitions
;;
"9") clear
"9") configure_mirrorlist
;;
"10") clear
(
ctrlc(){
return 0
......@@ -269,9 +272,9 @@ prep_menu() {
check_for_error 'refresh pacman-keys'
)
;;
"10") set_cache
"11") set_cache
;;
"11") set_fsck_hook
"12") set_fsck_hook
;;
*) loopmenu=0
return 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment