Skip to content

Commit 682b6cd

Browse files
levindecarodhslove
authored andcommitted
fix fsvm-init.yml to detect virtio-scsi in kvm (apache#11070)
* fix fsvm-init.yml to detect virtio-scsi in kvm * Update fsvm-init.yml to handle universal block device case.
1 parent f0dc5de commit 682b6cd

File tree

1 file changed

+3
-17
lines changed
  • plugins/storage/sharedfs/storagevm/src/main/resources/conf

1 file changed

+3
-17
lines changed

plugins/storage/sharedfs/storagevm/src/main/resources/conf/fsvm-init.yml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,9 @@ write_files:
2929
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> $LOG_FILE
3030
}
3131
get_block_device() {
32-
if [ "$HYPERVISOR" == "kvm" ]; then
33-
BLOCK_DEVICE="sdb"
34-
if [ -n "$(blkid /dev/$BLOCK_DEVICE)" -a -z "$(blkid -s TYPE /dev/$BLOCK_DEVICE)" ]; then
35-
BLOCK_DEVICE="sda"
36-
fi
37-
elif [ "$HYPERVISOR" == "xenserver" ]; then
38-
BLOCK_DEVICE="xvdb"
39-
if [ -n "$(blkid /dev/$BLOCK_DEVICE)" -a -z "$(blkid -s TYPE /dev/$BLOCK_DEVICE)" ]; then
40-
BLOCK_DEVICE="xvda"
41-
fi
42-
elif [ "$HYPERVISOR" == "vmware" ]; then
43-
BLOCK_DEVICE="sdb"
44-
if [ -n "$(blkid /dev/$BLOCK_DEVICE)" -a -z "$(blkid -s TYPE /dev/$BLOCK_DEVICE)" ]; then
45-
BLOCK_DEVICE="sda"
46-
fi
47-
else
48-
log "Unknown hypervisor"
32+
BLOCK_DEVICE=$(lsblk -dn -o NAME,TYPE | awk '$2=="disk"{print $1}' | tail -n 1)
33+
if [ -z "$BLOCK_DEVICE" ]; then
34+
log "Unknown data disk"
4935
exit 1
5036
fi
5137
echo "$BLOCK_DEVICE"

0 commit comments

Comments
 (0)