diff --git a/usr/share/archboot/installer/setup b/usr/share/archboot/installer/setup index 90de21418..9be5e9a78 100755 --- a/usr/share/archboot/installer/setup +++ b/usr/share/archboot/installer/setup @@ -120,6 +120,7 @@ activate_dmraid() # activate lvm2 devices activate_lvm2() { + ACTIVATE_LVM2_DONE="no" if [ -e /sbin/lvm ]; then DIALOG --infobox "Scanning logical volumes..." 0 0 /sbin/lvm vgscan --ignorelockingfailure >/dev/null 2>&1 @@ -132,9 +133,10 @@ activate_lvm2() # activate md devices activate_raid() { + ACTIVATE_RAID_DONE="no" if [ -e /sbin/mdadm ]; then DIALOG --infobox "Activating RAID arrays..." 0 0 - /sbin/mdadm --assemble --scan >/dev/null 2>&1 + /sbin/mdadm --assemble --scan >/dev/null 2>&1 && ACTIVATE_RAID_DONE="yes" fi } @@ -142,6 +144,7 @@ activate_raid() # activate luks devices activate_luks() { + ACTIVATE_LUKS_DONE="no" if [ -e /sbin/cryptsetup ]; then DIALOG --infobox "Scanning for luks encrypted devices..." 0 0 for PART in $(blkid -c=/dev/null | grep "TYPE=\"crypto_LUKS\"" | sed -e 's#:.*##g'); do @@ -150,7 +153,7 @@ activate_luks() for devpath in $(ls /dev/mapper 2>/dev/null | grep -v control); do [ "$(cryptsetup status $devpath | grep $PART)" ] && OPEN_LUKS="no" done - ! [ "$OPEN_LUKS" = "no" ] && _enter_luks_name && _enter_luks_passphrase && _opening_luks + ! [ "$OPEN_LUKS" = "no" ] && _enter_luks_name && _enter_luks_passphrase && _opening_luks && ACTIVATE_LUKS_DONE="yes" done fi } @@ -158,15 +161,14 @@ activate_luks() # activate_special_devices() # activate special devices: # activate dmraid, lvm2 and raid devices, if not already activated during bootup! -# run it 3 times, it can be hidden by each other! +# run it more times if needed, it can be hidden by each other! activate_special_devices() { activate_dmraid - for i in seq 1 3; do + while [ "$ACTIVATE_LVM2_DONE" = "yes" -o "$ACTIVATE_RAID_DONE" = "yes" -o "$ACTIVATE_LUKS_DONE" = "yes" ] ; do activate_raid activate_lvm2 activate_luks - [ "$i" = "3" ] && break done } @@ -414,12 +416,11 @@ dmraid_devices() { fi } -# only show dmraid partitions, +# check_dm_devices # - remove part of encrypted devices # - remove part of lvm # - remove part ot raid -dmraid_partitions() { - # device mapper devices, only show dmraid partitions, remove part of encrypted devices, remove part of lvm, remove part ot raid! +check_dm_devices() { for devpath in $(ls /dev/mapper 2>/dev/null | grep -v control); do k="$(blkid -c=/dev/null /dev/mapper/$devpath 2>/dev/null | grep "TYPE=\"crypto_LUKS\"" | sed -e 's#:.*##g')" partofcrypt="$partofcrypt $k" @@ -432,12 +433,38 @@ dmraid_partitions() { k="$(blkid -c=/dev/null /dev/mapper/$devpath 2>/dev/null | grep "TYPE=\"linux_raid_member\"" | sed -e 's#:.*##g')" partofraid="$partofraid $k" done - for devpath in $(ls /dev/mapper 2>/dev/null | grep -v control); do - if ! [ "$(dmraid -s -c | grep $devpath$)" -o "$(ls $partofcrypt 2>/dev/null | grep /dev/mapper/$devpath$)" -o "$(ls $partoflvm 2>/dev/null | grep /dev/mapper/$devpath$)" -o "$(ls $partofraid 2>/dev/null | grep /dev/mapper/$devpath$)" ]; then - echo "/dev/mapper/$devpath" - [ "$1" ] && echo $1 - fi - done +} + +# dm_devices +# - show device mapper devices +dm_devices() { + check_dm_devices + if [ -d /dev/mapper ] ; then + for devpath in $(ls /dev/mapper 2>/dev/null | grep -v control); do + if ! [ "$(dmraid -s -c | grep ^$devpath)" -o "$(ls $partofcrypt 2>/dev/null | grep /dev/mapper/$devpath$)" -o "$(ls $partoflvm 2>/dev/null | grep /dev/mapper/$devpath$)" -o "$(ls $partofraid 2>/dev/null | grep /dev/mapper/$devpath$)" ]; then + echo "/dev/mapper/$devpath" + [ "$1" ] && echo $1 + fi + done + fi +} + +# dmraid_partitions +# - show dmraid partitions +dmraid_partitions() { + check_dm_devices + if [ -d /dev/mapper ] ; then + for fakeraid in $(dmraid -s -c); do + if [ "$(echo $fakeraid | grep '_')" ]; then + for devpath in $(ls /dev/mapper/$fakeraid*); do + if ! [ "$(dmraid -s -c | grep $devpath$)" -o "$(ls $partofcrypt 2>/dev/null | grep /dev/mapper/$devpath$)" -o "$(ls $partoflvm 2>/dev/null | grep /dev/mapper/$devpath$)" -o "$(ls $partofraid 2>/dev/null | grep /dev/mapper/$devpath$)" ]; then + echo "/dev/mapper/$devpath" + [ "$1" ] && echo $1 + fi + done + fi + done + fi } # do sanity checks on partitions, argument comes $devpath loop @@ -478,6 +505,7 @@ findpartitions() { default_partition_check $1 done additional_blockdevices_partitions $1 + dm_devices $1 dmraid_partitions $1 raid_devices $1 partitionable_raid_devices_partitions $1