{"id":6030,"date":"2012-11-15T23:10:34","date_gmt":"2012-11-15T21:10:34","guid":{"rendered":"http:\/\/www.fedora.md\/?p=6030"},"modified":"2012-11-15T23:11:55","modified_gmt":"2012-11-15T21:11:55","slug":"raid0-%d0%bd%d0%b0-%d0%be%d1%81%d0%bd%d0%be%d0%b2%d0%b5-lvm","status":"publish","type":"post","link":"https:\/\/www.fedora.md\/ro\/2012\/11\/15\/raid0-%d0%bd%d0%b0-%d0%be%d1%81%d0%bd%d0%be%d0%b2%d0%b5-lvm\/","title":{"rendered":"LVM-based RAID0"},"content":{"rendered":"<p>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 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Standard_RAID_levels#RAID_0\">RAID0<\/a> (stripe) array on 4 hard drives: sdb sdc sdd sde, 500GB each.<br \/>\n<!--more--><br \/>\n0) for debian - install lvm2 (apt-get install lvm), no installation resuired for fedora\/rhel.<br \/>\n1) open fdisk and create partitions on all the drives:<br \/>\n<code>fdisk \/dev\/sdb<\/code><br \/>\nOut 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.<br \/>\nrepeat the process for all drives<br \/>\n2) create lvm physical volumes on partitions we just created:<br \/>\n<code>pvcreate \/dev\/sdb1<br \/>\npvcreate \/dev\/sdc1<br \/>\npvcreate \/dev\/sdd1<br \/>\npvcreate \/dev\/sde1<\/code><br \/>\n3) \u043ejoin them into a group named \"stripe_group\"<br \/>\n<code>vgcreate stripe_group \/dev\/sdb1 \/dev\/sdc1 \/dev\/sdd1 \/dev\/sde1<\/code><br \/>\n4) check the group using \"vgdisplay\"<br \/>\n<code>root@box:~# vgdisplay<br \/>\n  --- Volume group ---<br \/>\n  VG Name               stripe_group<br \/>\n  System ID<br \/>\n  Format                lvm2<br \/>\n  Metadata Areas        4<br \/>\n  Metadata Sequence No  3<br \/>\n  VG Access             read\/write<br \/>\n  VG Status             resizable<br \/>\n  MAX LV                0<br \/>\n  Cur LV                2<br \/>\n  Open LV               2<br \/>\n  Max PV                0<br \/>\n  Cur PV                4<br \/>\n  Act PV                4<br \/>\n  VG Size               1.81 TiB<br \/>\n  PE Size               4.00 MiB<br \/>\n  Total PE              476936<br \/>\n  Alloc PE \/ Size       0 \/ 0<br \/>\n  Free  PE \/ Size       476936 \/ 1.90 TiB<br \/>\n  VG UUID               9DpW1d-gf3e-kdF6-eoAB-z12p-jNTW-PEgHC9<\/code><br \/>\nAt 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!<br \/>\n5) The most interesting part - create a logical volume using \"lvcreate\" with special parameters:<br \/>\n<code>lvcreate -i4 -I64  -l 100%VG -n data_array stripe_group<\/code><br \/>\n-i indicates the number of stripes used (4 in my case)\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u0430\u0439\u043f\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0430 (4 \u0432 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435)<br \/>\n-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)<br \/>\n-l indicates the size of the volume - im my case it's 100% of the volume group size<br \/>\n-n indicates the name of the new volume<br \/>\n5.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.<br \/>\n6) last step - let's create a file system!<br \/>\n<code>mkfs.ext4 \/dev\/mapper\/stripe_group-data_array<\/code><br \/>\n7) mount it and use the array.<br \/>\n<code>mount \/dev\/mapper\/stripe_group-data_array \/mnt\/raid<\/code><\/p>\n<p>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 \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I decided to experiment with more &#8222;advanced&#8221; LVM features, such as creating a logical volume on multiple physical ones. Here I&#8217;ll tell you the steps necessary to create a RAID0 (stripe) array on 4 hard drives: sdb sdc sdd sde, 500GB each.<\/p>\n","protected":false},"author":100,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,355],"tags":[335,370],"_links":{"self":[{"href":"https:\/\/www.fedora.md\/wp-json\/wp\/v2\/posts\/6030"}],"collection":[{"href":"https:\/\/www.fedora.md\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fedora.md\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fedora.md\/wp-json\/wp\/v2\/users\/100"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fedora.md\/wp-json\/wp\/v2\/comments?post=6030"}],"version-history":[{"count":20,"href":"https:\/\/www.fedora.md\/wp-json\/wp\/v2\/posts\/6030\/revisions"}],"predecessor-version":[{"id":6050,"href":"https:\/\/www.fedora.md\/wp-json\/wp\/v2\/posts\/6030\/revisions\/6050"}],"wp:attachment":[{"href":"https:\/\/www.fedora.md\/wp-json\/wp\/v2\/media?parent=6030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fedora.md\/wp-json\/wp\/v2\/categories?post=6030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fedora.md\/wp-json\/wp\/v2\/tags?post=6030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}