What Is Striped Volume? How To Create Striped Logical Volume In LINUX

A striped volume in Linux, also known as RAID 0, is a way of combining multiple physical disks into a single logical storage unit. Data is “striped” across the disks in blocks, so that each disk stores a portion of the data. This can provide increased performance and capacity, as well as redundancy, depending on the RAID level used. However, it also increases the risk of data loss if one of the disks fails, as all data on the striped volume will be lost.

To create a striped logical volume in Linux, you can use the “lvcreate” command from the Logical Volume Manager (LVM). Here are the general steps to follow:

  • Identify the physical volumes that you want to use for the striped logical volume. These can be individual disk partitions or entire physical disks that are already part of a volume group.
  • At least two physical volumes are necessary to create striped volume, here we are using /dev/sdb and /dev/sdc to create a striped volume.

[root@techielinux ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   17G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   16G  0 part
  ├─centos-root 253:0    0 14.3G  0 lvm  /
  └─centos-swap 253:1    0  1.7G  0 lvm  [SWAP]
sdb               8:16   0    1G  0 disk
sdc               8:32   0    1G  0 disk
sr0              11:0    1 1024M  0 rom
[root@techielinux ~]#

  • Create a physical volume with Below command.

[root@techielinux ~]# pvcreate /dev/sdb /dev/sdc
  Physical volume "/dev/sdb" successfully created.
  Physical volume "/dev/sdc" successfully created.
[root@techielinux ~]# pvs
  PV         VG     Fmt  Attr PSize   PFree
  /dev/sda2  centos lvm2 a--  <16.00g 4.00m
  /dev/sdb          lvm2 ---    1.00g 1.00g
  /dev/sdc          lvm2 ---    1.00g 1.00g
[root@techielinux ~]#

  • Create a volume group using physical volumes (/dev/sdb /dev/sdc )

[root@techielinux ~]# vgcreate strip_vg /dev/sdb /dev/sdc
  Volume group "strip_vg" successfully created
[root@techielinux ~]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree
  centos     1   2   0 wz--n- <16.00g 4.00m
  strip_vg   2   0   0 wz--n-   1.99g 1.99g
[root@techielinux ~]#

  • Now Create a Striped Logical Volume using below command

[root@techielinux ~]# lvcreate -L 1G -i 2 -I 256k -n strip_lv strip_vg
  Logical volume "strip_lv" created.
[root@techielinux ~]# lvs
  LV       VG       Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root     centos   -wi-ao---- 14.29g
  swap     centos   -wi-ao---- <1.70g
  strip_lv strip_vg -wi-a-----  1.00g

-i2 means the number of stripes

-I 256k means the stripe size in KB

-L<size> means the size of logical volume

-n strip_lv means the name of logical volume

strip_vg is the name of volume group.

  • Format the Logical Volume with a Filesystem of your choice. For Example, to Format it with the XFS Filesystem.

[root@techielinux ~]# mkfs.xfs /dev/mapper/strip_vg-strip_lv
meta-data=/dev/mapper/strip_vg-strip_lv isize=512    agcount=8, agsize=32704 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=261632, imaxpct=25
         =                       sunit=64     swidth=128 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=1728, version=2
         =                       sectsz=512   sunit=64 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@techielinux ~]#

  • Create a mount point for the logical volume, for example:

[root@techielinux ~]# mkdir /strip

  • Mount the logical volume to the mount point you created:
[root@techielinux ~]# mount /dev/mapper/strip_vg-strip_lv /strip

  • You can also create an entry in /etc/fstab file to mount the raid array automatically at boot time.

[root@techielinux ~]# vi /etc/fstab
[root@techielinux ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Fri Nov 18 11:40:01 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=4b5c6d5d-008c-4852-97f1-56815a02488b /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
/dev/mapper/strip_vg-strip_lv /strip    xfs     defaults        0 0
[root@techielinux ~]# df -ThP /strip
Filesystem                    Type  Size  Used Avail Use% Mounted on
/dev/mapper/strip_vg-strip_lv xfs  1016M   33M  983M   4% /strip
[root@techielinux ~]#

  • Verify the logical volume Type.

[root@techielinux ~]# lvs --segments
  LV       VG       Attr       #Str Type    SSize
  root     centos   -wi-ao----    1 linear  14.29g
  swap     centos   -wi-ao----    1 linear  <1.70g
  strip_lv strip_vg -wi-ao----    2 striped  1.00g
[root@techielinux ~]#

Note: This is a general process for creating a striped logical volume, the specific commands and options may vary depending on your Linux distribution and the specific RAID level you’re using. Also make sure LVM is installed in your machine and you have sufficient space in the volume group to create a new logical volume.

Leave a Reply

Your email address will not be published. Required fields are marked *