0

I have a Hyper-V server (host). With a CentOS6.x VM (guest).

My goal is:

  • expand the /dev/mapper/VolGroup-lv_root partition to a total 200GB;
  • expand the /dev/mapper/VolGroup-lv_swap partition to a total 100GB;
  • create another logical mount within VolGroup, called /dev/mapper/VolGroup-lv_data with the remainder of the disk (IE: roughly ~250GB)

I successfully expanded the disk on the guest (centos6) in the hyper-v manager. Then when I boot the VM (centos6) back up, and run a few commands - I am getting something really strange. It appears that CentOS does - but also does not detect the new 500GB space I gave it.

Running df -h and fdisk -l produces the following:

# fdisk -l

Disk /dev/sda: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000a3c9d

   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        1045     7875584   8e  Linux LVM

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


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


# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      6.5G  2.2G  4.1G  35% /
tmpfs                 7.9G     0  7.9G   0% /dev/shm
/dev/sda1             477M  128M  324M  29% /boot

So apparently the VM can, sortof, detect the 500GB because it shows up in fdisk - but there is no partition, no unallocated space, and it does not detect it in df. Every guide and question on this topic points to using something like gparted and pvcreate and xfs_growfs and such commands - none of which work on my end and they require some kind of unallocated mount header in fdisk, which mine is not providing.

Yes the server this is on has a maximum expansion of 27TB for this specific VM so space is not the issue - and hyper-v fully believes this disk (vhdx) to be 536.9GB (or whatever roughly) as stated in fdisk.

Ideas?

efraimip
  • 13
  • 3
  • Resizing the VHD does not automatically resize the partitions, or LVM PVs or LVM LVs, or resize the filesystem. You must do those each of those steps manually. – Zoredache Jun 20 '19 at 21:43
  • https://serverfault.com/questions/924155/need-help-expanding-space-on-a-debian-virtual-server https://serverfault.com/questions/424678/how-to-resize-root-lvm-partition-in-fedora-without-livecd-or-rebooting https://serverfault.com/questions/38542/ubuntu-resize-the-root-lvm2-partition https://serverfault.com/questions/307030/centos-xen-resizing-domu-partition-and-volume-group ... Also see google for pvresize, lvresize, etc. – Zoredache Jun 20 '19 at 21:53

1 Answers1

0

You can use two approaches:

  1. Extend the partition /dev/sda2 to the desired size, then extend the PV. And this will extend the VG which will give you the option to extend the LV ot create new one.
  2. Or create new partition /dev/sda3 with desired size, create it as PV with pvcreate command and add it to the VG.

If you do not want to deal with LVM you can create new partition, then create filesystem and mount it on the desired mountpoint

Do not forget, you have maximum of 4 partition (primary/extended).

Romeo Ninov
  • 3,195
  • 2
  • 13
  • 16
  • 1
    Thanks! -- I ended up following this guide: https://www.miarec.com/doc/administration-guide/doc1014 ----- like you said, I didnt realize that the VM needed to manually create the partitions as it doesnt get any partition information from the host. – efraimip Jun 21 '19 at 21:56