From a6798f6df2f5875e91ce6348d49be4f5e7298be5 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Fri, 9 May 2025 18:44:14 +0200 Subject: [PATCH] Update synology5.sh --- scripts/test/vm/synology5.sh | 50 +++++++++++++++++------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/scripts/test/vm/synology5.sh b/scripts/test/vm/synology5.sh index cabe457..5bf2374 100644 --- a/scripts/test/vm/synology5.sh +++ b/scripts/test/vm/synology5.sh @@ -1075,37 +1075,33 @@ if [ "$DISK_TYPE" = "virtual" ]; then DISK_NUM=$((i+1)) DISK_NAME="vm-${VMID}-disk-${DISK_NUM}${DISK_EXT}" - + SATA_ID="sata$i" # Create virtual disk - #STORAGE_TYPE=$(pvesm status -storage "$STORAGE" | awk 'NR>1 {print $2}') - SATA_ID="sata$i" - DISK_NUM=$((i+1)) + if [[ "$STORAGE_TYPE" == "btrfs" || "$STORAGE_TYPE" == "dir" || "$STORAGE_TYPE" == "nfs" ]]; then + + msg_info "Creating virtual disk (format=raw) for $STORAGE_TYPE..." + if ! qm set "$VMID" -$SATA_ID "$STORAGE:$SIZE,format=raw" >/dev/null 2>&1; then + msg_error "Failed to assign disk $DISK_NUM ($SATA_ID) on $STORAGE" + ERROR_FLAG=true + continue + fi + else - if [[ "$STORAGE_TYPE" == "btrfs" || "$STORAGE_TYPE" == "dir" || "$STORAGE_TYPE" == "nfs" ]]; then - - msg_info "Creating virtual disk (format=raw) for $STORAGE_TYPE..." - if ! qm set "$VMID" -$SATA_ID "$STORAGE:$SIZE,format=raw" >/dev/null 2>&1; then - msg_error "Failed to assign disk $DISK_NUM ($SATA_ID) on $STORAGE" - ERROR_FLAG=true - continue - fi - else + msg_info "Allocating virtual disk for $STORAGE_TYPE..." + if ! pvesm alloc "$STORAGE" "$VMID" "$DISK_NAME" "$SIZE"G >/dev/null 2>&1; then + msg_error "Failed to allocate virtual disk $DISK_NUM" + ERROR_FLAG=true + continue + fi + if ! qm set "$VMID" -$SATA_ID "$STORAGE:${DISK_REF}$DISK_NAME" >/dev/null 2>&1; then + msg_error "Failed to configure virtual disk as $SATA_ID" + ERROR_FLAG=true + continue + fi + fi - msg_info "Allocating virtual disk for $STORAGE_TYPE..." - if ! pvesm alloc "$STORAGE" "$VMID" "$DISK_NAME" "$SIZE"G >/dev/null 2>&1; then - msg_error "Failed to allocate virtual disk $DISK_NUM" - ERROR_FLAG=true - continue - fi - if ! qm set "$VMID" -$SATA_ID "$STORAGE:${DISK_REF}$DISK_NAME" >/dev/null 2>&1; then - msg_error "Failed to configure virtual disk as $SATA_ID" - ERROR_FLAG=true - continue - fi - fi - - msg_ok "Configured virtual disk as $SATA_ID, ${SIZE}GB on ${CL}${BL}$STORAGE${CL} ${GN}" + msg_ok "Configured virtual disk as $SATA_ID, ${SIZE}GB on ${CL}${BL}$STORAGE${CL} ${GN}" # Add information to the description