increasing hdd size for guest

abubin

New Member
May 17, 2014
12
0
1
This is one of the feature that is important when using a VM.

I created a standard centos guest with 32GB and it's IDE.

Now I want to increase the volume size. I shutdown the guest. Next, I tried using the resize function in the GUI. After than I can see the size increased in the proxmox gui.

After that I start up the server and it starts fine. I use fdisk:

Code:
[root@localhost ~]# fdisk -l

Disk /dev/sda: 39.7 GB, 39728447488 bytes
255 heads, 63 sectors/track, 4830 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ab504


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        4178    33041408   8e  Linux LVM


Disk /dev/mapper/VolGroup-lv_root: 32.8 GB, 32791068672 bytes
255 heads, 63 sectors/track, 3986 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000




Disk /dev/mapper/VolGroup-lv_swap: 1040 MB, 1040187392 bytes
255 heads, 63 sectors/track, 126 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

I can see the size of /dev/sda has increased. However, I tried using lvextend or lvresize or vgresize and so on to extend the LVM size without success.

Code:
[root@localhost ~]# vgdisplay  --- Volume group ---
  VG Name               VolGroup
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               31.51 GiB
  PE Size               4.00 MiB
  Total PE              8066
  Alloc PE / Size       8066 / 31.51 GiB
  Free  PE / Size       0 / 0
  VG UUID               1q01KM-sIal-wXTi-YT4A-Esva-iU3M-nCCSUv

See, it is showing no Free space available.

Anyone can help? I have been googling around but this is so confusing. A lot of the tutorial told about using qemu-img to convert the vm to raw then increase the size and dd into the new storage and then convert back to qcow. If that is the case, what is the resize function for in the GUI?

I have also tried the commandline method of qemu-img and dd. However, once I created the new image, how do I add it back into the VM?
 
Had a similar issue trying to figure this out.Main issue, you cannot resize a partition while it is mounted. The problem is you can't unmount a root filesystem.
Which leaves a problem. How do you increase LVM without the partition increase
I have three solutions
1. Create a new "Hard Drive" instead of increasing the mounted hard drive. Then you can add the new hard drive and partition to the current LVM
2. Download a rescue disk and boot your VM into the rescue disk. This way the filesystem is not mounted on the partition, and you can increase the partition to allow free space on the LVM.
3. Create a new hard drive and mount it to a specific location for your needs. This is the route I took, as I needed a specific mount point to have the new file system. This also allows me to umount the new partition, grow it, then remount it.
 
hmm..what about starting up the guest linux on a single user mode? That way the root filesystem can also be unmounted.
 
Had a similar issue trying to figure this out.Main issue, you cannot resize a partition while it is mounted. The problem is you can't unmount a root filesystem.
Which leaves a problem. How do you increase LVM without the partition increase
I have three solutions
1. Create a new "Hard Drive" instead of increasing the mounted hard drive. Then you can add the new hard drive and partition to the current LVM
2. Download a rescue disk and boot your VM into the rescue disk. This way the filesystem is not mounted on the partition, and you can increase the partition to allow free space on the LVM.
3. Create a new hard drive and mount it to a specific location for your needs. This is the route I took, as I needed a specific mount point to have the new file system. This also allows me to umount the new partition, grow it, then remount it.

Thanks for the simple guide. I manage to google around and found this tutorial that most resemble to what you describe. Except I did the extension on the system itself which is a bit risky. Better is to use livecd to extend the partition.

http://rbgeek.wordpress.com/2013/01/27/how-to-extend-the-root-partition-in-lvm/

However, this method is adding of another partition into the LVM instead of extending the existing LVM partition. Is there no way to do this easily?

I felt resizing of partition need to be documented well because this is one of the most basic thing that we often do for a VM. Be it windows or linux or freebsd. I hope someone can write a good documentation for this as it would really help the community.

Thanks for now.

Anyone found a better method, please feel free to chime in.
 
When you have a contained filesystem on the guest, like QCOW, expanding the qcow size will not automatically increase the Guest disk usage.
Similar to what spirit said, you can utilize raw filesystems and gain the functionality, but you lose the cluster/migration functionality of QCOW.
With Windows, it is very simple to increase the software usage of the new disk, because the disk size is essentially larger. The partition is the issue. Windows will resize the partition live, using the storage tab under "Manage". The same windows as the Device Manager, just a different tab.
Linux is a little more intricate with mounted filesystems. If you don't want to boot into a Linux Rescue disk, you can boot your system into Single User Mode from the GRUB options, and remount with rw.
Code:
mount -o remount,rw /partition/identifier /mount/point
Code:
mount -o remount,rw /code]

As for a Wiki writeup or something, I will do what I can, as I have never done one before, but you have to remember; this is specific to the Guest OS, and not as much with Proxmox. I'm not sure how relevant this will be to Proxmox, so I'm not sure the devs will approve it for the Wiki.
The same thing applies to containers as far as RAW filesystems. You can increase HDD usage in a container Live. As well as RAM and CPU. All Live.
 

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!