Basic LVM operations in Linux(RHEL)
The following steps will provide an idea of how to perform basic operations on Linux (RHEL) LVM.
Creating VG
- 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
- 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.
- Create new PV using following command.
#pvcreate <newdisk>
- Create VG
#vgcreate -s <Size of PE> <VG_name> <Disk>
Eg:
#vgcreate -s 32M vg01 /dev/sdb
- verify the VG and attribures
#vgdisplay <Vg_Name>
Create LV
- 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.
- 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
- Creating FS
#mkfs -t ext3 <Lv_name>
Eg:
#mkfs -t ext3 /dev/vg01/ora_install
- Add fstab entries Eg:
LV_name FS Name FS Type
/dev/vg01/ora_install /ora_install ext3 defaults 1 2
- 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
-
If free space was not there..let the new disk added from Storage. follow the steps to scan new disk. and do PV create
-
extend VG:
#vgextend <VGName> /dev/<newdisk>
- extend LV:
#lvextend -L +10G /dev/vgname/lv
- resize FS:
#resize2fs /dev/vgname/filesystem
- If asking for FSCK run
#e2fsck -f /dev/vgname/filesystem
Comments
Post a Comment