Find centOS version:
cat /etc/centos-releaseRHEL:
cat /etc/redhat-releaseIf your starting from scratch, ‘imaging’ or installing linux , insure you’ve partitioned with setup LVM on the first disk for this guide. As this is just the basic setup.
Once you’ve reached the command line, you can run lsblk to list all block devices, noticing what is a partition and what is a device, where sda would be a device, and sda1 would be a partition:
lsblk
Output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 243M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 465.5G 0 part
├─bak10--vg-root 254:0 0 465.5G 0 lvm /
└─bak10--vg-swap_1 254:1 0 4G 0 lvm [SWAP]
sdb 8:16 0 465.8G 0 disk
Once you know the device you want to expand the LVM (Logical Volume Management) in this case ‘sdb’
Take care to notice, there are many disk identifiers aka ‘sda’ depending on the specific distro you are using
First you’ll want to install the required tools:
sudo apt-get install system-config-lvm
Then run:
sudo vgdisplay
In this case the LVM has already been expanded, either way, take note of the volume group, which you would have been prompted to define during the OS install.
We can see here as the volume group as ‘VG Name’ bak10-vg
Output:
--- Volume group ---
VG Name bak10-vg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
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 931.28 GiB
PE Size 4.00 MiB
Total PE 238407
Alloc PE / Size 238407 / 931.28 GiB
Free PE / Size 0 / 0
VG UUID I3z4RM-RAsq-HfPD-FiUo-KxOZ-Jpsg-zROJPt
We also need the logical volume root path, this can be found by running:
sudo lvdisplay
We can see the volume group root path is ‘LV Path /dev/bak10-vg/root’ Output:
--- Logical volume ---
LV Path /dev/bak10-vg/root
LV Name root
VG Name bak10-vg
LV UUID ykeSJi-Q1mw-dWui-5D7p-Lr1y-wk18-swWVN8
LV Write Access read/write
LV Creation host, time bak10, 2016-12-24 10:43:48 -0500
LV Status available
# open 1
LV Size 927.28 GiB
Current LE 237383
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
--- Logical volume ---
LV Path /dev/bak10-vg/swap_1
LV Name swap_1
VG Name bak10-vg
LV UUID URTRk2-lcke-7oq6-TAtK-EGg8-qyTf-pAmr9Z
LV Write Access read/write
LV Creation host, time bak10, 2016-12-24 10:43:48 -0500
LV Status available
# open 2
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
Now we convert the disk ‘sdb’ into a physical volume by running:
sudo pvcreate /dev/sdb
Then we add the physical volume to the volume group by extending the existing volume group to the second disk:
sudo vgextend bak10-vg /dev/sdb
Then we allocate the physical volume to the logical volume. You can allocate a specific partition or percentage of the new disk, however this is basic by adding the complete disk:
sudo lvextend -l +100%FREE /dev/bak10-vg/root
Now we must resize the volume group to the new physical drive:
sudo resize2fs /dev/bak10-vg/root
The LVM has been expanded to the second disk ‘/dev/sdb’, where the first disk contains a default and basic partitioning scheme :
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 243M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 465.5G 0 part
├─bak10--vg-root 254:0 0 927.3G 0 lvm /
└─bak10--vg-swap_1 254:1 0 4G 0 lvm [SWAP]
sdb 8:16 0 465.8G 0 disk
└─bak10--vg-root 254:0 0 927.3G 0 lvm /
None the less, we can see the two available physical disks ‘sda and sdb’ are now part of one file system.
Where sda contains necessary basic partitions, and the second disk is now part of the volume group as usable space.
Fin! Enjoy your new space!