{"id":299,"date":"2018-01-23T15:41:33","date_gmt":"2018-01-23T20:41:33","guid":{"rendered":"https:\/\/www.unliterate.net\/?p=299"},"modified":"2018-01-25T11:51:50","modified_gmt":"2018-01-25T16:51:50","slug":"home-linux-file-server-with-software-raid-and-iscsi-1-10","status":"publish","type":"post","link":"https:\/\/www.unliterate.net\/index.php\/2018\/01\/23\/home-linux-file-server-with-software-raid-and-iscsi-1-10\/","title":{"rendered":"Home Linux File Server with Software RAID and iSCSI (1\/10)"},"content":{"rendered":"<style>pre { background-color: rgb(234, 234, 234); }<\/style>\n<p><strong>Yays! Fun stuff in route!<\/strong><\/p>\n<p>Part of my 2018 goals is to be able to have a universally-accessible resource where I can be able to store all the data that I need to, and more, without worry of fault or loss. One of the ways to approach this is to create a File Server that I can mount from a majority of operating systems and be able to store anywhere in the world. So, I&#8217;ve come to the conclusion to build a Linux File Server, complete with a Software RAID5 (as opposed to a hardware RAID5), and make it so that we can use iSCSI to mount the LUNs.<\/p>\n<p>We need to do this on a budget, too.<\/p>\n<p><!--more--><\/p>\n<p><strong>Our Wants and Needs<\/strong><br \/>\nWe need to idealize and setup what we need our beast to do. We&#8217;re gonna need some scenarios where things go down and we need to be able to kick it back into shape:<\/p>\n<ol>\n<li>Create the RAID<\/li>\n<li><a href=\"https:\/\/www.unliterate.net\/index.php\/2018\/01\/23\/home-linux-file-server-with-software-raid-and-iscsi-23-10\/\">Break the RAID<\/a><\/li>\n<li><a href=\"https:\/\/www.unliterate.net\/index.php\/2018\/01\/23\/home-linux-file-server-with-software-raid-and-iscsi-23-10\/\">Add the Spare and Rebuild<\/a><\/li>\n<li><a href=\"https:\/\/www.unliterate.net\/index.php\/2018\/01\/24\/home-linux-file-server-with-software-raid-and-iscsi-45-10\/\">Setup and configure iSCSI Target<\/a><\/li>\n<li><a href=\"https:\/\/www.unliterate.net\/index.php\/2018\/01\/24\/home-linux-file-server-with-software-raid-and-iscsi-45-10\/\">Mount the LUN from a separate computer<\/a><\/li>\n<li><a href=\"https:\/\/www.unliterate.net\/index.php\/2018\/01\/25\/home-linux-file-server-with-software-raid-and-iscsi-678-10\/\">Break the RAID, again<\/a><\/li>\n<li><a href=\"https:\/\/www.unliterate.net\/index.php\/2018\/01\/25\/home-linux-file-server-with-software-raid-and-iscsi-678-10\/\">Verify that we can still create\/make files<\/a><\/li>\n<li><a href=\"https:\/\/www.unliterate.net\/index.php\/2018\/01\/25\/home-linux-file-server-with-software-raid-and-iscsi-678-10\/\">Rebuild the RAID with the Spare<\/a><\/li>\n<li><a href=\"https:\/\/www.unliterate.net\/index.php\/2018\/01\/25\/home-linux-file-server-with-software-raid-and-iscsi-9-10\/\">Reinstall Core Operating system, configure it up, and mount and use \/md<\/a><\/li>\n<li>Install different OS, configure it up, mount and use\/md<\/li>\n<\/ol>\n<p>So, we&#8217;ve got a good base on keeping data kept for years to come \ud83d\ude42<\/p>\n<p><strong>Virtualize to validate<\/strong><br \/>\nIt&#8217;s best, before we do anything with any purchases, to go the free and open route. Hence, we&#8217;ll virtualize in <a href=\"https:\/\/www.virtualbox.org\/wiki\/Downloads\" rel=\"noopener\" target=\"_blank\">Oracle Virtuabox<\/a>.<\/p>\n<p>We&#8217;ll start with a base <a href=\"http:\/\/isoredirect.centos.org\/centos\/6\/isos\/x86_64\/\" rel=\"noopener\" target=\"_blank\">Centos 6.9 setup<\/a> in Virtuabox that I&#8217;ve amicably called <em>eye-scrunchie<\/em>. I&#8217;ve provided the OS with 8GB for storage for \/ and \/boot. I&#8217;ve created an additional 4 SATA devices, all with 256MB of space. I don&#8217;t need to create a TON of space on them, but I do need enough to create a base RAID5 w\/ 1 Spare. To not over-complicate configuration anymore I&#8217;ve provided 1 Ethernet Port bridged to my onboard NIC.<\/p>\n<p><strong>Setup Base System<\/strong><\/p>\n<p>After installing and <em>yum update<\/em>&#8216;ing the base system, i&#8217;ve done the typical <em>iptables<\/em> and <em>selinux<\/em> &#8220;configurations&#8221; (aka shutting them all downs):<\/p>\n<pre># yum update\r\n# service iptables save\r\n# service iptables stop\r\n# chkconfig iptables off\r\n# cat \/etc\/selinux\/config | sed s\/=enforcing\/=disabled\/ &gt; \/etc\/selinux\/config.new && rm \/etc\/selinux\/config && mv \/etc\/selinux\/config.new \/etc\/selinux\/config\r\n# shutdown -r now<\/pre>\n<p>We&#8217;re gonna use a guide to help us out, but not follow it 100% since we have an idea of what we want to use from it: [<a href=\"https:\/\/wiki.archlinux.org\/index.php\/Software_RAID_and_LVM\" target=\"_blank\" rel=\"noopener\">archlinux:Software RAID and LVM<\/a>]<\/p>\n<p><strong>Setup Disks<\/strong><\/p>\n<p>Check if we have the the kernel module for this:<\/p>\n<pre># modprobe raid5<\/pre>\n<p>Now, we need to verify that the OS sees the disks, and create partitions on them all. We&#8217;re going to use <em>fdisk<\/em> for now, but for larger volumes later on I might use a different program. For now, I just need to be able to make the necessary partitions. We&#8217;re working with \/dev\/sdb, \/dev\/sdc, \/dev\/sdd, and \/dev\/sde will be our &#8220;recovery spare&#8221;.<\/p>\n<pre># fdisk \/dev\/sdb\r\nCommand (m for help): : c\r\nDOS Compatibility flag is not set\r\n\r\nCommand (m for help): : u\r\nChanging display\/entry units to sectors\r\n\r\nCommand (m for help): n\r\nCommand action\r\ne extended\r\np primary partition (1-4)\r\np\r\nPartition number (1-4): 1\r\nFirst sector (2048-524287, default 2048):\r\nUsing default value 2048\r\nLast sector, +sectors or +size{K,M,G} (2048-524287, default 524287):\r\nUsing default value 524287\r\n\r\nCommand (m for help): t\r\nSelected partition 1\r\nHex code (type L to list codes): fd\r\nChanged system type of partition 1 to fd (Linux raid autodetect)\r\n\r\nCommand (m for help): p\r\nDisk \/dev\/sdb: 268 MB, 268435456 bytes\r\n255 heads, 63 sectors\/track, 32 cylinders, total 524288 sectors\r\nUnits = sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 512 bytes\r\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\r\nDisk identifier: 0x0005d307\r\nDevice Boot Start End Blocks Id System\r\n\/dev\/sdb1 2048 524287 261120 fd Linux raid autodetect\r\n\r\nCommand (m for help): w\r\nThe partition table has been altered!\r\n\r\nCalling ioctl() to re-read partition table.\r\n\r\nWARNING: If you have created or modified any DOS 6.x\r\npartitions, please see the fdisk manual page for additional\r\ninformation.\r\n\r\nSyncing disks.<\/pre>\n<p>In Short: <code>c u n p 1 enter enter t fd p w<\/code><\/p>\n<p>And performed the same with the other 3 disks.<\/p>\n<p><strong>Setup RAID<\/strong><\/p>\n<p>This seems to be cut-and-dry:<\/p>\n<pre># mdadm --create \/dev\/md0 --level=5 --raid-devices=3 \/dev\/sd[bcd]1\r\nmdadm: Defaulting to version 1.2 metadata\r\nmdadm: array \/dev\/md0 started.\r\n<\/pre>\n<p>Checking on the status:<\/p>\n<pre># mdadm --misc --detail \/dev\/md0\r\n\/dev\/md0:\r\n        Version : 1.2\r\n  Creation Time : Mon Jan 22 22:35:54 2018\r\n     Raid Level : raid5\r\n     Array Size : 520192 (508.00 MiB 532.68 MB)\r\n  Used Dev Size : 260096 (254.00 MiB 266.34 MB)\r\n   Raid Devices : 3\r\n  Total Devices : 3\r\n    Persistence : Superblock is persistent\r\n\r\n    Update Time : Mon Jan 22 22:35:58 2018\r\n          State : clean\r\n Active Devices : 3\r\nWorking Devices : 3\r\n Failed Devices : 0\r\n  Spare Devices : 0\r\n\r\n         Layout : left-symmetric\r\n     Chunk Size : 512K\r\n\r\n           Name : eye-scrunchie:0  (local to host eye-scrunchie)\r\n           UUID : e47e9e3a:8b2d2d70:430fa6dc:babf2503\r\n         Events : 18\r\n\r\n    Number   Major   Minor   RaidDevice State\r\n       0       8       17        0      active sync   \/dev\/sdb1\r\n       1       8       33        1      active sync   \/dev\/sdc1\r\n       3       8       49        2      active sync   \/dev\/sdd1\r\n<\/pre>\n<p>and make it persistent:<\/p>\n<pre># mdadm --examine --scan > \/etc\/mdadm.conf<\/pre>\n<p><strong>Format + Mount <\/strong><\/p>\n<p>Format with ext4:<\/p>\n<pre># mkfs.ext4 \/dev\/md0\r\nmke2fs 1.41.12 (17-May-2010)\r\nFilesystem label=\r\nOS type: Linux\r\nBlock size=1024 (log=0)\r\nFragment size=1024 (log=0)\r\nStride=512 blocks, Stripe width=1024 blocks\r\n130048 inodes, 520192 blocks\r\n26009 blocks (5.00%) reserved for the super user\r\nFirst data block=1\r\nMaximum filesystem blocks=67633152\r\n64 block groups\r\n8192 blocks per group, 8192 fragments per group\r\n2032 inodes per group\r\nSuperblock backups stored on blocks:\r\n        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409\r\n\r\nWriting inode tables: done\r\nCreating journal (8192 blocks): done\r\nWriting superblocks and filesystem accounting information: done\r\n\r\nThis filesystem will be automatically checked every 36 mounts or\r\n180 days, whichever comes first.  Use tune2fs -c or -i to override.<\/pre>\n<p>&#8230;mount it as \/data<\/p>\n<pre># mount -t ext4 \/dev\/md0 \/data<\/pre>\n<p>and add it to \/etc\/fstab<\/p>\n<pre>...data...\r\n\/dev\/md0 \/data ext4 defaults 0 0<\/pre>\n<p>And now we&#8217;ve concluded #1: &#8220;Create the RAID&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yays! Fun stuff in route! Part of my 2018 goals is to be able to have a universally-accessible resource where I can be able to store all the data that I need to, and more, without worry of fault or loss. One of the ways to approach this is to create a File Server that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,20,17],"tags":[],"class_list":["post-299","post","type-post","status-publish","format-standard","hentry","category-centos","category-geek-instructions","category-linux"],"_links":{"self":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts\/299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/comments?post=299"}],"version-history":[{"count":18,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts\/299\/revisions"}],"predecessor-version":[{"id":334,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts\/299\/revisions\/334"}],"wp:attachment":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/media?parent=299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/categories?post=299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/tags?post=299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}