qemu-img convert - resulted VM image too big

svacaroaia

Member
Oct 4, 2012
36
0
6
Hi,
I am migratting ( hyper-v) VHD to ( proxmox) raw

Part of the process is to convert the vhd into raw using
qemu-img convert -f vpc -O raw my_disk.vhd my_disk.raw

My problem is that the result of the conversion is always 32Gb regardless of the size of the vhd

Questions:
1. How do I resize / shrink the image ( all my Linux guests are using 5 Gb hard drives ) ?
I tried the following:
boot the Linux guest from systemrescue
use gparted and shrink the partition to 5 Gb
shut off vm
on host, ran qemu-img resize my_disk.img -28G
although all the above commands completed successfully, my image still remain at 32 Gb and , on the guest, fdisk -l /dev/vda1 still shows 32Gb
What am I missing ???

2. Is there a way to convert vhd to img while controlling / specifying the img size ??

3. is there a better /smarter way to migrate Linux guests from Hyper-v to Proxmox than physically copying the vhd, converted then added to newly created proxmox VM ?

Thanks
Steven
 
Mir,
thanks for taking the trouble to provide some guidance
However it is still unclear to me what should I do although I read the redhat document

When you say "resize the filesystem inside the image" aren't you referring to using gparted or something similar on the guest ?
If yes, I already did that ...if no, please elaborate a bit

Thanks
Steven
 
Mir,
thanks for taking the trouble to provide some guidance
However it is still unclear to me what should I do although I read the redhat document

When you say "resize the filesystem inside the image" aren't you referring to using gparted or something similar on the guest ?
If yes, I already did that ...if no, please elaborate a bit

Thanks
Steven
When I talk about resize filesystem inside the image a mean:
1a) Start the server with the converted image
1b) Start a live distribution like sysrescuecd or gparted live in virtualbox/wmware etc. with the image available <-- the recommended way
2) Use the tools for resize a filesystem which the current filesystem provides (for ext3 and ext4 the tool is resize2fs)

So for ext3 and ext4 using sysrescuecd or gparted live with the image recognized as /dev/sda1 and size 32G reducing to 5G:
1) e2fsck -f /dev/sda1
2) resize2fs -p /dev/sda1 5G
3) e2fsck -f /dev/sda1
4) qemu-img resize my_disk.img -28G

That should do it but as a precaution make a backup before you start.
 

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!