Logical volume manager (LVM)

Logical volume manager (LVM)

What is LVM ?

Logical volume manager (LVM) introduces an extra layer between the physical disks and the file system allowing file systems to be resized and moved easily and online without requiring a system-wide outage.

LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes

No alt text provided for this image

 

HERE THERE IS TWO EXAMPLES TO PRACTICE LVM :

Example 1 :

Create the “LVM” with the name “source” by using 26PE’s from the volume group “open”. Consider the PE size as “8MB”. Mount it on /mnt/secret with filesystem vfat.

CREATE A PARTITION

# fdisk /dev/sda (n, p, 3, +300M, t, 8e , w)

FORCE READING PARTITION TABLE BY THE KERNEL

# partprobe /dev/sda

CREATE A PHYSICAL VOLUME

# pvcreate /dev/sda3

CREATE A VOLUME GROUP WITH A SIZE OF PE = 8M

# vgcreate –s 8M open /dev/sda3

CREATIE A LOGICAL VOLUME FROM THE VOLUME GROUP 26PE’S

# lvcreate –n source –l 26 open 

ASSIGN THE VFAT FILE SYSTEM TYPE TO THE LOGICAL VOLUME

# mkfs.vfat /dev/open/source 

CREATE THE MOUNT POINT

# mkdir /mnt/secret 

MOUNTING THE LOGICAL VOLUME PERSISTENTLY

# vim /etc/fstab 

/dev/mapper/open-source /mnt/secret vfat defaults 1 2

# mount -a

 

Example 2 :

Resize the lvm “/dev/vgsrv/home” (/dev/myvol/vo) so that after reboot size should be in between 90MB to 120MB..

SHOW DETAILS ABOUT THE LOGICAL VOLUME

# lvdisplay /dev/vgsrv/home 

SHOW DETAILS ABOUT THE VOLUME GROUP

# vgdisplay vgsrv 

EXTEND THE LOGICAL GROUP

# lvextend –L +volume_to_add /dev/vgsrv/home

EXTEND THE FILE SYSTEM

# mount | grep /dev/mapper/vgsrv-home (To show file system type)

# xfs_growfs file_system_name (if type of the file system is xfs)

# resize2fs logical_volume_name (if type of the file system is ext4)

 

Note: If we want to reduce the size of 100Mb

# umount /dev/vgsrv/home

# Lvreduce –L 100M /dev/vgsrv/home -r

# mount /dev/vgsrv/home


You can find more articles on : www.hentati.org


Thanks,

Ali HENTATI


要查看或添加评论,请登录

Ali HENTATI的更多文章

社区洞察

其他会员也浏览了