Command to get qemu attached disks

James Crook

Well-Known Member
Jul 28, 2017
149
4
58
So just trying to get a list of attached disks on a virtual machine.

So for containers i used a basic grep the container for the item "rootfs:" then used that with pvesm path (now thinking about it containers can have more than one attached storage)

But for qemu virtuals, they could have IDE drives (including CD Drives), SATA, SCSI and Virtio Block, so was wondering if any one had a quick way to get a list of attached storage, so i pipe it to ZFS for a snapshot, to then use that as a backup.
 
Hi,
you could grep it from the output of `qm config VMID`... although I'm not sure why you don't use the backup functionality provided by PVE.
 
Hi,
you could grep it from the output of `qm config VMID`... although I'm not sure why you don't use the backup functionality provided by PVE.

Yea, so that's what I'm doing, but wasn't sure if there a filter/option to only show disks, as I have to know how the disk is attached, i.e. SCSI sata (tho I'm sure I could change what my grep filter is.... Hmmmm)

With regards to the inbuilt backup, it does fulls each time and has no encryption. Both are needed in my case.
 
Not sure if this is what you want but there is also the `qm snapshot <vmid> <snapname> [OPTIONS]` command which creates named snapshots of VMs.
 
So i'm using Borg to create a backup, but i might be going about it the wrong way by calling zfs snapshot in my script, and then using that to create the Borg backup.

I've just noticed that call virtual machine hard drives start with VM-, so i'll filter out the drives like that i think, as for the containers i was looking for rootfs: