Linux Logical Volume Manager LVM

PARTITION--->PHYSICAL VOLUME ---> VOLUME GROUP ---> LOGICAL VOLUME

-> LVM is a method of allocating hard drive space into logical volumes that can be easily resized.
-> With LVM, the hard drive or set of hard drives is allocated to one or more Physical Volumes.
-> The Physical volume PV are then combined into Volume Groups VG.

Steps for creating normal volumes
1. Create partition
# fdisk /dev/sda
:l <- this gives all ID's i.e. list all known partion types
:t <- to change partition's system ID
:9 <- example partion number to be created
:8e <- 'linux LVM' system partion type code
:p <- print the partition table
:w <- write talbe to disk and exit

The above steps create a new partition with 'linux LVM' type.

2. Check and create physical volumes
[root@dregpodb /]# pvdisplay

--- Physical volume ---
PV Name /dev/dm-8
VG Name vg01
PV Size 150.00 GB / not usable 4.00 MB
Allocatable yes (but full)
PE Size (KByte) 4096
Total PE 38399
Free PE 0
Allocated PE 38399
PV UUID kuEpoH-xXL0-c7LU-Vf6Q-7Uj7-xxKn-MmmZLV

--- Physical volume ---
PV Name /dev/cciss/c0d0p2
VG Name vg00
PV Size 136.20 GB / not usable 14.56 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 4358
Free PE 102
Allocated PE 4256
PV UUID 12osfI-bJBr-NtUy-0mo7-j3ZD-Aeqx-9m0N3P

[root@dregpodb /]#pvcreate /dev/dm-9

[root@dregpodb /]# pvdisplay
--- Physical volume ---
PV Name /dev/dm-9
VG Name vg02
PV Size 100.00 GB / not usable 4.00 MB
Allocatable yes (but full)
PE Size (KByte) 4096
Total PE 25599
Free PE 0
Allocated PE 25599
PV UUID 6Mjkim-P13j-Afu2-pUE7-E4l2-VfyB-dZ68VE

--- Physical volume ---
PV Name /dev/dm-8
VG Name vg01
PV Size 150.00 GB / not usable 4.00 MB
Allocatable yes (but full)
PE Size (KByte) 4096
Total PE 38399
Free PE 0
Allocated PE 38399
PV UUID kuEpoH-xXL0-c7LU-Vf6Q-7Uj7-xxKn-MmmZLV

--- Physical volume ---
PV Name /dev/cciss/c0d0p2
VG Name vg00
PV Size 136.20 GB / not usable 14.56 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 4358
Free PE 102
Allocated PE 4256
PV UUID 12osfI-bJBr-NtUy-0mo7-j3ZD-Aeqx-9m0N3P

3. Volume Group creation#vgcreate vg02 /dev/dm-9

[root@dregpodb /]# vgdisplay
--- Volume group ---
VG Name vg02
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 100.00 GB
PE Size 4.00 MB
Total PE 25599
Alloc PE / Size 25599 / 100.00 GB
Free PE / Size 0 / 0
VG UUID LdtcHj-g26p-BSRu-g9Wi-vcqj-dQki-nGoM2e

--- Volume group ---
VG Name vg01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 150.00 GB
PE Size 4.00 MB
Total PE 38399
Alloc PE / Size 38399 / 150.00 GB
Free PE / Size 0 / 0
VG UUID dhdeBn-kdIP-frWp-gODa-9X6f-0dW7-rOAmzQ

--- Volume group ---
VG Name vg00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 9
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 8
Open LV 8
Max PV 0
Cur PV 1
Act PV 1
VG Size 136.19 GB
PE Size 32.00 MB
Total PE 4358
Alloc PE / Size 4256 / 133.00 GB
Free PE / Size 102 / 3.19 GB
VG UUID JYPuCP-9ezo-hg8v-pvE9-1GAL-8o4F-UhezPC

4. Logical Volume Creation
# lvcreate -L 100g /dev/vg02 -n /dev/vg02/lvol01

[root@dregpodb /]# lvdisplay -v
Finding all logical volumes
--- Logical volume ---
LV Name /dev/vg02/lvol01
VG Name vg02
LV UUID T5EIW5-OiIS-WhvA-Wp0d-X0mL-4tKF-GxXY4u
LV Write Access read/write
LV Status available
# open 2
LV Size 100.00 GB
Current LE 25599
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:10

5. Format and mount logical volumes
#mkfs.ext3 /dev/vg02/lvol01
#mkdir /u01
#mount /dev/vg02/lvol01 /u01
#df -h
[root@dregpodb /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-lvol01
9.7G 435M 8.8G 5% /
/dev/mapper/vg00-lvol04
12G 3.4G 7.7G 31% /usr
/dev/mapper/vg00-lvol03
9.7G 157M 9.1G 2% /home
/dev/mapper/vg00-lvol05
9.7G 336M 8.9G 4% /var
/dev/mapper/vg00-lvol08
49G 42G 4.1G 92% /u03
/dev/mapper/vg00-lvol07
9.7G 187M 9.1G 2% /tmp
/dev/mapper/vg00-lvol06
15G 320M 14G 3% /opt
/dev/cciss/c0d0p1 487M 21M 441M 5% /boot
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/mapper/vg01-lvol0
148G 33G 108G 24% /u02
/dev/mapper/vg02-lvol01
99G 42G 52G 45% /u01

6. Resizing the logical volume
#lvresize -L +50g /dev/vg02/lvol01 <-This will add 50g to existing 100g size
#resize2fs /dev/vg02/lvol01 <-This will update the kernel with changes

7. Extending size of a volume group
#vgdisplay
#vgextend /dev/vg02 /dev/sda12
#vgdisplay

To check graphically about volumes use the following tool,
#system-config-lvm &

--------Additional commands------------
eject <-- To eject cd-rom device
eject -t <-- To insert the cd-rom device
init 6 <-- to reboot server

hwbrowser &<-- To view available free space of a disk
df -h <-- To view free space in a partition
du -sh <--- To view total amount of used space in a partition directory

e2label /dev/sda8 sami <-- To add a lable
e2label /dev/sda8 "" <-- To remove a lable

mkfs.etc3 L sami /dev/sda8 <-- format the partition and add a lable

No comments:

ORA-00059: Maximum Number Of DB_FILES Exceeded in 19C database

When I am adding datafile to my 19C database facing the below error. SQL> alter tablespace DATA  add datafile '/u01/data/data15.dbf&#...