{"id":973,"date":"2009-05-30T06:00:55","date_gmt":"2009-05-30T12:00:55","guid":{"rendered":"http:\/\/www.cyberward.net\/blog\/?p=973"},"modified":"2009-06-29T10:38:48","modified_gmt":"2009-06-29T16:38:48","slug":"setting-up-linux-software-raid","status":"publish","type":"post","link":"http:\/\/www.cyberward.net\/blog\/2009\/05\/setting-up-linux-software-raid\/","title":{"rendered":"Setting up Linux Software Raid"},"content":{"rendered":"<div class=\"seriesmeta\">This entry is part 3 of 3 in the series <a href=\"http:\/\/www.cyberward.net\/blog\/series\/nas\/\" class=\"series-330\" title=\"Building a NAS\">Building a NAS<\/a><\/div><p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1204\" data-permalink=\"http:\/\/www.cyberward.net\/blog\/2009\/05\/setting-up-linux-software-raid\/dualdrive\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.cyberward.net\/blog\/wp-content\/uploads\/dualdrive.jpg?fit=329%2C173\" data-orig-size=\"329,173\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Dual Drives for Raid 1\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/www.cyberward.net\/blog\/wp-content\/uploads\/dualdrive.jpg?fit=240%2C126\" data-large-file=\"https:\/\/i0.wp.com\/www.cyberward.net\/blog\/wp-content\/uploads\/dualdrive.jpg?fit=329%2C173\" class=\"alignleft size-full wp-image-1204\" title=\"Dual Drives for Raid 1\" src=\"https:\/\/i0.wp.com\/www.cyberward.net\/blog\/wp-content\/uploads\/dualdrive.jpg?resize=329%2C173\" alt=\"Dual Drives for Raid 1\" width=\"329\" height=\"173\" srcset=\"https:\/\/i0.wp.com\/www.cyberward.net\/blog\/wp-content\/uploads\/dualdrive.jpg?w=329 329w, https:\/\/i0.wp.com\/www.cyberward.net\/blog\/wp-content\/uploads\/dualdrive.jpg?resize=300%2C157 300w\" sizes=\"(max-width: 329px) 100vw, 329px\" data-recalc-dims=\"1\" \/>This is part of our series on building a NAS. In this article we will get the box set up with a static IP address, and get your drives set up for RAID 1.<\/p>\n<p>We are assuming that at this point you have Ubuntu installed. We are gong to install software raid in a moment. The first thing I want to do is make sure we have a static ip address. Usually Ubuntu will start up with a dynamic ip address. This can make it more difficult to transfer files to this box, so lets make it static.<br \/>\n<!--more--><\/p>\n<h3>Setting a static IP address<\/h3>\n<p>Type ifconfig eth0, and you will see your current address.<\/p>\n<p>Lets make it static. Note, typing sudo in front of commands lets you assume the privileges of the administrator, or super user.<\/p>\n<pre class=\"linux\">sudo nano \/etc\/network\/interfaces<\/pre>\n<p>We will replace the text there with this text, which will assign 10.0.0.50 to our server, and assume the gateway is at 10.0.0.1:<\/p>\n<pre class=\"linux\">auto eth0\r\niface eth0 inet static\r\naddress 10.0.0.50\r\nnetmask 255.255.255.0\r\nnetwork 10.0.0.0\r\nbroadcast 10.0.0.255\r\ngateway 10.0.0.1<\/pre>\n<p>restart the network to get the new settings :<\/p>\n<pre class=\"linux\">sudo \/etc\/init.d\/networking restart<\/pre>\n<p>ifconfig eth0 and you should see the new settings.<\/p>\n<p>If you want to see a whole lot more networking commands, see <a href=\"http:\/\/www.cyberciti.biz\/tips\/howto-ubuntu-linux-convert-dhcp-network-configuration-to-static-ip-configuration.html\">here<\/a>.<\/p>\n<h3>Finding out drives<\/h3>\n<p>Great. Now before we can put two drives into a RAID 1 array, we need to tell linux what drives we are going to use for this.<\/p>\n<p>How do we know what disks? I just type dmesg. This will scroll lots of stuff down the screen. If you are in the GUI at a terminal you can scroll. Otherwise type dmesg | less which will let you move through the text with the cursor keys.<\/p>\n<p>This is all the hardware that was found and initialized. You will first see the ataX with X being the number of the drive. You need to look for a section after this that has letters like hda or sda. The drives I am using are SATA drives and they are <strong>sda<\/strong> and <strong>sdb<\/strong>. I could tell by the size of the drives. (press Q to exit less if you need to)<\/p>\n<h3>Partition\u00ac\u2020for Raid 1<\/h3>\n<p>Ok, lets tell Linux that we want those drives to be used for raid.<\/p>\n<pre class=\"linux\">sudo fdisk \/dev\/sda<\/pre>\n<p>[p] will list the partitions. If you had one previously, you will see it. Remove them. Press d for delete, then give a partition number. (no need if you only had one)<\/p>\n<p>Now add a [n]ew [p]rimary partition number [1] with default start and end (the whole disk)<\/p>\n<pre class=\"linux\">n [enter] p [enter] 1 [enter][enter][enter]<\/pre>\n<p>Now [p] again to verify that the partition is there. Note the type: 83. Type [l] to see all the types. We need to set the type to fd for Linux software raid.<\/p>\n<pre class=\"linux\">t [enter] fd [enter]<\/pre>\n<p>Now write the partition table and exit: w [enter]<\/p>\n<p>Now we repeat the process with the other drive.<\/p>\n<pre class=\"linux\">sudo fdisk \/dev\/sdb<\/pre>\n<p>And repeat the fdisk commands.<\/p>\n<h3>Setting up mdadm for Raid1<\/h3>\n<p>Ok, now for Linux software raid. First we need to install it.<\/p>\n<pre class=\"linux\">sudo apt-get install mdadm<\/pre>\n<p>When I did this, I was prompted that citadel-server was being installed. This is what is used by default as the mail server. Mdadm is dependant on a mail server so it can mail you of failures. Pick an admin user and say no to external auth.<\/p>\n<p>Once installed you can build an array. I am going to use two drives in a RAID 1, mirrored setup. This duplicates all the data on both drives. They are mirrored. This is the command with my drives used. You will substitute for your devices:<\/p>\n<pre class=\"linux\">sudo mdadm --create --verbose \/dev\/md0 --level=1 --raid-devices=2 \/dev\/sda1 \/dev\/sdb1<\/pre>\n<p>This should tell you that the array \/dev\/md0 has started.<\/p>\n<p>If you would like to see when the array is built:<\/p>\n<pre class=\"linux\">cat \/proc\/mdstat<\/pre>\n<p>This will tell you how long it will take, or if it is done.<\/p>\n<p>Ok, that&#8217;s it for now.\u00ac\u2020 We will look at commands to manipulate the array in a later article in the series. Next up will be creating the resizable volumes on the array using LVM.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"seriesmeta\">This entry is part 3 of 3 in the series <a href=\"http:\/\/www.cyberward.net\/blog\/series\/nas\/\" class=\"series-330\" title=\"Building a NAS\">Building a NAS<\/a><\/div><p>This is part of our series on building a NAS. In this article we will get the box set up with a static IP address, and get your drives set up for RAID 1. We are assuming that at this &hellip; <a href=\"http:\/\/www.cyberward.net\/blog\/2009\/05\/setting-up-linux-software-raid\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[3,29,103],"tags":[47,164,165,22,134],"series":[330],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pffAy-fH","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/www.cyberward.net\/blog\/wp-json\/wp\/v2\/posts\/973"}],"collection":[{"href":"http:\/\/www.cyberward.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.cyberward.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.cyberward.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.cyberward.net\/blog\/wp-json\/wp\/v2\/comments?post=973"}],"version-history":[{"count":0,"href":"http:\/\/www.cyberward.net\/blog\/wp-json\/wp\/v2\/posts\/973\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.cyberward.net\/blog\/wp-json\/wp\/v2\/media?parent=973"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.cyberward.net\/blog\/wp-json\/wp\/v2\/categories?post=973"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.cyberward.net\/blog\/wp-json\/wp\/v2\/tags?post=973"},{"taxonomy":"series","embeddable":true,"href":"http:\/\/www.cyberward.net\/blog\/wp-json\/wp\/v2\/series?post=973"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}