Merge "Select disk via kickstart"

This commit is contained in:
Zuul 2020-04-03 13:47:20 +00:00 committed by Gerrit Code Review
commit 980720173a
3 changed files with 32 additions and 26 deletions

View File

@ -73,5 +73,29 @@ function get_http_port()
echo \$(cat /proc/cmdline |xargs -n1 echo |grep '^inst.repo=' | sed -r 's#^[^/]*://[^/]*:([0-9]*)/.*#\1#')
}
get_disk_dev()
{
local disk
# Detect HDD
for blk_dev in vda vdb sda sdb dda ddb hda hdb; do
if [ -d /sys/block/\$blk_dev ]; then
disk=\$(ls -l /sys/block/\$blk_dev | grep -v usb | head -n1 | sed 's/^.*\([vsdh]d[a-z]\+\).*$/\1/');
if [ -n \$disk ]; then
echo \$disk
return
fi
fi
done
for blk_dev in nvme0n1 nvme1n1; do
if [ -d /sys/block/\$blk_dev ]; then
disk=\$(ls -l /sys/block/\$blk_dev | grep -v usb | head -n1 | sed 's/^.*\(nvme[01]n1\).*$/\1/');
if [ -n \$disk ]; then
echo \$disk
return
fi
fi
done
}
END_FUNCTIONS

View File

@ -36,6 +36,10 @@ else
append="$append tboot=false"
fi
if [ -z "$boot_device" ]; then
boot_device=$(get_disk_dev)
fi
boot_device_arg=
if [ -n "$boot_device" ] ; then
boot_device_arg="--boot-drive=$(get_by_path $boot_device)"

View File

@ -10,33 +10,11 @@
set -- `cat /proc/cmdline`
for I in $*; do case "$I" in *=*) eval $I 2>/dev/null;; esac; done
# Find either the ISO or USB device first chopping off partition
ISO_DEV=`readlink /dev/disk/by-label/oe_iso_boot`
sdev=`echo $ISO_DEV | sed -e 's/.$//'`
if [ -e /dev/disk/by-label/$sdev ] ; then
ISO_DEV=$sdev
if [ -z "$boot_device" ]; then
boot_device=$(get_disk_dev)
fi
USB_DEV=`readlink /dev/disk/by-label/wr_usb_boot`
sdev=`echo $USB_DEV | sed -e 's/.$//'`
if [ -e /dev/disk/by-label/$sdev ] ; then
USB_DEV=$sdev
fi
# Temporary, until lab pxelinux.cfg files are updated to specify install devices
if [ -z "$rootfs_device" -o -z "$boot_device" ]
then
INST_HDD=""
# Prefer a vd* device if this is kvm/qemu
for e in vda vdb sda sdb nvme0n1; do
if [ -e /dev/$e -a "$ISO_DEV" != "../../$e" -a "$USB_DEV" != "../../$e" ] ; then
INST_HDD=$e
break
fi
done
# Set variables to $INST_HDD if not set
rootfs_device=${rootfs_device:-$INST_HDD}
boot_device=${boot_device:-$INST_HDD}
if [ -z "$rootfs_device" ]; then
rootfs_device=$(get_disk_dev)
fi
# Convert to by-path