I have a CentOS VMs running in VMware, one of the VMs I was running was out of disk space. The disk was originally 85GB, I tried to increase it to 345GB. In an effort to increase the disk size, I tried:
- Shutdown the VM
- Increase the size of the disk
- Power on the VM
- Use parted to resize the partition
Unfortunately, step 4 did not work, parted complained that it could not detect the filesystem:
# parted GNU Parted 2.1 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print Model: VMware Virtual disk (scsi) Disk /dev/sda: 344GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 1049kB 538MB 537MB primary ext4 boot 2 538MB 85.9GB 85.4GB primary lvm (parted) resize WARNING: you are attempting to use parted to operate on (resize) a file system. parted's file system manipulation code is not as robust as what you'll find in dedicated, file-system-specific packages like e2fsprogs. We recommend you use parted only to manipulate partition tables, whenever possible. Support for performing most operations on most types of file systems will be removed in an upcoming release. Partition number? 2 Start? [538MB]? End? [85.9GB]? 344GB Error: Could not detect file system.
It looks like parted does not like LVM. The next thing that I did is to add a new partition, then use ‘pvcreate’ to create a new physical extent, and then add that to the volume group, as seen below:
# parted GNU Parted 2.1 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print Model: VMware Virtual disk (scsi) Disk /dev/sda: 344GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 1049kB 538MB 537MB primary ext4 boot 2 538MB 85.9GB 85.4GB primary lvm (parted) mkpart Partition type? primary/extended? primary File system type? [ext2]? Start? 85.9 End? 344GB Warning: You requested a partition from 85.9MB to 344GB. The closest location we can manage is 85.9GB to 344GB. Is this still acceptable to you? Yes/No? yes Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. (parted) print Model: VMware Virtual disk (scsi) Disk /dev/sda: 344GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 1049kB 538MB 537MB primary ext4 boot 2 538MB 85.9GB 85.4GB primary lvm 3 85.9GB 344GB 258GB primary (parted) quit #ls -l /dev/sda sda sda1 sda2 sda3 # pvcreate /dev/sda3 dev_is_mpath: failed to get device for 8:3 Physical volume "/dev/sda3" successfully created # pvs PV VG Fmt Attr PSize PFree /dev/sda2 vg0 lvm2 a-- 79.50g 0 /dev/sda3 lvm2 a-- 240.00g 240.00g # vgextend vg0 /dev/sda3 Volume group "vg0" successfully extended # vgs VG #PV #LV #SN Attr VSize VFree vg0 2 4 0 wz--n- 319.49g 240.00g