Attach/detach hdd to vm via API

Aleksej

Well-Known Member
Feb 25, 2018
55
1
48
38
hi all.

can anyone help me with this?
i tried to use /config with params ide[2] (ide[3]...) to attach disk to vm. it works, but how to detach it? ide[2]='' returns "error parsing params"
 
Hi!

use the '-delete <property>' mechanism to delete a property, or in this case make it unused.

A relative easy way to check what WebUI feature maps to which API call is by using your Browsers web/developer console's network tab, there you see the call in it's full form :)
 
  • Like
Reactions: ams_tschoening
there is empty in console while doing anything in web interface.


did you mean use it in monitor? according to https://pve.proxmox.com/pve-docs/api-viewer/index.html i can't find any similar command...

The delete property is described in your linked article just fine, navigate to "/nodes/{node}/qemu/{vmid}/config" and select the PUT tab.

A pvesh example would be:
Code:
pvesh set /nodes/nina/qemu/101/config -delete unused0
update VM 101: -delete unused0
  Logical volume "vm-101-disk-0" successfully removed

which equals an API call like:
Code:
PUT /nodes/nina/qemu/101/config?delete=unused0
 
  • Like
Reactions: ams_tschoening
Or explicitly for your case:
Code:
pvesh set /nodes/NODE/qemu/VMID/config -delete ide2

This will first mark it unused, you then can delete it finally by deleting the respective unusedX entry.
 
  • Like
Reactions: ams_tschoening
thank you a lot.
it works great.

But now i have a different problem. i'm doing it to make users to do "clean" OS install. OS images i don't want to do unattended.

So i need to remove all data in vm image, maybe format it and then start OS install.
Tried to use virtio0=stor:vm-111-disk-2,size=10G (i'm using LVM) but it won't to create LV.
So, it is nececarry to use POST on /nodes/node/storage/stor/content to create new image. If using simple storage it's ok. but in LVM what filename to use?

i don't want to post new thread about this, as i think, very simple question. but search not return anything.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!