• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to convert a Volume to Stripe (RAID0) Volume in LVM

by admin

For performance reasons instead of using one large LVM volume, it might be replaced by multiple small striped (RAID0) volumes. There is no command to directly transform a single disk logical volume into a striped logical volume. This post will explain the procedure to perform the conversion.

Note: Before starting take a full backup of the volume or filesystem.

This procedure can be performed in a live system, without the need to reboot. The procedure consists in create a mirror between the original volume and the new striped volumes. Once the mirroring is completed, we can remove the original volume from the mirror leaving only the striped volumes.

To be able to perform the conversion, the number of logical extents (LE) in the LVM logical volume (LV) must be divisible by the number of physical volumes (PV) that will be used in the future striped LV.

Check the number of assigned LE:

# lvdisplay
 --- Logical volume ---
 LV Path                /dev/<VOLUME_GROUP>/<LOGICAL_VOLUME>
 LV Name                <LOGICAL_VOLUME>
 VG Name                <VOLUME_GROUP>
 LV UUID                <VOLUME_UUID>
 LV Write Access        read/write
 LV Creation host, time <HOSTNAME>, 2020-12-10 08:38:44 +0000
 LV Status              available
 # open                 1
 LV Size                <10.00 GiB
 Current LE             2559
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           252:0

In this case, the number of LE is 2559.

To know the number of needed LE, you can use:
– le = number of assigned LE, from previous command (2559 in this case)
– pv = number of striped PV to be used in future (ex: 5)

$ le=2559; pv=5; echo $((le%pv?(le/pv+1)*pv:le))
2560

In this case one extra LE is needed. Example to extend the LV:

# lvresize --extents +1 /dev/<VOLUME_GROUP>/<LOGICAL_VOLUME> /dev/sdb
 Size of logical volume <VOLUME_GROUP>/<LOGICAL_VOLUME> changed from <10 GiB (2559 extents) to <10 giB (2560 extents).
 Logical volume <VOLUME_GROUP>/<LOGICAL_VOLUME> successfully resized.

After the LV is prepared proceed:

1. Add the new PVs to the LV creating a striped mirror. The number of stripes should be the number of PVs:

# lvconvert --type mirror -m 1 --mirrorlog core --stripes 2 /dev/<VOLUME_GROUP>/<LOGICAL_VOLUME> /dev/<PV1> /dev/<PV2> ... /dev/<PV5>

2. Remove the initial PV from the LV:

# lvconvert -m0 <VOLUME_GROUP>/<LOGICAL_VOLUME> /dev/<INITIAL_PV>

3. Remove the PV from LVM:

# vgreduce <VOLUME_GROUP> /dev/<INITIAL_PV>
# pvremove /dev/<INITIAL_PV>

Filed Under: CentOS/RHEL, Linux

Some more articles you might also be interested in …

  1. aws lambda: CLI for AWS lambda (Command Examples)
  2. btrfs subvolume Command Examples in Linux
  3. binwalk: command not found
  4. light Command Examples in Linux
  5. brctl Command Examples in Linux
  6. rpm: error while loading shared libraries: invalid ELF header
  7. logwatch : command not found
  8. gpg: command not found
  9. How to avoid ssh from prompting key passphrase for passwordless logins
  10. readpe Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • cf: Command-line tool to manage apps and services on Cloud Foundry
  • certutil: Manage keys and certificates in both NSS databases and other NSS tokens
  • cdk: A CLI for AWS Cloud Development Kit (CDK)
  • cd: Change the current working directory

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright