Select disk via kickstart

If the boot_device and/or rootfs_device are not set on the kernel
cmdline detect them early in the kickstart script. This can help
solve the issue about which disk type is to be used.

Remove the older code for disk detection
Tested with both sda and nvme disk types

Story: 2007486
Task: 39204
Change-Id: I4fa3b44a4e656e280820ceeefafaf127cb048df6
Signed-off-by: Saul Wold <sgw@linux.intel.com>
This commit is contained in:
Saul Wold 2020-03-30 11:52:59 -07:00
parent b235d3c111
commit f11e52b000
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#') 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 END_FUNCTIONS

View File

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

View File

@ -10,33 +10,11 @@
set -- `cat /proc/cmdline` set -- `cat /proc/cmdline`
for I in $*; do case "$I" in *=*) eval $I 2>/dev/null;; esac; done 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 if [ -z "$boot_device" ]; then
ISO_DEV=`readlink /dev/disk/by-label/oe_iso_boot` boot_device=$(get_disk_dev)
sdev=`echo $ISO_DEV | sed -e 's/.$//'`
if [ -e /dev/disk/by-label/$sdev ] ; then
ISO_DEV=$sdev
fi fi
USB_DEV=`readlink /dev/disk/by-label/wr_usb_boot` if [ -z "$rootfs_device" ]; then
sdev=`echo $USB_DEV | sed -e 's/.$//'` rootfs_device=$(get_disk_dev)
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}
fi fi
# Convert to by-path # Convert to by-path