In this article we learn how to create an LVM striped logical volume that stripes data accross the disks and it is very similar to RAID-O.Here we will learn all the methods to create and configure a striped LVM.Striped Logical Volume Increases the performance because with striping I/O can be done in parallel.Striping enhance the performance by writing users data to a predetermined numbers of physical volumes in round robin fashion.It also improves the efficiency of the data I/O for large sequential reads and writes.This Lab will help you to understand LVM configuration and also makes you to learn and grab the configuration of striped logical volume.
Also Read: How to Configure and Delete lvm in Linux
Let’s see Partition Table before creating LVM.
[root@localhost ~]# fdisk -l
Disk /dev/sda: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 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: 0x000e1624
Device Boot Start End Blocks Id System
/dev/sda1 * 1 1275 10240000 83 Linux
/dev/sda2 1275 1530 2048000 82 Linux swap / Solaris
/dev/sda4 1530 2088 4482836 5 Extended
/dev/sda5 1530 1555 201482 83 Linux
/dev/sda6 1556 1581 208813+ 83 Linux
/dev/sda7 1582 1633 417658+ 83 Linux
Now change the Partition Type of /dev/sda5/dev/sda6 and /dev/sda7 to LVM type so that these partitions can be used in LVM.
[root@localhost ~]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).
Command (m for help): t
Partition number (1-7): 5
Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)
Command (m for help): t
Partition number (1-7): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)
Command (m for help): t
Partition number (1-7): 7
Hex code (type L to list codes): 8e
Changed system type of partition 7 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sda: 17.2 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 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: 0x000e1624
Device Boot Start End Blocks Id System
/dev/sda1 * 1 1275 10240000 83 Linux
/dev/sda2 1275 1530 2048000 82 Linux swap / Solaris
/dev/sda4 1530 2088 4482836 5 Extended
/dev/sda5 1530 1555 201482 8e Linux LVM
/dev/sda6 1556 1581 208813+ 8e Linux LVM
/dev/sda7 1582 1633 417658+ 8e Linux LVM
Command (m for help): w
Update the Partition Table without Reboot.
[root@localhost ~]# partx -v /dev/sda
device /dev/sda: start 0 size 33554432
gpt: 0 slices
dos: 7 slices
# 1: 2048- 20482047 ( 20480000 sectors, 10485 MB)
# 2: 20482048- 24578047 ( 4096000 sectors, 2097 MB)
# 3: 0- -1 ( 0 sectors, 0 MB)
# 4: 24578048- 33543719 ( 8965672 sectors, 4590 MB)
# 5: 24578111- 24981074 ( 402964 sectors, 206 MB)
# 6: 24981138- 25398764 ( 417627 sectors, 213 MB)
# 7: 25398828- 26234144 ( 835317 sectors, 427 MB)
Create the Physical Volume:
[root@localhost ~]# pvcreate /dev/sda{5,6,7}
Physical volume “/dev/sda5” successfully created
Physical volume “/dev/sda6” successfully created
Physical volume “/dev/sda7” successfully created
Note:The above command will destroy any data on /dev/sda5,/dev/sda6 and /dev/sda7
Display the attributes of Physical Volume:
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 lvm2 a- 196.76m 196.76m
/dev/sda6 lvm2 a- 203.92m 203.92m
/dev/sda7 lvm2 a- 407.87m 407.87m
Create Volume Group:
[root@localhost ~]# vgcreate vg00 /dev/sda{5,6,7}
Volume group “vg00” successfully created
Display the attributes of Volume Group :
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg00 3 0 0 wz–n- 796.00m 796.00m
Create Logical Volume(Bydefault it’s a Linear Logical Volume)
[root@localhost ~]# lvcreate -L 300M -n lv1 vg00
Logical volume “lv1” created
Display the attributes of Logical Volume :
[root@localhost ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lv1 vg00 -wi-a- 300.00m
Display Logical Volume Information in Detail.
[root@localhost ~]# lvdisplay
— Logical volume —
LV Name /dev/vg00/lv1
VG Name vg00
LV UUID atV0Ws-mrQK-Z18G-FNS8-6Oac-ZznA-2lRGdq
LV Write Access read/write
LV Status available
# open 0
LV Size 300.00 MiB
Current LE 75
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:0
STRIPED LOGICAL VOLUME CREATION:
Method1:
Learn how to create striped Logical Volume:
[root@localhost ~]# lvcreate -L 300M -i2 -I64 vg00 /dev/sda5 /dev/sda6
Rounding size (75 extents) up to stripe boundary size (76 extents)
Logical volume “lvol0” created
Explanation of above command:
300M is Total Size of Striped LVM
-i2 means use two physical volume for the stripes here( /dev/sda5 and /dev/sda6)
-I64 means Stripe Size=64KB
Now see the Details and attributes of striped logical volume:
[root@localhost ~]# lvs -a -o +devices
LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices
lv1 vg00 -wi-a- 300.00m /dev/sda7(0)
lvol0 vg00 -wi-a- 304.00m /dev/sda5(0),/dev/sda6(0)
Explanation of above output:
lv1 is Linear LVm which we have created earlier in the starting of this tutorial.
lvol0 is our striped LVM using two physical volumes /dev/sda5 and /dev/sda6.
Method2:
Another Method to Create Striped Logical Volume:
[root@localhost ~]# lvcreate -L 50M -i2 -I64 -n lv3 vg00
Rounding up size to full physical extent 52.00 MiB
Rounding size (13 extents) up to stripe boundary size (14 extents)
Logical volume “lv3” created
Display the Information and attributes of Striped Logical Volume.
[root@localhost ~]# lvs -a -o +devices
LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices
lv1 vg00 -wi-a- 300.00m /dev/sda7(0)
lv3 vg00 -wi-a- 56.00m /dev/sda5(38),/dev/sda6(38)
lvol0 vg00 -wi-a- 304.00m /dev/sda5(0),/dev/sda6(0)
Create a directory and then create a filesystem over it.
[root@localhost ~]# mkdir /striplv1
[root@localhost ~]# mkfs.ext4 /dev/vg00/lvol0
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=64 blocks, Stripe width=128 blocks
77824 inodes, 311296 blocks
15564 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
38 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Explanation: Above command creates a ext4 file system on logical volume.
Mount the striped lvm:
below commands will mount the logical volume and report the file system disk usage.
[root@localhost ~]# mount /dev/vg00/lvol0 /striplv1/
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext4 9.7G 2.7G 6.5G 30% /
tmpfs tmpfs 504M 420K 504M 1% /dev/shm
/dev/mapper/vg00-lvol0
ext4 295M 11M 270M 4% /striplv1
Create File system and Mount another Striped LVM:
[root@localhost ~]# mkdir /striplv3
[root@localhost ~]# mkfs.ext4 /dev/vg00/lv3
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=64 blocks, Stripe width=128 blocks
14336 inodes, 57344 blocks
2867 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=58720256
7 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]# mount /dev/vg00/lv3 /striplv3
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext4 9.7G 2.7G 6.5G 30% /
tmpfs tmpfs 504M 420K 504M 1% /dev/shm
/dev/mapper/vg00-lvol0
ext4 295M 11M 270M 4% /striplv1
/dev/mapper/vg00-lv3
ext4 55M 4.9M 47M 10% /striplv3
Now see LVM short Details using lvscan
[root@localhost ~]# lvscan
ACTIVE ‘/dev/vg00/lv1’ [300.00 MiB] inherit
ACTIVE ‘/dev/vg00/lvol0’ [304.00 MiB] inherit
ACTIVE ‘/dev/vg00/lv3’ [56.00 MiB] inherit
Display mapping of LVM:
[root@localhost ~]# lvdisplay /dev/vg00/lv3 -m
— Logical volume —
LV Name /dev/vg00/lv3
VG Name vg00
LV UUID sMJKUO-0lro-8X0y-9BXL-cSmh-TU10-V5bkKN
LV Write Access read/write
LV Status available
# open 1
LV Size 56.00 MiB
Current LE 14
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 512
Block device 253:2
— Segments —
Logical extent 0 to 13:
Type striped
Stripes 2
Stripe size 64.00 KiB
Stripe 0:
Physical volume /dev/sda5
Physical extents 38 to 44
Stripe 1:
Physical volume /dev/sda6
Physical extents 38 to 44
good sir
LikeLiked by 1 person
Thanks! if you like our articles keep sharing linuxtiwary.com and keep commenting.
LikeLike
Thanks a lot,sayar or sir or teacher
LikeLiked by 1 person
[…] Read:HOW TO CREATE STRIPED LOGICAL VOLUME IN LINUX […]
LikeLike
An interesting discussion is definitely worth comment. I believe that you should write more on this issue, it might not be a taboo matter but generally folks don’t discuss such subjects. To the next! Best wishes!!
LikeLiked by 1 person