{"id":250,"date":"2012-05-31T22:45:52","date_gmt":"2012-05-31T14:45:52","guid":{"rendered":"http:\/\/blog.yaojun.sg\/?p=250"},"modified":"2012-05-31T22:45:52","modified_gmt":"2012-05-31T14:45:52","slug":"building-a-raid-5-storage-system-using-linux","status":"publish","type":"post","link":"https:\/\/blog.yaojun.sg\/?p=250","title":{"rendered":"Building a RAID 5 Storage System using Linux"},"content":{"rendered":"<p>RAID improves storage performance and storage is important, but what&#8217;s more important is the data that is being contained. So I&#8217;ve decided to build a proof of concept in a Visualized en environment before hitting the real thing.<\/p>\n<p>so after &#8220;installing&#8221; your disk, check for your disks using this command<\/p>\n<pre>fdisk -l<\/pre>\n<p>You&#8217;ll see things like this<\/p>\n<pre>Disk \/dev\/sdb: 21.5 GB, 21474836480 bytes\n255 heads, 63 sectors\/track, 2610 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\nDisk \/dev\/sdb doesn't contain a valid partition table\n\nDisk \/dev\/sdc: 21.5 GB, 21474836480 bytes\n255 heads, 63 sectors\/track, 2610 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\nDisk \/dev\/sdc doesn't contain a valid partition table\n\nDisk \/dev\/sdd: 21.5 GB, 21474836480 bytes\n255 heads, 63 sectors\/track, 2610 cylinders\nUnits = cylinders of 16065 * 512 = 8225280 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisk identifier: 0x00000000\n\nDisk \/dev\/sdd doesn't contain a valid partition table<\/pre>\n<p>Make sure that these are the drives that you&#8217;re going to work on for the RAID.<\/p>\n<p>Now create a new partition (in this case the partition is going to be on \/dev\/sdb)<\/p>\n<pre>fdisk \/dev\/sdb<\/pre>\n<p>Press &#8216;n&#8217; for new partition<\/p>\n<pre>n<\/pre>\n<p>Press &#8216;p&#8217; for primary partition and &#8216;1&#8217; for the 1st partition<\/p>\n<pre>p<\/pre>\n<pre>1<\/pre>\n<p>After creating partitions change it to lo Linux raid auto detect<\/p>\n<p>Press &#8216;t&#8217; to change partition type<\/p>\n<pre>t<\/pre>\n<p>Press &#8216;fd&#8217; to change it to &#8220;Linux RAID auto&#8221;<\/p>\n<pre>fd<\/pre>\n<p>Press &#8216;w&#8217; to save and write the configuration<\/p>\n<pre>w<\/pre>\n<p>Repeat the above steps for the other hard disks also.<\/p>\n<p>After getting the partitions up, it&#8217;s time to build the raid and it&#8217;s a simple 1 liner. \ud83d\ude42<\/p>\n<pre>mdadm --create --verbose \/dev\/md0 --level=5 --raid-devices=3 \/dev\/sdb1 \/dev\/sdc1 \/dev\/sdd1<\/pre>\n<p>Then you persist the RAID settings into a mdadm.conf file using this<\/p>\n<pre>mdadm --detail --scan &gt;&gt; \/etc\/mdadm.conf<\/pre>\n<p>Then it&#8217;s time to format the new RAID<\/p>\n<pre>mkfs.ext4 \/dev\/md0<\/pre>\n<p>Then it&#8217;s time to mount somewhere create a directory<\/p>\n<pre>mkdir -p \/mnt\/raid<\/pre>\n<pre>mount \/dev\/md0 \/mnt\/raid<\/pre>\n<p>After that find the UUID of the raid device<\/p>\n<pre dir=\"ltr\">ls \/dev\/disk\/by-uuid -alh<\/pre>\n<p>Then add it into \/etc\/fstab by editing the file using a text editor like vim<\/p>\n<pre>vim \/etc\/fstab<\/pre>\n<p>add this line at the end of the file<\/p>\n<pre>UUID=&lt;&lt;YOUR UUID&gt;&gt; \/mnt\/raid ext4 defaults 0 0<\/pre>\n<p>And there you have it! a RAID 5 storage system ready to be used! \ud83d\ude42<\/p>\n<p>Do take note that RAID is not a backup, it is merely redundant storage with performance. You&#8217;ll still have to backup regularly into another drive which I&#8217;ll touch on later.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>RAID improves storage performance and storage is important, but what&#8217;s more important is the data that is being contained. So I&#8217;ve decided to build a proof of concept in a Visualized en environment before hitting the real thing. so after &#8220;installing&#8221; your disk, check for your disks using this command fdisk -l You&#8217;ll see things [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-250","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=\/wp\/v2\/posts\/250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=250"}],"version-history":[{"count":0,"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=\/wp\/v2\/posts\/250\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}