I have cent-os 7 installed on an ssd with capacity 160GB. The Cent-os partitions only consume 20GB in total, such that when I run fdisk -l this is my output:

Disk /dev/sda: 171.8 GB, 171798691840 bytes, 335544320 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000a2b1e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    41943039    20458496   8e  Linux LVM

Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/centos-root: 18.8 GB, 18798870528 bytes, 36716544 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

When I try to run pvs I get the following:

  PV         VG     Fmt  Attr PSize  PFree
  /dev/sda2  centos lvm2 a--  19.51g    0

What steps do I need to take in order to get CentOS to recognise the full 160GB physical volume, and then be able to either extend centos-root directly or first create another logical partition (of size 140GB), remove it and then allow centos-root to expand into the that space?

Apologies if my terminology is incorrect, I'm not a Linux expert.

  • create other partition and add that partition to your volume group and than you can extend the logical volume and after the filesystem
    – c4f4t0r
    Sep 29 '16 at 13:44
  • @c4f4t0r, partition /dev/sda2 already holds the bulk of the disk's space as a lvm partition. But he's only showing two volumes within the volume group.
    – Jeter-work
    Sep 29 '16 at 14:24

Your physical volume is 19.51g with no free space (pvs results). So you first have to resize the physical volume.

pvresize /dev/sda2

Then you need to resize the logical volume centos-root to fill all the free space.

lvresize -l +100%FREE /dev/mapper/centos-root

Now its time for the filesystem. Its not obvious what filesystem you are using but i bet that its either ext4 or xfs.

In the first case:

resize2fs /dev/mapper/centos-root

In the second case:

xfs_growfs /
  • This worked great for me on Centos 7 with xfs filesystem.
    – Lucas
    Oct 2 '17 at 23:10
  • @Vikelidis Kostas I got error [root@casc-centos-test-01 ~]# pvresize /dev/xvdb Failed to find physical volume "/dev/xvdb" 0 physical volume(s) resized / 0 physical volume(s) not resized why is that ? Oct 7 '18 at 4:58

man lvm and lvm --help. And of course google "resize lvm".

The physical partition /dev/sda2 holds all the space, 171.8 GB, but you've only listed two volumes totaling about 21 GB. You should be able to resize /dev/mapper/centos-root to hold all of the available space. If this is a default centos 7 install, the bulk of the space was assigned to /dev/mapper/centos-home and mounted as /home. But fdisk -l does not show this so maybe you did a custom install? There's LVM commands to list and manipulate the Physical volumes, Volume Groups and Logical Volumes.

This may be as simple as a lvm extend volume command. If you do go that route, be sure you use the switch to expand the filesystem too. It'll save you some heartache.

Here's an excellent tutorial on how to create PV, VG and LV on CentOS/RHEL7. Read through that and then google how to resize a volume.

  • Ah, I forgot to mention that this is a Bitnami CentOS image, so yes it's a custom install. There is no /home. What do I do in this case?
    – ugotchi
    Sep 29 '16 at 14:23
  • That just explains why the bulk of the space is not assigned to /home. Research how to use lvm to examine what has become of the extra 150 GB that are part of the LVM partition but not represented in your listing. Also, check your mount table (/etc/fstab) to see where the lvm groups are actually being mounted. Using LVM commands you should be able to list the partitions, volumes, etc.
    – Jeter-work
    Sep 29 '16 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.