Logical Volume Manager (LVM) is a software which provides the abstraction layer over the physical disk. Which hides the details regarding where does data stored on the disk or from where the data comes from actual physical disk whenever it is requested.Before learning how to create lvm lets learn terms in LVM so that it will become easy to grasp the commands about LVM administration.
Terms involved in the LVM.
- The Physical Disk/Media: It is the raw hard disk where the actual data is going to store. Ex: : /dev/hda, /dev/hda6, /dev/sda.
- Physical Volume (PV): To bring the physical disk under LVM control we need to create the LVM data structure on the disk. once its created the its called as a PV.
- Physical Extents (PE):PV is divided into PE’s.
- Volume Group(VG): is made of number of PE coming from one or more PV’s.
- Logical Volume (LV): A Logical Volume is the end result of our work, and it’s there that we store our information.
- FileSystem:is the actual formatted LM which is formatted first and the mounted on the directory for actual storage of the information.
To understand the above terms more clearly refer to below diagrams:
Physical Volume, contains Physical Extents:
+-----[ Physical Volume ]------+ | PE | PE | PE | PE | PE | PE | +------------------------------+
Volume Group, containing 2 Physical Volumes (PVs) with 6 Physical Extents:
+------[ Volume Group ]-----------------+ | +--[PV]--------+ +--[PV]---------+ | | | PE | PE | PE | | PE | PE | PE | | | +--------------+ +---------------+ | +---------------------------------------+
We now further expand this:
+------[ Volume Group ]-----------------+ | +--[PV]--------+ +--[PV]---------+ | | | PE | PE | PE | | PE | PE | PE | | | +--+---+---+---+ +-+----+----+---+ | | | | | +-----/ | | | | | | | | | | | | +-+---+---+-+ +----+----+--+ | | | Logical | | Logical | | | | Volume | | Volume | | | | | | | | | | /home | | /var | | | +-----------+ +------------+ | +---------------------------------------+
This shows us two filesystems, spanning two disks.
The /home filesystem contains 4 Physical Extents, the /var filesystem contains 2 Physical Extents.
Practicals: Now lets learn how to create LVM volume so that it can be mounted on Linux server.
Steps to create LVM volume
1. Checking the attached disk:
[root@mann ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00076e7f Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 39 2093 16501760 83 Linux /dev/sda3 2093 2611 4161536 82 Linux swap / Solaris Disk /dev/sdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdb doesn't contain a valid partition table Disk /dev/sdc: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdc doesn't contain a valid partition table Disk /dev/sdd: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdd doesn't contain a valid partition table Disk /dev/dm-1: 440 MB, 440401920 bytes 255 heads, 63 sectors/track, 53 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/dm-1 doesn't contain a valid partition table
2. Create LVM data structure on the disk /dev/sdc
[root@mann ~]# pvcreate /dev/sdc Physical volume "/dev/sdc" successfully created
2a. Recheck it using pvdisply command.
[root@mann ~]# pvdisplay --- Physical volume --- PV Name /dev/sdb VG Name vg01 PV Size 5.00 GiB / not usable 4.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 1279 Free PE 1174 Allocated PE 105 PV UUID 3p2Wdk-SkZD-76ko-TQiP-IrwX-Whk5-WIzR7Q "/dev/sdc" is a new physical volume of "2.00 GiB" --- NEW Physical volume --- PV Name /dev/sdc VG Name PV Size 2.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID qoiBZ4-mRwV-G96p-U07x-zxwf-4iqY-wLPKUS
3. Create new VG
[root@mann ~]# vgcreate myvg /dev/sdc Volume group "myvg" successfully created
4.Then Create new LV of size 200mb in the newly created VG.
[root@mann ~]# lvcreate -L 200 myvg Logical volume "lvol0" created
5. Check the LV
[root@mann ~]# lvdisplay --- Logical volume --- LV Name /dev/myvg/lvol0 VG Name myvg LV UUID Jul8hw-3hWt-HYzM-cjiA-jysn-1YrU-4SPqgV LV Write Access read/write LV Status available # open 0 LV Size 200.00 MiB Current LE 50 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Name /dev/vg01/lvol0 VG Name vg01 LV UUID ziIOqS-WGe6-uv6X-F4GU-x7U9-MSfA-9ugZ42 LV Write Access read/write LV Status available # open 0 LV Size 420.00 MiB Current LE 105 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1
Leave a Reply