SOLVED : qm change unused disk from scsi to sata

spacemancw

New Member
Feb 2, 2024
13
0
1
I have a VM with 2 unused disks, 0 and 1 .. and they both scsi.
how do I use qm to set them to sata and set Async IO to native?

thanks
 
thanks for the reply, but I need to be able to do it on the command line with qm.
I'm working on automating VM migration from VMware to PXMX.
I can import the VM with "qm import $nextVmid $vmxFile --storage $pxmxStorage"
The VM gets imported with 2 scsi drives, 0 and 1.
It seems I have to add another scsi drive (a 1G disk is sufficient), detach and change the first 2 to sata, power up and then down and then back to scsi and then the VM powers on properly after that. Then delete that 1G drive.
One of the engineers does this manually over and over on many VMs ... so I'm translating his manual steps into an automated process.
 
You can usually find commands and their descriptions in man pages.

You probably need to unlink and then set the unusedX as needed.

qm disk unlink <vmid> --idlist <string> [OPTIONS]

Unlink/delete disk images.

<vmid>: <integer> (100 - 999999999)
The (unique) ID of the VM.

--force <boolean>
Force physical removal. Without this, we simple remove the disk from the config file and create an additional configuration entry called unused[n], which contains the volume ID. Unlink of
unused[n] always cause physical removal.

--idlist <string>
A list of disk IDs you want to delete.

To add the unused disk (adjust for sata, etc.) :
qm set "$vmid" --scsihw virtio-scsi-single --"$DEVICE"3 "$storage":vm-"$vmid"-disk-3,aio=native,iothread=1


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Thanks ... I'm always looking at the man pages ... sometimes getting the syntax right on the command line isn't always straighforward ... anyway I worked it out.
I'm using a mixture of the API and qm commands all inside powershell. So I get the config with the API
Code:
$endpoint="nodes/$node/qemu/$nextVmid/config"
        $URL="https://$phost/api2/json/$endpoint"
        $response = Invoke-RestMethod -Uri $URL -Headers $pHeaders
        $newConfig = $response.data

$unusedEntries = $newConfig.PSObject.Properties | Where-Object { $_.Name -like "unused*" } | sort name


# Add the unused disks back as SATA
        foreach ($entry in $unusedEntries) {
            $diskPath = $entry.Value
            $sataDevice = "sata$nextSataNum"

            # Build the command and execute via SSH
            $cmd = "qm set 703 -$sataDevice $diskPath,aio=native"
            $SSHStream.writeLine($cmd)
            $SSHStream.Read()

            # Increment for the next disk
            $nextSataNum++
        }

so basically the config lists unused disks and path to the disks
I loop thru the unused disks. I already calculated the next sata number ($nextSataNum) .. and increment the $nextSataNum .. I dont just start using sata0, because it may already exist.

And I have an SSH stream open using the posh-ssh powershell module.
 
Last edited:
Looks like you had quite a few more requirements than initially mentioned, glad to see you were able to work it all out.

If you run into issues with a specific CLI command or its options, it’s always best to share the exact commands you used so the community can help more effectively.

Feel free to mark the thread solved by editing the original post and adding a "SOLVED" tag to the subject


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox