Creating Striped Volumes

A striped volume is a dynamic volume that stores data in stripes on two or more physical disks space.

For demonstration, I have two volume disks partitions (i.e /dev/sde5 and /dev/sdf5). Each Partition size is 4GB.

Striping a Logical Group

There are few steps needed to striping a logical group.

1.) Preparing the disk partitions.

# fdisk /dev/sde

Command (m for help): n
Partition type:
   p   primary (0 primary, 1 extended, 3 free)
   l   logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (4096-10485759, default 4096): 4096
Last sector, +sectors or +size{K,M,G} (4096-10485759, default 10485759): +4G 
Partition 5 of type Linux and of size 4 GiB is set

Change the partition type to Linux LVM – “8e”

Command (m for help): t
Partition number (1,5, default 5): 5
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help):

Write the change to the partition table and register the new partition with the kernel.

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@server1 ~]# partprobe /dev/sde
[root@server1 ~]#

Similar steps for the “/dev/sde” partition.

2.) Create the physical volume.

#pvcreate <Partition Device1> <Partition Device2>

[root@server1 ~]# pvcreate /dev/sde5 /dev/sdf5
  Physical volume "/dev/sde5" successfully created
  Physical volume "/dev/sdf5" successfully created
[root@server1 ~]# pvs /dev/sd[e-f]5
  PV         VG   Fmt  Attr PSize PFree
  /dev/sde5       lvm2 ---  4.00g 4.00g
  /dev/sdf5       lvm2 ---  4.00g 4.00g
[root@server1 ~]# 

3.)  Setup volume Group.

Create volume group “striped-vg” with /dev/sde5 and /dev/sdf5

#vgcreate <Volume Name> <Physical Partition1> <Physical Partition2>

[root@server1 ~]# vgcreate striped-vg /dev/sde5 /dev/sdf5
  Volume group "striped-vg" successfully created
[root@server1 ~]# vgs striped-vg
  VG         #PV #LV #SN Attr   VSize VFree
  striped-vg   2   0   0 wz--n- 7.99g 7.99g
[root@server1 ~]# 

4.) Creating the Logical Volume.

#lvcreate -L 4G -i2  -n striped-lg striped-vg (Where, “L” used for Logical volume size. “i” is stripes, This is equal to the number of physical volumes to scatter the logical volume.  “n” Logical Volume Name)

[root@server1 ~]# lvcreate -L 4G -i2  -n striped-lg striped-vg 
  Using default stripesize 64.00 KiB.
  Logical volume "striped-lg" created.
[root@server1 ~]#

Note: In above result, we can see that the default size of stripe-size was 64 KB, if we need to define our own stripe value, we can use “-I” option.

[root@server1 ~]# lvs -a -o vg_name,name,devices,size 
  VG         LV         Devices                   LSize
  centos     home       /dev/sda3(2269)           2.00g
  centos     root       /dev/sda3(0)              7.00g
  centos     var        /dev/sda3(1792)           1.86g
  striped-vg striped-lg /dev/sde5(0),/dev/sdf5(0) 4.00g
[root@server1 ~]# lvdisplay /dev/striped-vg/striped-lg  -m
  --- Logical volume ---
  LV Path                /dev/striped-vg/striped-lg
  LV Name                striped-lg
  VG Name                striped-vg
  LV UUID                bvE1fg-xfGf-1Tcu-Xkhu-GwMv-uBr1-LjcDv0
  LV Write Access        read/write
  LV Creation host, time server1, 2016-09-27 10:14:08 -0400
  LV Status              available
  # open                 0
  LV Size                4.00 GiB
  Current LE             1024
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:3
  --- Segments ---
  Logical extents 0 to 1023:
    Type        striped
    Stripes        2
    Stripe size        64.00 KiB
    Stripe 0:
      Physical volume    /dev/sde5
      Physical extents    0 to 511
    Stripe 1:
      Physical volume    /dev/sdf5
      Physical extents    0 to 511

Using “m” option we can display the mapping of logical volumes. As above, we can also see that there is 2 stripes and the size of stripe is 64 KB.

5.) Create the File System.

Use “Mkfs” to create the “ext4” file system on the logical volume.

#mkfs.ext4 <Logical Volume Name>

[root@server1 ~]# mkfs.ext4 /dev/striped-vg/striped-lg 
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=16 blocks, Stripe width=32 blocks
262144 inodes, 1048576 blocks
52428 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

[root@server1 ~]#

6.) Create mount directory and add an entry to fstab file.

Use “mkdir” command to create the directory.

[root@server1 ~]# mkdir /Designer
 [root@server1 ~]#

#vim /etc/fstab Add an entry to the fstab file.

/dev/striped-vg/striped-lg      /Designer       ext4    defaults        0  0


Use “mount -a” command.

[root@server1 ~]# mount -a
[root@server1 ~]# df -hT /Designer/
Filesystem                          Type  Size  Used Avail Use% Mounted on
/dev/mapper/striped--vg-striped--lg ext4  3.9G   16M  3.6G   1% /Designer
[root@server1 ~]#

If everything worked properly, you should now have a logical volume mounted at “/Designer“.!!!

Read Also:

Managing Logical Volumes in Linux
Extending Logical Volume
Reducing Logical Volume
Migrating the Logical Volume Data

Leave a Reply

Be the First to Comment!

Notify of