How to create and add a new virtual disk to a VM using command line.

kakao73

Member
Aug 1, 2018
20
1
8
Hello,

I've tried below but failed:
Bash:
$ pvesm alloc <lvm-thin-storage> 123 '' 5G
successfully created '<lvm-thin-storage>:vm-123-disk-1'

$ qm set 123 --scsihw virtio-scsi-pci --scsi1 <lvm-thin-storage>:vm-123-disk1,discard=on,ssd=1
update VM 123: -scsi1 <lvm-thin-storage>:vm-123-disk1,discard=on,ssd=1 -scsihw virtio-scsi-pci
can't get size of '/dev/<lvm-storage>/vm-123-disk1':   Failed to find logical volume "<lvm-storage>/vm-123-disk1"

How can I add a new virtual disk to a VM using command line?
 
Have you tried using vgcreate directly? What is the output of lvdisplay (or only lvs)?
 
Last edited:
Works for me:

Code:
mala# pvesm status            
Name                       Type     Status           Total            Used       Available        %
(...)
localThin               lvmthin     active       419430400       214328934       205101465   51.10%
mala# pvesm alloc localThin 116 '' 11G    
  Logical volume "vm-116-disk-1" created.
successfully created 'localThin:vm-116-disk-1'
mala# qm set 116 --scsi11 localThin:vm-116-disk-1,discard=on
update VM 116: -scsi11 localThin:vm-116-disk-1,discard=on
mala# qm config 116 | grep scsi11
scsi11: localThin:vm-116-disk-1,discard=on,size=11G

What version are you using pveversion -v?
 

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!