Problems understanding LVM configuration in Rhat 7 that needs to be extended

I inherrited a server which is running out of space and need some help understand it’s configuration before I take action.

I need to extend a logical volume without rebooting the server.
LVS shows that volume named RHEL which is 295.62g in size.
LSBLK shows that I actually have two partitions that are 295.6 in size, so I thought it was in mirror mode,but LVS does not reflect this. So how is this setup? is rhel effectively using both partitions? how can I verify this?

Also, I see an sdb disk that has no partitions, so my plan is to create a partition there and add it to the LVM but first I would like to understand how /sda2/rhel-root and sda3/rhel-root are working… makes no sense at all to have mirroring on the same disk! Surely cannot be that.

# lvs 
  LV   VG   Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root rhel -wi-ao---- <295,62g                                                    
  swap rhel -wi-ao----   <3,38g                                                    
# lsblk
NAME          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda             8:0    0   400G  0 disk 
├─sda1          8:1    0     1G  0 part /boot
├─sda2          8:2    0    39G  0 part 
│ ├─rhel-root 253:0    0 295,6G  0 lvm  /
│ └─rhel-swap 253:1    0   3,4G  0 lvm  [SWAP]
└─sda3          8:3    0   360G  0 part 
  └─rhel-root 253:0    0 295,6G  0 lvm  /
sdb             8:16   0   200G  0 disk 
# vgdisplay -v rhel
  --- Volume group ---
  VG Name               rhel
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  10
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               298,99 GiB
  PE Size               4,00 MiB
  Total PE              76542
  Alloc PE / Size       76542 / 298,99 GiB
  Free  PE / Size       0 / 0   
  VG UUID               mDkink-qzyl-2KyS-DG5T-tf55-4it5-eGNqx3
   
  --- Logical volume ---
  LV Path                /dev/rhel/root
  LV Name                root
  VG Name                rhel
  LV UUID                U4AI2b-eadM-TczV-g4ff-gudE-JWiU-dbz5sT
  LV Write Access        read/write
  LV Creation host, time sms-linux-image.novalocal, 2021-07-01 17:16:09 -0400
  LV Status              available
  # open                 1
  LV Size                <295,62 GiB
  Current LE             75678
  Segments               3
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
   
  --- Logical volume ---
  LV Path                /dev/rhel/swap
  LV Name                swap
  VG Name                rhel
  LV UUID                jSxEFM-frWb-MtJw-ae1g-Omfv-VNHD-SzbGt5
  LV Write Access        read/write
  LV Creation host, time sms-linux-image.novalocal, 2021-07-01 17:16:09 -0400
  LV Status              available
  # open                 2
  LV Size                <3,38 GiB
  Current LE             864
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
   
  --- Physical volumes ---
  PV Name               /dev/sda2     
  PV UUID               vscfjc-VcNp-Kwdv-JjuB-gtbP-2SsB-6iq6td
  PV Status             allocatable
  Total PE / Free PE    9983 / 0
   
  PV Name               /dev/sda3     
  PV UUID               yLqH6J-EQc9-FZBS-2MTr-Tams-7Mhn-hSSXAM
  PV Status             allocatable
  Total PE / Free PE    66559 / 0
Asked By: user186057

||

LSBLK shows that I actually have two partitions that are 295.6 in size…

It doesn’t, actually:

├─sda2          8:2    0    39G  0 part 
...
└─sda3          8:3    0   360G  0 part 

It shows that sda2 is 39G, and sda3 is 360G. This is reflected in the information from vgdisplay, which shows:

  --- Physical volumes ---
  PV Name               /dev/sda2     
  PV UUID               vscfjc-VcNp-Kwdv-JjuB-gtbP-2SsB-6iq6td
  PV Status             allocatable
  Total PE / Free PE    9983 / 0
   
  PV Name               /dev/sda3     
  PV UUID               yLqH6J-EQc9-FZBS-2MTr-Tams-7Mhn-hSSXAM
  PV Status             allocatable
  Total PE / Free PE    66559 / 0

Look at the Total PE / Free PE. PE stands for "Physical Extent". An extent is usually 4MB, so the Total PE corresponds roughly to the partition sizes we see from lsblk.

So how is this setup? is rhel effectively using both partitions? how can I verify this?

You can verify that rhel is using both partitions from the
vgdisplay output, which shows that both partitions are members of
the rhel volume group (and that both are fully allocated).

Also, I see an sdb disk that has no partitions, so my plan is to create a partition there and add it to the LVM but first I would like to understand how /sda2/rhel-root and sda3/rhel-root are working… makes no sense at all to have mirroring on the same disk! Surely cannot be that.

They are not mirrored (and couldn’t be, given the difference in size).
They are simply two chunks of space being consumed by the VG.

You don’t need to create any partitions on sdb. You’re better off
just adding the entire disk to the VG:

# pvcreate /dev/sdb
# vgextend rhel /dev/sdb
Answered By: larsks

This is just a quirk of how lsblk displays filesystems that are located partly on one device and partly on another.

The total size of the root filesystem is 295,6G exactly as displayed. Now, since it’s on LVM, part of the filesystem is within LVM PV sda2 and the other part is within sda3… but since lsblk does not currently do a deep analysis of LVM, it doesn’t know how big each part of it is. And because the SIZE column is understood to mean the size of the device, it shows the size of the /dev/mapper/rhel-root device, even though the device is not fully contained in one physical partition, and so lsblk must list that device twice.

You might want to run lsblk -s to show the listing in a filesystem-centric way rather than the default device-centric way, and see if it helps you visualize what is going on.

Having said that, it appears the sda3 partition is 360G in size while the entire rhel VG is just 298,99G. This might be the result of a previous incomplete partition resizing operation on sda.

Try this:

partprobe /dev/sda   # to ensure the kernel has up-to-date view of the partition table
pvresize /dev/sda3   # to extend the LVM PV at sda3 to fill the entire partition if it's currently smaller
vgs                  # to see if the rhel VG now has free space available

If this makes some space available (= VFree in the vgs output is not 0), you could then use the capacity by extending the LV(s) as required. For example, to put all the available capacity of the rhel VG into the root filesystem:

lvextend --resizefs -l +100%FREE /dev/mapper/rhel-root
Answered By: telcoM
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.