Monday, April 20, 2015

How to add new disk to LVM in CentOS7.1

On fresh CentOS/RHEL 7, you need to install System Storage Manager first.
sudo yum install system-storage-manager

First, let's check information about available hard drives and LVM volumes. The following command will show information about existing disk storage devices, storage pools, LVM volumes and storage snapshots. The output is from fresh CentOS 7 installation which uses LVM and XFS file system by default.

sudo ssm list 
ssm list
-------------------------------------------------------------
Device        Free       Used      Total  Pool    Mount point
-------------------------------------------------------------
/dev/sda                       200.00 GB          PARTITIONED
/dev/sda1                        3.91 GB          /boot
/dev/sda2  4.00 MB  196.08 GB  196.09 GB  centos
/dev/sdb                        16.00 GB
/dev/sdc                        30.00 GB
/dev/sdd                        40.00 GB
-------------------------------------------------------------
----------------------------------------------------
Pool    Type  Devices     Free       Used      Total
----------------------------------------------------
centos  lvm   1        4.00 MB  196.08 GB  196.09 GB
----------------------------------------------------
------------------------------------------------------------------------------------
Volume            Pool    Volume size  FS     FS size      Free  Type    Mount point
------------------------------------------------------------------------------------
/dev/centos/swap  centos      3.91 GB                            linear
/dev/centos/usr   centos     40.81 GB  ext4  40.81 GB  36.30 GB  linear  /usr
/dev/centos/root  centos     78.12 GB  ext4  78.12 GB  72.79 GB  linear  /
/dev/centos/home  centos     58.59 GB  ext4  58.59 GB  54.57 GB  linear  /home
/dev/centos/var   centos     14.65 GB  ext4  14.65 GB  13.28 GB  linear  /var
/dev/sda1                     3.91 GB  ext4   3.91 GB   3.47 GB  part    /boot
------------------------------------------------------------------------------------
 

in this example  /dev/sdb,/dev/sdc and
/dev/sdd  i added hard drive in CentOS7.1 VM in VMWare Vsphere

my pool name is centos i will add these three drive to my pool
sudo ssm add -p centos /dev/sdb /dev/sdc /dev/sdd

and now list

 ssm list
--------------------------------------------------------------
Device         Free       Used      Total  Pool    Mount point
--------------------------------------------------------------
/dev/sda                        200.00 GB          PARTITIONED
/dev/sda1                         3.91 GB          /boot
/dev/sda2   4.00 MB  196.08 GB  196.09 GB  centos
/dev/sdb   16.00 GB    0.00 KB   16.00 GB  centos
/dev/sdc   30.00 GB    0.00 KB   30.00 GB  centos
/dev/sdd   40.00 GB    0.00 KB   40.00 GB  centos
--------------------------------------------------------------
-----------------------------------------------------
Pool    Type  Devices      Free       Used      Total
-----------------------------------------------------
centos  lvm   4        85.99 GB  196.08 GB  282.07 GB
-----------------------------------------------------
------------------------------------------------------------------------------------
Volume            Pool    Volume size  FS     FS size      Free  Type    Mount point
------------------------------------------------------------------------------------
/dev/centos/swap  centos      3.91 GB                            linear
/dev/centos/usr   centos     40.81 GB  ext4  40.81 GB  36.30 GB  linear  /usr
/dev/centos/root  centos     78.12 GB  ext4  78.12 GB  72.79 GB  linear  /
/dev/centos/home  centos     58.59 GB  ext4  58.59 GB  54.57 GB  linear  /home
/dev/centos/var   centos     14.65 GB  ext4  14.65 GB  13.28 GB  linear  /var
/dev/sda1                     3.91 GB  ext4   3.91 GB   3.47 GB  part    /boot
------------------------------------------------------------------------------------
 



now we can see these three drives are part of my lVM pool centos

Now , i will increase the size of my var and list again

sudo ssm resize -s+5G /dev/centos/var

ssm list
--------------------------------------------------------------
Device         Free       Used      Total  Pool    Mount point
--------------------------------------------------------------
/dev/sda                        200.00 GB          PARTITIONED
/dev/sda1                         3.91 GB          /boot
/dev/sda2   0.00 KB  196.09 GB  196.09 GB  centos
/dev/sdb   11.00 GB    5.00 GB   16.00 GB  centos
/dev/sdc   30.00 GB    0.00 KB   30.00 GB  centos
/dev/sdd   40.00 GB    0.00 KB   40.00 GB  centos
--------------------------------------------------------------
-----------------------------------------------------
Pool    Type  Devices      Free       Used      Total
-----------------------------------------------------
centos  lvm   4        80.99 GB  201.08 GB  282.07 GB
-----------------------------------------------------
------------------------------------------------------------------------------------
Volume            Pool    Volume size  FS     FS size      Free  Type    Mount point
------------------------------------------------------------------------------------
/dev/centos/swap  centos      3.91 GB                            linear
/dev/centos/usr   centos     40.81 GB  ext4  40.81 GB  36.30 GB  linear  /usr
/dev/centos/root  centos     78.12 GB  ext4  78.12 GB  72.79 GB  linear  /
/dev/centos/home  centos     58.59 GB  ext4  58.59 GB  54.57 GB  linear  /home
/dev/centos/var   centos     19.65 GB  ext4  19.65 GB  18.00 GB  linear  /var
/dev/sda1                     3.91 GB  ext4   3.91 GB   3.47 GB  part    /boot
------------------------------------------------------------------------------------
from this output we can see /dev/sdb showing 5GB used and /dev/centos/var is now 19.65,before adding space to it it was

14.65 GB


for more use , read man page of ssm
ssm (8)              - System Storage Manager: a single tool to manage your storage