CONFIGURING LVMS


CONFIGURING LVMS

fdisk /dev/sdb
t - to change partition id(system id) - to lvm
choose part no - 1 to n
L - to see hex codes
8e - Linux LVM
then w changes.

if you want to do it in mounted file system it will through a warning
++++++++++++++++++++++++++++++++++++++++++++
Re -reading the partition table failed with error 16: Device or resource busy.
The kernal still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8)
syncking disks.
+++++++++++++++++++++++++++++++++++

to see the changes
fdisk -l

unmount the file system

umount /mnt/udemy
fdisk /dev/sdb
t
2
8e
w
no warning's

lvm - allow us to dynamically resize the space on the drive
we don't need to know in advance how much drive we need for partition
used for hot plug options(defected drive-hint)

layers of abstraction:

## ######    FILE SYSTEM
                       ############################################this
## ### ####  LOGICAL VOLUMES #lvcreate -n [name] -L [size] [group] -some#is portion of VG is taken      #                                     #-LVM
                       #                                    #
############   VOLUME GROUP  # vgcreate [name] [list of volumes]##      #
                       ####                           #
#### #### #### PHYSICAl VOLUMES #pvcreate /dev/sdb1 /dev/sdb2 ##########


DISK1 DISK2 DISK3 STORAGE DEVICES

CREATING lvm'S

YOU HAVE ASSIGN LVM(82) TO DISK'S THAT ARE USED TO CREATE LVM
BEFORE DOING THIS 1 ST YOU NEED TO UNMOUNT THE DEVICES(IF ANY MOUNTED) AND REMOVE formated FILESYSTEM on the disk (LIKE XFS,EXT ETC IF FS formated to disk) WHICH IS PARTITIONED EARLIER.
IF IT IS FRESH ONE - NO NEED TO DO ABOVE

ex:

pvcreate /dev/sdb1 /dev/sdb2
or
pvcreate /dev/sdb[1,2]

pvdisplay etc are there

if any filesyste is formated it asks for wiping. if dev is mounted it gives an error then u have to unmount before creating it.

vgcreate Lyra /dev/sdb1 /dev/sdb2

vg[options]
vgreduce,vgdisplay,vgextend,vgdelete etc for reducing,displaying & extending with disks,deleting volume size etc

lvcreate -n LyraJR -L 10G Lyra

lvdisplay
lvreduce,lvdelete,lvextend etc..

NOW FORMAT IT WITH FILESYSTEM AS DO WITH NORMAL DISKS OR FS's

ex
mkfs.[xfs,ext2,ext3] etc
mkfs.xfs /dev/Lyra/LyraJR

THEN MOUNT IT ANY DIRECTORY THAT YOU WISH WITH THE FORMATED DISK OR FS

TEMPORARY MOUNT
ex
mount /dev/Lyra/LyraJR /mnt/logicalvolume01/

to check mount point
mount
or
mount | grep "/mnt/logicalvolume01
or
df -h

for temporary unmount

umount /dev/Lyra/LyraJR
or
umount /mnt/logicalvolume01/

to check if it is unmounted

df -h

TO RESIZE THE SPACE TO ALREADY CREATED LOGICAL VOLUMES

ex
lvresize -L 14G /dev/Lyra/LyraJR

TO CHECK SIZE OF THAT RESIZED VOLUME

df -h

IT WON'T SHOW BEZ EXTRA RESIZED GB OR FS IS NOT FORMATED. SO YOU HAVE TO DO IT

ex

xfs_[growfs...etc]
resize2fs

xfs_growfs /dev/Lyra/LyraJR

now check. it shows the 14 gb

df -h

EXTENDING

ex

ADD A DISK
fdisk /dev/sdb
n -creating new partation
p -creatring primary partation(other one is extended)
3 -partition no
+5G - size allocated
t - changing system id
8e - chossing lvm
w - write changes

partprobe - to force the kernal to reread the partition table to reload it

to check whether disk added or not

fdisk -l /dev/sdb

now create physical volume

pvcreate /dev/sdb3

now extend vg

vgextend Lyra1 /dev/sdb3

to check how many PV LV are there

vgs
in this case 3 PV 1 LV

SAME WAY YOU CAN CHECK LV'S WITH
lvs

now create other logical volume

lvcreate -L 4G -n NEWLV_FORREDUCE

lvs - now it shows 3 PV and 2 LV

now formate it

use ext4 as it supports shrinking (xfs does not support)

mkfs.ext4 /dev/Lyra1/NEWLV_FORREDUCE

now monut it

mount /dev/Lyra1/NEWLV_FORREDUCE /mnt/NEWLV_FORREDUCE

then check if it mounted

df -h

TO REDUCE THE LV SIZE

1 st unmount the FS

umount /mnt/NEWLV_FORREDUCE

resize2fs /dev/Lyra1/NEWLV_FORREDUCE
throws error that is e2fsck -f /dev/Lyra1/NEWLV_FORREDUCE
f means forcefully

lvreduce -L 1G /dev/Lyra1/NEWLV_FORREDUCE
resize2fs /dev/Lyra1/NEW

to check newly created lv size
lvs

now mount it

mount /dev/Lyra1/NEWLV_FORREDUCE /mnt/NEWLV_FORREDUCE/

now check

df -h

TO EXTEND EXT4 FILE SYSTEM
resize2fs /dev/Lyra/LyraJR1  <lv path>
then check if it is extended using df -h

Comments

Popular posts from this blog

Power Broker

zabbix-introduction

variables in shell scripting