MT#62787 Support NVMe disks in autodetection code

We had to revert commit 2974f71127,
as we're relying on the /sys/block autodetection code in our VM
builds that don't specify the target disk explicitly.

So instead let's reintroduce the code, but also support
NVMe disks and make the code more generic WRT sda vs vda.

While at it, also report a message whenever we're running through this
autodetection code.

Change-Id: I39fe04def1694f127a99c97f91fabc2768fec1c7
mr13.4
Michael Prokop 7 months ago
parent b6f8f4194b
commit b2007bd91d

@ -1798,20 +1798,17 @@ fi
if [ -n "$TARGET_DISK" ] ; then
export DISK="${TARGET_DISK}"
else # otherwise try to find sane default
if [ -L /sys/block/vda ] ; then
export DISK=vda # will be configured as /dev/vda
else
# in some cases, sda is not the HDD, but the CDROM,
# so better walk through all devices.
for i in /sys/block/sd*; do
if grep -q 0 "${i}/removable"; then
for i in /sys/block/sd* /sys/block/vd* /sys/block/nvme*n* ; do
# device might not be a HDD, but a CDROM or a removable device
if grep -q 0 "${i}/removable" 2>/dev/null; then
DISK=$(basename "$i")
export DISK
break
fi
done
echo "NOTE: used autodetection code to assigning disk '${DISK}'"
fi
fi
if [[ -n "${SWRAID_DISK1}" ]] && [[ -z "${SWRAID_DISK2}" ]] ; then
die "Error: swraiddisk1 is set, but swraiddisk2 is unset."
elif [[ -z "${SWRAID_DISK1}" ]] && [[ -n "${SWRAID_DISK2}" ]] ; then

Loading…
Cancel
Save