Reduce RAW size in VM disk

reachmedia

Active Member
Jan 24, 2018
19
2
43
43
Hi all,

Need some guidance on how to reduce the size of the VM disk as I have mistakenly increased by more than 1+ TB.

Current HDD is only 4TB and I'm afraid it will crash.

It is currently running Windows Server 2012 R2 with 2.6TB allocated (this was done before the VM resize).

Thanks

AC
 

Attachments

  • resize pix 2.JPG
    resize pix 2.JPG
    37.1 KB · Views: 201
  • resize pix 1.JPG
    resize pix 1.JPG
    16.8 KB · Views: 195
Hi,

See man qemu-img resize.
Be sure that the fs in the raw file is not larger than the raw file.
Because if you make the raw file smaller than the fs inside you will lose your data.
 
Hi all,

I did work with qemu-img resize to shrink the raw VM disk, it says that the operation was successful, but when I do qemu-img info, I get that the HDD is still 300 GB (btw, I'm trying to reduce from 300 to 150 GB).

1570568971104.png

Thanks a lot to all

P.S. I need to do this, so the LVM-thin will have space, as I'm moving physical as well as Virtual servers to Proxmox.
 
  • Like
Reactions: android25
Hi all

after googling and reading a bit more, I found out thanks to this other post that my VMs HDD are LVs, so I did that, after resizing it with qemu-img and now all is working great.

Thanks a lot
 
Ok, so I accidentally made thin provisioned disk 2000g on a 220g disk. NBD, just resize it. Oh, proxmox ui doesn't let you do negative resize in the UI. Ok, shell time:

Bash:
vzdump 101 --dumpdir /mnt/backup/my_dump --mode stop
root@proxmox:~# pct stop 101
root@proxmox:~# qemu-img resize /zedeffess/ct_volumes/images/101/vm-101-disk-0.raw 10G
WARNING: Image format was not specified for '/zedeffess/ct_volumes/images/101/vm-101-disk-0.raw' and probi
ng guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will
be restricted.
Specify the 'raw' format explicitly to remove the restrictions.
qemu-img: Use the --shrink option to perform a shrink operation.
qemu-img: warning: Shrinking an image will delete all data beyond the shrunken image's end. Before perform
ing such an operation, make sure there is no important data there.
root@proxmox:~# qemu-img resize --shrink /zedeffess/ct_volumes/images/101/vm-101-disk-0.raw 10G
WARNING: Image format was not specified for '/zedeffess/ct_volumes/images/101/vm-101-disk-0.raw' and probi
ng guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will
be restricted.
Specify the 'raw' format explicitly to remove the restrictions.
Image resized.
root@proxmox:~# pct start 101
run_buffer: 322 Script exited with status 255
lxc_init: 844 Failed to run lxc.hook.pre-start for container "101"
__lxc_start: 2027 Failed to initialize container "101"
startup for container '101' failed

Well that'll be fun to fix in a minute.
 

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!