[SOLVED] Disk Resize issue

reetp

Renowned Member
Aug 19, 2013
67
11
73
I needed to resize the disk in a VM.

I went to resize and mistakenly entered the required size, and not the increase in size. Doh.... it's way to easy to do that.... :-(

The original was about 450gb and I added 750Gb by mistake - I actually wanted it to be 750Gb but the OS now can see 1342Gb !

I now have this as the actual image:

702G vm-100-disk-1.qcow2

The OS currently has:

df -h
/dev/vda3 488G 427G 37G 93% /

It can see the remaining space:

fdisk -l /dev/vda

Disk /dev/vda: 1342.2 GB, 1342177280000 bytes

I have not tried to resize the partition.

I clearly can't just set the config to 750Gb - I presume I am going to have to try and go qm resize?

Any suggestion on how I can get to my required 750Gb without starting over ?
 
Addendum

Whist playing about I did set the config directly to 750G

qm list
VMID NAME STATUS MEM(MB) BOOTDISK(GB) PID
100 Home running 8192 750.00 1270

So qm thinks it is 750, but the OS and gparted can see 1342.

Question is how to get it all back to one figure....

Ahhh - OK - I was reading the man page for qm here https://pve.proxmox.com/pve-docs/qm.1.html

qm rescan

qm list
VMID NAME STATUS MEM(MB) BOOTDISK(GB) PID
100 Home running 8192 1250.00 1270

So now we can see the allocated size correctly. So I think what I need to do now is resize it back down taking about 500Gb off which is still more than before.
 
Except damn - it doesn't loo like you can
qm resize <vmid> <disk> <size> [OPTIONS]

The disk you want to resize.

<size>: \+?\d+(\.\d+)?[KMGT]?
The new size. With the + sign the value is added to the actual size of the volume and without it, the value is taken as an absolute one. Shrinking disk size is not supported.


That's at odds with the wiki https://pve.proxmox.com/wiki/Resize_disks

"Shrinking disks is not supported by the PVE API and has to be done manually."

So what options do I have to get this back to down to a manageable size?
 

Yes, but I am not sure that is the case here.

I need to shrink the size of the disk the OS *thinks* it has.

Yes, I am sure it has some overhead - hence the OS has a drive of about 488Gb and the qcow2 file is about 700Gb

The problem is the VM now thinks it has a 1342Gb disk with a load of free space for expanding the partition.

I just don't want it to have THAT much space as I don't have room for it all if it grows that big.

I created a test as follows:

Create 32Gb disk
Resize +12G to 50Gb

Now try and resize down:

qm resize 1004 virtio0 35G
"shrinking disks is not supported"

So, really bad you can make such a simple mistake in the interface - no "are you sure you want the new size to be X" - and worse no easy way to undo that that mistake even though nothing has been altered.

Any suggestion greatly appreciated.
 
Yes, but I am not sure that is the case here.

Oh sorry, I only skimmed over the article and missed that it does not resize your disk.

The only way I know is to convert the image to raw, resize it and convert it back - this works like a charm if you do not have changed anything inside of your VM concerning the partition layout.
 
Oh sorry, I only skimmed over the article and missed that it does not resize your disk.

NP !!

The only way I know is to convert the image to raw, resize it and convert it back - this works like a charm if you do not have changed anything inside of your VM concerning the partition layout.

Damn. I don't have enough disk space to do that. No, I've not changed anything, but as per my test when converting to raw it will create an image of the New disk size. So.

Qcow2 = 700Gb
Convert to raw = 1342Gb
Resize down to 750Gb
Convert to qcow = 500Gb (current vm data size)

That's 3.2Tb if you preserve images for backup as you go. I have nowhere near that much space.

Even just converting to raw will be 2Tb (700+1342) and I'm not sure I even have that (need to check)

That's insane... particularly as the mistake was allowed to happen so easily....

:crying:
 
Mate just had an idea.

Create new HD at size required.

Boot vm with clonezilla (or live disk with say dd)

Clone old partitions (not entire drive) to new drive.

Reboot with new drive to check it is ok. Should now be my new 750Gb drive with 500Gb data and space to resize the partition.

Boot with gparted live. Resize partitions on new drive as appropriate.

Reboot to new drive.

I'd also guess that with a qcow2 image it will clear out all the old detritus?

Logical?
 
I should be ok.

Current qcow2 is 700Gb but only contains 500Gb data.

I'd have space to cope with a 750Gb raw drive to copy to.
 
Well, to follow up, all good.

Created a 750G qcow2 file

Ran with gparted and both partitions and copied the partitions over with sfdisk eg

sfdisk -d /dev/vda > sfdisk_vda.output
sfdisk /dev/vdb < sfdisk_vda.output

So I now have the right partitions.

Ran clonezilla and very gingerly copied the partitions over one at a time
(my RAID 6 '6 x 750Gb drive' array took about 2 1/2 hours to copy 500Gb data)

Rebooted with the OS installer disc in rescue mode to sort out grub properly

Rebooted, and barring a few self inflicted odds & sods like UUID on swap (I changed fstab to the real partition /dev/vda2 and then put the new UUID in after) it all worked straight away.

Class, and thanks.
 
Facing a similar issue.
I'm learning the hard way that not only does Proxmox give you enough rope to hang yourself, it provides the gallows, hangman, and getting started guide.
I'm sure some facets of the product are intentionally designed to sell support! <cynical>
 
I'm learning the hard way that not only does Proxmox give you enough rope to hang yourself, it provides the gallows, hangman, and getting started guide.
I'm sure some facets of the product are intentionally designed to sell support! <cynical>
I'm glad you appreciate all the features that come with Proxmox. Personally, I really like the integration with PBS and all the backups of backups that it makes very easy. ;-)
 

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!