1

I'm using RHEL7 and here is my partition:

NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0             2:0    1    4K  0 disk
sda             8:0    0  100G  0 disk
├─sda1          8:1    0    1G  0 part /boot
└─sda2          8:2    0   39G  0 part
  ├─rhel-root 253:0    0   35G  0 lvm  /
  └─rhel-swap 253:1    0    4G  0 lvm  [SWAP]

As you can see, rhel-root is the root directory, whose size is 35G. The size of sda is 100G, which means that there is (100 - 39 - 1)G = 60G unused spaces.

How could I add the 60G spaces to the sda2 to increase the size of root directory?

Output of pvs:

  PV         VG   Fmt  Attr PSize   PFree
  /dev/sda2  rhel lvm2 a--  <39.00g    0

Output of vgs:

  VG   #PV #LV #SN Attr   VSize   VFree
  rhel   1   2   0 wz--n- <39.00g    0

Output of lvs:

  LV   VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root rhel -wi-ao---- <35.00g
  swap rhel -wi-ao----   4.00g
Yves
  • 3,291

1 Answers1

2

There are two approaches.

The first, sticking closely to your suggestion, is to resize sda2 to include the extra space:

  • use your favourite partitioning tool to change the end sector of the partition (see this answer for an example using sfdisk on an MBR-based partition table);
  • run pvresize /dev/sda2 to resize the PV.

This will make the extra space available in your VG, and you can then resize your LVs or create new LVs.

The second is to create a new partition:

  • again using your favourite partitioning tool, create a third primary partition, /dev/sda3, with all the available space;
  • run pvcreate /dev/sda3 to initialise it as a PV;
  • run vgextend rhel /dev/sda3 to add the PV to your VG.

It should be possible to do all this without rebooting...

Stephen Kitt
  • 434,908