Skip to content

Commit

Permalink
Use the more reliable lsblk to find block devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Ratler committed Dec 4, 2017
1 parent 9fe20ce commit 8f4bdac
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions lunar-install/sbin/lunar-install
Expand Up @@ -250,24 +250,14 @@ block_devices()

list_block_devices()
{(
local DEVICE TYPE
export IFS=$' \t\n'
local DEVICE FDEVICE PDEVICE

# Grab protected device when booting iso from other media then cdrom
PDEVICE=$(basename `grep -v '^rootfs' /proc/mounts | fgrep -w '/' | cut -d' ' -f1` 2> /dev/null)

for DEVICE in $(tail +3 /proc/partitions | awk '{print $4}' | grep -v -e ${PDEVICE:-^$} -e loop); do
FDEVICE=$(lsh unmap_device /dev/$DEVICE)
# if the device node ends with [0-9] then it's never a disc
if [[ $DEVICE =~ [0-9]$ ]]; then
# partitions always sit on a disc - which is also listed
if grep -qw "${DEVICE/[0-9]*/}" /proc/partitions ; then
echo $FDEVICE:part
else
echo $FDEVICE:other
fi

lsblk -o NAME,TYPE -p -n --raw -I 3,8,9 | while read DEVICE TYPE; do
if [[ "$TYPE" == "disk" || "$TYPE" == "part" ]]; then
echo $DEVICE:$TYPE
else
echo $FDEVICE:disc
echo $DEVICE:other
fi
done
export IFS=$'\t\n'
Expand All @@ -277,7 +267,7 @@ list_block_devices()
menu_list_devices()
{
local DEVICE
for DEVICE in $(block_devices list part; block_devices list disc ; block_devices list other); do
for DEVICE in $(block_devices list part; block_devices list disk; block_devices list other); do
echo $DEVICE
echo "Block device"
done
Expand Down Expand Up @@ -372,18 +362,17 @@ menu_get_partition()

menu_list_discs()
{
for DISC in $(block_devices listall disc); do
for DISC in $(block_devices listall disk); do
echo $DISC
echo "disc"
echo "disk"
done

}


menu_get_disc()
{
TITLE="Disk Selection Menu"
HELP="Please select a disc"
HELP="Please select a disk"
$DIALOG --title "$TITLE" --menu "$HELP" 0 0 0 $(menu_list_discs)
}

Expand Down

0 comments on commit 8f4bdac

Please sign in to comment.