How to Add/Detach Hard Disk via Command Line?


New Member
Oct 21, 2019
Proxmox is an amazing product. I have been tinkering with it for weeks and the functionality is overwhelming. After 17 years of Windows I finally decided to make the shift to Linux, and Proxmox is a huge help. It allows me to keep my desired server tasks separated from one another so that it will not affect the entire system when I mess up.

I have just re-installed Proxmox on a 120GB SSD, and created a directory on the 1TB HDD that I want to use as my Nextcloud data directory. I can add the disk fine under "Hardware > Add > Hard Disk". However, since I have a lot of data, backups of the VM would take very long. In order to speed things up, I would rather detach the data disk and only back up the VM image. As far as my understanding goes, backing up my Nextcloud data with rsync would be much more effective than doing a complete image backup.

Of course I can do all of this manually, but there are certainly command line options for adding and detaching hard disks. This way I could write a bash file and automatically execute it via a cron job.

Thanks a lot for this great product!

Edit: Just realized that when I detach a hard disk under "Hardware", the created raw image in my directory will not simply be re-attached. Instead, a new one is created the next time I add a hard disk. So I guess I will have to revert to my initial method of adding the physical disk to the VM as a vda device via "qm set VMID -virtio2 /dev/disk/by-id". However I would still need the command to detach it.

Edit 2: When I tried to delete the VM images from the directory, it told me I had to delete them from the Hardware pane of the VM. I now noticed there were two 'unused disks' that I could conveniently re-attach. I am a little confused now. Which scenario would be recommended for my use case, and what are the respective commands for my bash script?
Last edited:
If you just want to not backup a single disk, just enable the "no Backup" option of the disk (it's under advanced options).
  • Like
Reactions: FLOSSFreak
:oops: That's it.

VM > Hardware > Select Disk > Edit > Toggle "No Backup"

Just ran "vzdump VMID" from shell and it only backed up the system disk. Thank you so much!
Great post. I needed the same thing today with a very large disk I didn't want to backup either.


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!