I have a Hyper-V server (host). With a CentOS6.x VM (guest).
My goal is:
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?
You can use two approaches:
/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./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
 Romeo NinovUser contributions licensed under CC BY-SA 3.0