resize VM HDD to 800GB and my real HDD has only 80GB

mfaridi

Member
Oct 17, 2015
64
0
6
I install Proxmox 4 on my HP server , my HP server has two HDD one of them is 80GB and another HDD is 1000GB. I run centos on first HDD make 32 GB virtual HDD for it . 32 GB is not enough for my project , so I go to Proxmox UI and resize HDD . and make mistake and make 800GB HDD , real HD is 80GB, my centos boot normal ,
what I must do ?
 
Hi,

in this case your friend is qemu-img.
First you have to skrink your vm inside. you can use Clonezilla for this.
then you have to use qemu-img resize on your image.
the edit the vm config and correct the size.
 
Hi,

in this case your friend is qemu-img.
First you have to skrink your vm inside. you can use Clonezilla for this.
then you have to use qemu-img resize on your image.
the edit the vm config and correct the size.
Thanks,
my original size for centos in Proxmox was 32GB and right now it is 800GB, I want delete all new size add to the disk.
I am very nervous , I am afraid I lose all of my project.
Please help me . I have very important project on the Centos , it is my educational project.
 
No problem make a backup and you are save!
What size you see in the VM
df -h

if you have the old size then you don't have to shrink it inside.
 
No problem make a backup and you are save!
What size you see in the VM
df -h

if you have the old size then you don't have to shrink it inside.

Thanks
I see
Code:
[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       28G   18G  9.5G  65% /
tmpfs                 750M     0  750M   0% /dev/shm
/dev/sda1             477M   57M  395M  13% /boot
/dev/sdb               99G   14G   80G  15% /data
I make mistake and add 800GB to sda VM HDD .
 
No problem make a backup and you are save!
What size you see in the VM
df -h

if you have the old size then you don't have to shrink it inside.
please see this screenshot after df -h
centos2.png

this picture show I made 832GB Virtual HDD on the centos VM ,
df -h
do not give use more information.
 
What you see on the GUI is what you rite in the config.
more intresting is what do you see if you go on the storage dir in tab content?
What size the vm-100-disk-1.qcow2 has?
 
What you see on the GUI is what you rite in the config.
more intresting is what do you see if you go on the storage dir in tab content?
What size the vm-100-disk-1.qcow2 has?
I see in storage dir 37.98GB
and when I run ncdu in server I see
Code:
26.0GiB [######### ]  vm-100-disk-1.qcow2
 17.8GiB [######    ]  vm-100-disk-2.qcow2

when I boot VM by gparted I see 800GB size and 800GB is unlocated .
what happen if I reboot proxmox server , I am afraid my system can not boot.
 
Reboot do not fix the problem, but do not harm your system.

you must first understand what thin provisioning is.

you can create a 2TeraByte image on 40GigaByte storage white qcow.
but the file has only the needed space and some extra space on the host.

so long no problem the problem occurs if the image need more space then the host disk has.
this is a very uncountable situation you never want to have.

so in you case we have only to shrink the image.

please give me the output of pvesm list dir
 
Reboot do not fix the problem, but do not harm your system.

you must first understand what thin provisioning is.

you can create a 2TeraByte image on 40GigaByte storage white qcow.
but the file has only the needed space and some extra space on the host.

so long no problem the problem occurs if the image need more space then the host disk has.
this is a very uncountable situation you never want to have.

so in you case we have only to shrink the image.

please give me the output of pvesm list dir

when I run that command I see
Code:
oot@aal-prox:~# pvesm list 
400 Parameter verification failed.
storage: property is missing and it is not optional
pvesm list <storage> [OPTIONS]
 
when I run command , I see
Code:
root@aal-prox:~# pvesm list dir
dir:100/vm-100-disk-1.qcow2 qcow2 893353197568 100
dir:100/vm-100-disk-2.qcow2 qcow2 107374182400 100
dir:101/vm-101-disk-1.qcow2 qcow2 26843545600 101
dir:102/vm-102-disk-1.qcow2 qcow2 214748364800 102
dir:102/vm-102-disk-2.qcow2 qcow2 322122547200 102
dir:103/vm-103-disk-1.qcow2 qcow2 34359738368 103
root@aal-prox:~#
 
I give you an step by step converting and resize How to do.

But first of all make an backup.
and verify that you haven't change anything in the Vm especially no resize2fs or simular since you send me the df -h output.
then please give my the path your vm disk

pvesm path dir:100/vm-100-disk-1.qcow2
 
I give you an step by step converting and resize How to do.

But first of all make an backup.
and verify that you haven't change anything in the Vm especially no resize2fs or simular since you send me the df -h output.
then please give my the path your vm disk

pvesm path dir:100/vm-100-disk-1.qcow2
when I run this command
[cmd]pvesm path dir:100/vm-100-disk-1.qcow2[/cmd]
I see
Code:
/data/images/100/vm-100-disk-1.qcow2
when I want get backup with proxmox UI and when choose Centos VM , I can not find location for backup , I have two HDD on My HDD server .
can I said proxmox to use second HDD for get backup from VM/
In first HDD , I do not have enough space.
 
when I run this command
[cmd]pvesm path dir:100/vm-100-disk-1.qcow2[/cmd]
I see
Code:
/data/images/100/vm-100-disk-1.qcow2
when I want get backup with proxmox UI and when choose Centos VM , I can not find location for backup , I have two HDD on My HDD server .
can I said proxmox to use second HDD for get backup from VM/
In first HDD , I do not have enough space.

Hi,
you must define a storage which is able to store backups (type backup - must be an filesystem like ext3/4 or nfs). Eg. you can define (and create before) an directory like /data/backup if this in on an hdd with enough space.

BTW. an backup on the same hdd like the original is not realy the best solution...

Udo
 
Hi,
you must define a storage which is able to store backups (type backup - must be an filesystem like ext3/4 or nfs). Eg. you can define (and create before) an directory like /data/backup if this in on an hdd with enough space.

BTW. an backup on the same hdd like the original is not realy the best solution...

Udo
Ok,
Thanks I create backup and move it another HDD. , what I must do right now ? how I remove 800GB ?
 
Last edited:
I give you an step by step converting and resize How to do.

But first of all make an backup.
and verify that you haven't change anything in the Vm especially no resize2fs or simular since you send me the df -h output.
then please give my the path your vm disk

pvesm path dir:100/vm-100-disk-1.qcow2
I find option in UI and creat backup on another HDD.
I am ready for decrease 800GB HDD
 
Last edited:
I will suppose that you did not change anything in the VM after you post.

You have to stop the VM
on the command line

to be sure the vm is stop:
Code:
qm stop 100

now we convert the image from qcow2 in raw, because qcow can't be shrinked.
Code:
qemu-img convert  [COLOR=#333333][I]/data/images/100/vm-100-disk-1.qcow2  [/I][/COLOR][COLOR=#333333][I]/data/images/100/vm-100-disk-1.raw [/I][/COLOR]

then we can shrink the image the 60G are the new total size.
Code:
qemu-img resize -f raw  [COLOR=#333333][I]/data/images/100/vm-100-disk-1.raw  60G[/I][/COLOR]

now we convert it back.
Code:
qemu-img convert  [COLOR=#333333][I]/data/images/100/vm-100-disk-1.raw [/I][/COLOR][COLOR=#333333][I]/data/images/100/vm-100-disk-1.qcow2 [/I][/COLOR]

erase the old .raw image
Code:
rm  [COLOR=#333333][I]/data/images/100/vm-100-disk-1.raw[/I][/COLOR]

then edit the "/etc/pve/qemu-server/100.conf" file and change the the size of the disk to 60G

that's is start you vm.
 
  • Like
Reactions: Helmut101
I will suppose that you did not change anything in the VM after you post.

You have to stop the VM
on the command line

to be sure the vm is stop:
Code:
qm stop 100

now we convert the image from qcow2 in raw, because qcow can't be shrinked.
Code:
qemu-img convert  [COLOR=#333333][I]/data/images/100/vm-100-disk-1.qcow2  [/I][/COLOR][COLOR=#333333][I]/data/images/100/vm-100-disk-1.raw [/I][/COLOR]

then we can shrink the image the 60G are the new total size.
Code:
qemu-img resize -f raw  [COLOR=#333333][I]/data/images/100/vm-100-disk-1.raw  60G[/I][/COLOR]

now we convert it back.
Code:
qemu-img convert  [COLOR=#333333][I]/data/images/100/vm-100-disk-1.raw [/I][/COLOR][COLOR=#333333][I]/data/images/100/vm-100-disk-1.qcow2 [/I][/COLOR]

erase the old .raw image
Code:
rm  [COLOR=#333333][I]/data/images/100/vm-100-disk-1.raw[/I][/COLOR]

then edit the "/etc/pve/qemu-server/100.conf" file and change the the size of the disk to 60G

that's is start you vm.
I do all command , but when I want run centos I see this
Code:
[COLOR=#000000][FONT=tahoma]Running as unit 100.scope.[/FONT][/COLOR]
[COLOR=#000000][FONT=tahoma]kvm: -drive file=/data/images/100/vm-100-disk-1.qcow2,if=none,id=drive-sata0,format=qcow2,cache=none,aio=native,detect-zeroes=on: Image is not in qcow2 format[/FONT][/COLOR]
[COLOR=#000000][FONT=tahoma]TASK ERROR: start failed: command '/usr/bin/systemd-run --scope --slice qemu --unit 100 -p 'CPUShares=1000' /usr/bin/kvm -id 100 -chardev 'socket,id=qmp,path=/var/run/qemu-server/100.qmp,server,nowait' -mon 'chardev=qmp,mode=control' -vnc unix:/var/run/qemu-server/100.vnc,x509,password -pidfile /var/run/qemu-server/100.pid -daemonize -smbios 'type=1,uuid=32cb53ae-ce89-4ed8-99e1-4cdfa9784257' -name CentOS -smp '4,sockets=1,cores=4,maxcpus=4' -nodefaults -boot 'menu=on,strict=on,reboot-timeout=1000' -vga cirrus -cpu kvm64,+lahf_lm,+sep,+kvm_pv_unhalt,+kvm_pv_eoi,-kvm_steal_time,enforce -m 1536 -k en-us -device 'pci-bridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e' -device 'pci-bridge,id=pci.2,chassis_nr=2,bus=pci.0,addr=0x1f' -device 'piix3-usb-uhci,id=uhci,bus=pci.0,addr=0x1.0x2' -device 'usb-tablet,id=tablet,bus=uhci.0,port=1' -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3' -iscsi 'initiator-name=iqn.1993-08.org.debian:01:d3f1e587de3a' -device 'ahci,id=ahci0,multifunction=on,bus=pci.0,addr=0x7' -drive 'file=/data/images/100/vm-100-disk-1.qcow2,if=none,id=drive-sata0,format=qcow2,cache=none,aio=native,detect-zeroes=on' -device 'ide-drive,bus=ahci0.0,drive=drive-sata0,id=sata0,bootindex=100' -drive 'file=/data/images/100/vm-100-disk-2.qcow2,if=none,id=drive-sata1,format=qcow2,cache=none,aio=native,detect-zeroes=on' -device 'ide-drive,bus=ahci0.1,drive=drive-sata1,id=sata1' -drive 'file=/var/lib/vz/template/iso/gparted-live-0.23.0-1-amd64.iso,if=none,id=drive-ide2,media=cdrom,aio=threads' -device 'ide-cd,bus=ide.1,unit=0,drive=drive-ide2,id=ide2,bootindex=200' -netdev 'type=tap,id=net0,ifname=tap100i0,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown' -device 'e1000,mac=3A:FD:9F:A0:AA:FB,netdev=net0,bus=pci.0,addr=0x12,id=net0,bootindex=300' -netdev 'type=tap,id=net1,ifname=tap100i1,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown' -device 'e1000,mac=86:A0:2D:4F:9D:FB,netdev=net1,bus=pci.0,addr=0x13,id=net1,bootindex=301'' failed: exit code 1[/FONT][/COLOR]
and centos can not run
I am worry.
 
I do all command , but when I want run centos I see this
Code:
[COLOR=#000000][FONT=tahoma]Running as unit 100.scope.[/FONT][/COLOR]
[COLOR=#000000][FONT=tahoma]kvm: -drive file=/data/images/100/vm-100-disk-1.qcow2,if=none,id=drive-sata0,format=qcow2,cache=none,aio=native,detect-zeroes=on: Image is not in qcow2 format[/FONT][/COLOR]
[COLOR=#000000][FONT=tahoma]TASK ERROR: start failed: command '/usr/bin/systemd-run --scope --slice qemu --unit 100 -p 'CPUShares=1000' /usr/bin/kvm -id 100 -chardev 'socket,id=qmp,path=/var/run/qemu-server/100.qmp,server,nowait' -mon 'chardev=qmp,mode=control' -vnc unix:/var/run/qemu-server/100.vnc,x509,password -pidfile /var/run/qemu-server/100.pid -daemonize -smbios 'type=1,uuid=32cb53ae-ce89-4ed8-99e1-4cdfa9784257' -name CentOS -smp '4,sockets=1,cores=4,maxcpus=4' -nodefaults -boot 'menu=on,strict=on,reboot-timeout=1000' -vga cirrus -cpu kvm64,+lahf_lm,+sep,+kvm_pv_unhalt,+kvm_pv_eoi,-kvm_steal_time,enforce -m 1536 -k en-us -device 'pci-bridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e' -device 'pci-bridge,id=pci.2,chassis_nr=2,bus=pci.0,addr=0x1f' -device 'piix3-usb-uhci,id=uhci,bus=pci.0,addr=0x1.0x2' -device 'usb-tablet,id=tablet,bus=uhci.0,port=1' -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3' -iscsi 'initiator-name=iqn.1993-08.org.debian:01:d3f1e587de3a' -device 'ahci,id=ahci0,multifunction=on,bus=pci.0,addr=0x7' -drive 'file=/data/images/100/vm-100-disk-1.qcow2,if=none,id=drive-sata0,format=qcow2,cache=none,aio=native,detect-zeroes=on' -device 'ide-drive,bus=ahci0.0,drive=drive-sata0,id=sata0,bootindex=100' -drive 'file=/data/images/100/vm-100-disk-2.qcow2,if=none,id=drive-sata1,format=qcow2,cache=none,aio=native,detect-zeroes=on' -device 'ide-drive,bus=ahci0.1,drive=drive-sata1,id=sata1' -drive 'file=/var/lib/vz/template/iso/gparted-live-0.23.0-1-amd64.iso,if=none,id=drive-ide2,media=cdrom,aio=threads' -device 'ide-cd,bus=ide.1,unit=0,drive=drive-ide2,id=ide2,bootindex=200' -netdev 'type=tap,id=net0,ifname=tap100i0,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown' -device 'e1000,mac=3A:FD:9F:A0:AA:FB,netdev=net0,bus=pci.0,addr=0x12,id=net0,bootindex=300' -netdev 'type=tap,id=net1,ifname=tap100i1,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown' -device 'e1000,mac=86:A0:2D:4F:9D:FB,netdev=net1,bus=pci.0,addr=0x13,id=net1,bootindex=301'' failed: exit code 1[/FONT][/COLOR]
and centos can not run
I am worry.
Hi,
which format does the vm-hdd have?

Code:
file /data/images/100/vm-100-disk-1.qcow2
ls -lsa  /data/images/100/vm-100-disk-1.qcow2
Looks that you must define the output format
Code:
qemu-img convert -O qcow2  /data/images/100/vm-100-disk-1.raw /data/images/100/vm-100-disk-1.qcow2
If your VM-hdd still is in raw simply rename it before
Code:
mv/data/images/100/vm-100-disk-1.qcow2 /data/images/100/vm-100-disk-1.raw
Udo
 

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!