LVM-based RAID0

    2012-11-15 23:10 | Autor: jekader | Filed under: FedoraMD, Jekader

    Recently I decided to experiment with more "advanced" LVM features, such as creating a logical volume on multiple physical ones. Here I'll tell you the steps necessary to create a RAID0 (stripe) array on 4 hard drives: sdb sdc sdd sde, 500GB each.

    0) for debian - install lvm2 (apt-get install lvm), no installation resuired for fedora/rhel.
    1) open fdisk and create partitions on all the drives:
    fdisk /dev/sdb
    Out of memory - press "n", "p", "1", "enter", "enter", "w". We created /dev/sdb1 the size of 100% of the drive. Read the man for details.
    repeat the process for all drives
    2) create lvm physical volumes on partitions we just created:
    pvcreate /dev/sdb1
    pvcreate /dev/sdc1
    pvcreate /dev/sdd1
    pvcreate /dev/sde1

    3) оjoin them into a group named "stripe_group"
    vgcreate stripe_group /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
    4) check the group using "vgdisplay"
    root@box:~# vgdisplay
    --- Volume group ---
    VG Name stripe_group
    System ID
    Format lvm2
    Metadata Areas 4
    Metadata Sequence No 3
    VG Access read/write
    VG Status resizable
    MAX LV 0
    Cur LV 2
    Open LV 2
    Max PV 0
    Cur PV 4
    Act PV 4
    VG Size 1.81 TiB
    PE Size 4.00 MiB
    Total PE 476936
    Alloc PE / Size 0 / 0
    Free PE / Size 476936 / 1.90 TiB
    VG UUID 9DpW1d-gf3e-kdF6-eoAB-z12p-jNTW-PEgHC9

    At the end of the output you can see the total number of "physical extents" (PE) and the size of an extent. They are all free. Let's make use of them!
    5) The most interesting part - create a logical volume using "lvcreate" with special parameters:
    lvcreate -i4 -I64 -l 100%VG -n data_array stripe_group
    -i indicates the number of stripes used (4 in my case)указывает количество страйпов для раздела (4 в моём случае)
    -I indicates the size of a stripe (so the first 64 kn are stored on the first drive the next - on the second, and so on)
    -l indicates the size of the volume - im my case it's 100% of the volume group size
    -n indicates the name of the new volume
    5.1) Attention, the stripe mode can work only with drives of equal size. If drive size differs, the smallest size in the group will be used. If you enter the command above and receive an error about insufficient physical extents, then the drives are different. In this case Use the total number of PEs from vgdisplay output and substract the number of PEs that the error shows and use the resulting number as the -l parameter. After the volume is created, free space is going to be left which can be used for other stuff.
    6) last step - let's create a file system!
    mkfs.ext4 /dev/mapper/stripe_group-data_array
    7) mount it and use the array.
    mount /dev/mapper/stripe_group-data_array /mnt/raid

    unfortunately i didn't test performance before the RAID was created, so there's nothing to compare to. Good enough that it works at all 🙂

    1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4,00 out of 5)

    Etichete: ,

    Comments (3) »

    Număr de comentarii de arătat: 3

    1. Vasile Chelban:

      а что ты на этом диске запускаешь, что требует RAID0 аж на 4 диска?

    2. jekader:

      Всякое малокритичное барахло, требующее много места.
      До этого пытался использовать USB HDD Для тех-же нужд, но производительность и надёжность были просто удручающими.

    3. настройка iSCSI (target и initiator) |

      […] обладает большим хардом, но слабейшим железом (см. Прошый пост про LVM), и другое, у которого мощное железо, но маленькие […]

    Leave a comment