mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2026-01-22 13:31:02 +08:00
fiz: Ignore sector size for whole disk passthrough (#1121)
This commit is contained in:
27
src/disk.sh
27
src/disk.sh
@@ -573,18 +573,25 @@ addDevice () {
|
|||||||
[ ! -b "$DISK_DEV" ] && error "Device $DISK_DEV cannot be found! Please add it to the 'devices' section of your compose file." && exit 55
|
[ ! -b "$DISK_DEV" ] && error "Device $DISK_DEV cannot be found! Please add it to the 'devices' section of your compose file." && exit 55
|
||||||
|
|
||||||
local sectors=""
|
local sectors=""
|
||||||
local result logical physical
|
local dev_type=""
|
||||||
result=$(fdisk -l "$DISK_DEV" | grep -m 1 -o "(logical/physical): .*" | cut -c 21-)
|
dev_type=$(lsblk -no TYPE "$DISK_DEV" 2>/dev/null | head -n1)
|
||||||
logical="${result%% *}"
|
|
||||||
physical=$(echo "$result" | grep -m 1 -o "/ .*" | cut -c 3-)
|
|
||||||
physical="${physical%% *}"
|
|
||||||
|
|
||||||
if [ -n "$physical" ]; then
|
# Only detect and apply sector sizes for partitions, not whole disks
|
||||||
if [[ "$physical" != "512" ]]; then
|
# Whole disk passthrough with explicit sector sizes causes DSM not to recognize the disk
|
||||||
sectors=",logical_block_size=$logical,physical_block_size=$physical"
|
if [[ "$dev_type" == "part" ]]; then
|
||||||
|
local result logical physical
|
||||||
|
result=$(fdisk -l "$DISK_DEV" | grep -m 1 -o "(logical/physical): .*" | cut -c 21-)
|
||||||
|
logical="${result%% *}"
|
||||||
|
physical=$(echo "$result" | grep -m 1 -o "/ .*" | cut -c 3-)
|
||||||
|
physical="${physical%% *}"
|
||||||
|
|
||||||
|
if [ -n "$physical" ]; then
|
||||||
|
if [[ "$physical" != "512" ]]; then
|
||||||
|
sectors=",logical_block_size=$logical,physical_block_size=$physical"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Failed to determine the sector size for $DISK_DEV"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
warn "Failed to determine the sector size for $DISK_DEV"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DISK_OPTS+=$(createDevice "$DISK_DEV" "$DISK_TYPE" "$DISK_INDEX" "$DISK_ADDRESS" "raw" "$DISK_IO" "$DISK_CACHE" "" "$sectors")
|
DISK_OPTS+=$(createDevice "$DISK_DEV" "$DISK_TYPE" "$DISK_INDEX" "$DISK_ADDRESS" "raw" "$DISK_IO" "$DISK_CACHE" "" "$sectors")
|
||||||
|
|||||||
Reference in New Issue
Block a user