Basic LVM operations in Linux(RHEL)

LVM_Operations.md

The following steps will provide an idea of how to perform basic operations on Linux (RHEL) LVM.

Creating VG

  1. Scan for the new disk.

For that first you need find out which host bus to scan.

# grep mpt /sys/class/scsi_host/host?/proc_name

If the disk properly attached, it should return like below.

/sys/class/scsi_host/host6/proc_name:mptspi

Here you need to rescan host6

#echo "- - -" > /sys/class/scsi_host/host6/scan

Here "- - -" means to scan

  • All channels
  • All controllers
  • All LUNs
  1. Cross verify if the disk was allocated to any VG
#vgdisplay -v |grep -i diskname

This is just to re-confirm you are playing around with Correct/New disk.

  1. Create new PV using following command.
#pvcreate <newdisk>
  1. Create VG
#vgcreate -s <Size of PE> <VG_name> <Disk>

Eg:

#vgcreate -s 32M vg01 /dev/sdb
  1. verify the VG and attribures
#vgdisplay <Vg_Name>

Create LV

  1. Create a LV
#lvcreate -l <Size_Of_LV in PEs> -n <Lv_Name> <Vg_Name>

Eg:

#lvcreate -l 480 -n Ora_install vg01

Here you need to calculate how many LVs need to assign to bring the volume to the requested size.

Confused.....

Here is straight way to do it. Instead -l(small) attribute use -L(big). So the command will look like

#lvcreate -L 200G -n Ora_install vg01

This will create a volume of 200GB.

  1. Check LV attributes.
#lvdisplay /dev/<Vg_Name>/<LV_Name>

Eg:

#lvdisplay /dev/vg01/ora_install

Here is a tip, if you want to add left out free space in VG to LV.

#lvcreate -l 100%FREE -n ora_install vg01

Creating FS

  1. Creating FS
#mkfs -t ext3 <Lv_name>

Eg:

#mkfs -t ext3 /dev/vg01/ora_install
  1. Add fstab entries Eg:
LV_name FS Name FS Type /dev/vg01/ora_install /ora_install ext3 defaults 1 2
  1. Create Folder to mount FS and mount it.
#mkdir /ora_install
#mount -a

Rename LV

#lvrename <Old LV_name> <new LV_name>

Eg:

lvrename /dev/vg01/vg01-ora_install /dev/vg01/ora_install

Update the new LV name in /etc/fstab and remount the FS.

Extending FS

  1. If free space was not there..let the new disk added from Storage. follow the steps to scan new disk. and do PV create

  2. extend VG:

#vgextend <VGName> /dev/<newdisk>
  1. extend LV:
#lvextend -L +10G /dev/vgname/lv
  1. resize FS:
#resize2fs /dev/vgname/filesystem
  1. If asking for FSCK run
#e2fsck -f /dev/vgname/filesystem

Comments

Popular posts from this blog

Jenkins Dynmaic Parameter - List All Branches in a Git Repository

JMSWMQ2013: The security authentication was not valid that was supplied for QueueManager 'XYZ' with connection mode 'Client' and host name 'x.x.x.x(1415)'. Please check if the supplied username and password are correct on the QueueManager to which you are connecting.