{"id":2336,"date":"2016-07-11T12:57:38","date_gmt":"2016-07-11T00:57:38","guid":{"rendered":"http:\/\/www.zoyinc.com\/?p=2336"},"modified":"2016-07-13T06:08:16","modified_gmt":"2016-07-12T18:08:16","slug":"create-a-single-mirror-disk-for-raid1","status":"publish","type":"post","link":"http:\/\/www.zoyinc.com\/?p=2336","title":{"rendered":"Create a single mirror disk for a RAID1 array"},"content":{"rendered":"<p>I have a problem, I have a 3TB drive which has all my data on it but I need to move to a new RAID solution using Open Media Vault, OMV.<\/p>\n<p>I want to set up a mirrored, RAID1, 3TB array so will need two 3TB drives. I plan to use my current 3TB drive as half of the array. I could just buy two new 3TB disks but I can&#8217;t afford to do this.<\/p>\n<p>The plan is to create a mirrored array with just one disk, then copy my data from my old disk to my new one. Then wipe my old drive and add it to the array.<\/p>\n<p>This post is about how to create a mirrored RAID1 array in Open Media Vault but with only one disk. OMV doesn&#8217;t allow you to do this as it won&#8217;t allow you to create a RAID1 array with just one disk.<\/p>\n<h2>Steps:<\/h2>\n<table class=\"zsteps\" style=\"width: 628px;\">\n<tbody>\n<tr style=\"height: 18px;\">\n<td style=\"width: 13px; height: 18px;\">1.<\/td>\n<td style=\"width: 570px; height: 18px;\">To begin with run OMV with only the system disk attached.<\/td>\n<\/tr>\n<tr style=\"height: 18px;\">\n<td style=\"width: 13px; height: 18px;\">2.<\/td>\n<td style=\"width: 570px; height: 18px;\">SSH to your OMV server as root.<\/td>\n<\/tr>\n<tr style=\"height: 536px;\">\n<td style=\"width: 13px; height: 536px;\">3.<\/td>\n<td style=\"width: 570px; height: 536px;\">Edit the mdadm config file, \/etc\/mdadm\/mdadm.conf which should look like:<\/p>\n<pre class=\"lang:default decode:true\"># mdadm.conf\r\n#\r\n# Please refer to mdadm.conf(5) for information about this file.\r\n#\r\n\r\n# by default, scan all partitions (\/proc\/partitions) for MD superblocks.\r\n# alternatively, specify devices to scan, using wildcards if desired.\r\n# Note, if no DEVICE line is present, then \"DEVICE partitions\" is assumed.\r\n# To avoid the auto-assembly of RAID devices a pattern that CAN'T match is\r\n# used if no RAID devices are configured.\r\nDEVICE partitions\r\n\r\n# auto-create devices with Debian standard permissions\r\nCREATE owner=root group=disk mode=0660 auto=yes\r\n\r\n# automatically tag new arrays as belonging to the local system\r\nHOMEHOST &lt;system&gt;\r\n\r\n# definitions of existing MD arrays\r\nARRAY \/dev\/md0 metadata=1.2 name=nas2:RAID1Mirror UUID=a77b4c17:6ddd1afc:58bf7cdd:a51275ef\r\n\r\n# instruct the monitoring daemon where to send mail alerts\r\nMAILADDR tony@cantabrian.co.nz\r\nMAILFROM root\r\n<\/pre>\n<p>If you see any lines that look like:<\/p>\n<pre class=\"crayon:false;\">ARRAY \/dev\/md0 metadata=1.2 name=nas2:RAID1Mirror UUID=a77b4c17:6ddd1afc:58bf7cdd:a51275ef<\/pre>\n<p>Then you need to comment them out. The main issue seems to be if you create a new disk that clashes with an existing one around the device details, in this case &#8220;\/dev\/md0&#8221;. In my situation I am only having one RAID array on the box so it&#8217;s simple I don&#8217;t need any other array definitions. If you have multiple arrays you might want to play around a bit or do some Googling.<\/td>\n<\/tr>\n<tr style=\"height: 36px;\">\n<td style=\"width: 13px; height: 36px;\">4.<\/td>\n<td style=\"width: 570px; height: 36px;\">Now boot from a Debian Live USB disk, you can see how to create on in the post <a  href=\"http:\/\/www.zoyinc.com\/?p=2353\">Create a Debian Live USB flash drive<\/a><\/td>\n<\/tr>\n<tr style=\"height: 36px;\">\n<td style=\"width: 13px; height: 36px;\">5.<\/td>\n<td style=\"width: 570px; height: 36px;\">If you are considering installing mdadm, please don&#8217;t do it just yet. That will come later.<\/td>\n<\/tr>\n<tr style=\"height: 199px;\">\n<td style=\"width: 13px; height: 199px;\">6.<\/td>\n<td style=\"width: 570px; height: 199px;\">Run lsblk to work out which drive is the RAID one:<\/p>\n<pre class=\"crayon:false;\">root@debian:~# lsblk\r\nNAME\u00a0\u00a0 MAJ:MIN RM\u00a0 SIZE RO TYPE MOUNTPOINT\r\nsda\u00a0\u00a0\u00a0\u00a0\u00a0 8:0\u00a0\u00a0\u00a0 0\u00a0 2.7T\u00a0 0 disk\r\nsdb\u00a0\u00a0\u00a0\u00a0\u00a0 8:16\u00a0\u00a0 1\u00a0 7.5G\u00a0 0 disk\r\n\u2514\u2500sdb1\u00a0\u00a0 8:17\u00a0\u00a0 1\u00a0 1.2G\u00a0 0 part \/lib\/live\/mount\/medium\r\nloop0\u00a0\u00a0\u00a0 7:0\u00a0\u00a0\u00a0 0\u00a0 1.1G\u00a0 1 loop \/lib\/live\/mount\/rootfs\/filesystem.squashfs<\/pre>\n<p>From this you can see the new disk is sda &#8211; by looking at the size, 2.7 TB and also that sdb is mounted as &#8220;\/lib\/live\/mount\/medium&#8221;<\/td>\n<\/tr>\n<tr style=\"height: 433px;\">\n<td style=\"width: 13px; height: 433px;\">7.<\/td>\n<td style=\"width: 570px; height: 433px;\">Now we wipe the old disk just to make sure it is nice and clean, this is why it is good to remove the other disks:<\/p>\n<p>First run:<\/p>\n<pre class=\"crayon:false;\">sgdisk --zap \/dev\/sda<\/pre>\n<p>Then run &#8220;gdisk \/dev\/sda&#8221; and enter &#8220;x&#8221; at the first prompt followed by &#8220;z&#8221;. Finally when prompted &#8220;Blank out MBR&#8221; also enter &#8220;y&#8221;. This should all look like:<\/p>\n<pre class=\"crayon:false; \">root@debian:~# gdisk \/dev\/sda\r\nGPT fdisk (gdisk) version 0.8.10\r\n\r\nPartition table scan:\r\n\u00a0 MBR: not present\r\n\u00a0 BSD: not present\r\n\u00a0 APM: not present\r\n\u00a0 GPT: not present\r\n\r\nCreating new GPT entries.\r\n\r\n<span style=\"background-color: #ffff99;\"><strong>Command (? for help): x<\/strong>\r\n\r\n<strong>Expert command (? for help): z<\/strong><\/span>\r\nAbout to wipe out GPT on \/dev\/sda. Proceed? (Y\/N): y\r\nGPT data structures destroyed! You may now partition the disk using fdisk or\r\nother utilities.\r\n<span style=\"background-color: #ffff99;\"><strong>Blank out MBR? (Y\/N): y<\/strong><\/span><\/pre>\n<\/td>\n<\/tr>\n<tr style=\"height: 180px;\">\n<td style=\"width: 13px; height: 180px;\">8.<\/td>\n<td style=\"width: 570px; height: 180px;\">Now run &#8220;fdisk -l \/dev\/sda&#8221; just to check everything went ok:<\/p>\n<pre class=\"crayon:false;\">root@debian:~# fdisk -l \/dev\/sda\r\n\r\nDisk \/dev\/sda: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors\r\nUnits: sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 4096 bytes\r\nI\/O size (minimum\/optimal): 4096 bytes \/ 4096 bytes<\/pre>\n<p>So no partitions showing.<\/td>\n<\/tr>\n<tr style=\"height: 146px;\">\n<td style=\"width: 13px; height: 146px;\">9.<\/td>\n<td style=\"width: 570px; height: 146px;\">Now you can install mdadm<\/p>\n<pre class=\"crayon:false;\">apt-get install mdadm rsync initramfs-tools<\/pre>\n<p>During the install you will be asked the question \u201cMD arrays needed for the root file system\u201d. You need to enter \u201cnone\u201d !<\/p>\n<p>As has been mentioned before, ensure the window for the terminal is not too small otherwise when you are asked the question about &#8220;MD arrays needed for the root file system&#8221; you will only see:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2424 size-medium\" src=\"http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup01-300x190.gif\" alt=\"mdadm configure screen\" width=\"300\" height=\"190\" srcset=\"http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup01-300x190.gif 300w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup01-150x95.gif 150w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup01-474x300.gif 474w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>If you see the above, simply kill the terminal session and start again with a bigger window and you will now see:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2425 size-medium\" src=\"http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup02-300x164.gif\" alt=\"mdadm configure screen 2\" width=\"300\" height=\"164\" srcset=\"http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup02-300x164.gif 300w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup02-150x82.gif 150w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup02-768x421.gif 768w, http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVBackup02-500x274.gif 500w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/td>\n<\/tr>\n<tr style=\"height: 18px;\">\n<td style=\"width: 13px; height: 18px;\">10.<\/td>\n<td style=\"width: 570px; height: 18px;\">Now create the array by running:<\/p>\n<pre class=\"crayon:false;\">mdadm --create \/dev\/md0 --level=1 --raid-devices=2 missing \/dev\/sda --name=nas2:Mirror --force<\/pre>\n<p>This will look like:<\/p>\n<pre class=\"crayon:false;\">root@debian:~# mdadm --create \/dev\/md0 --level=1 --raid-devices=2 missing \/dev\/sda --name=nas2:Mirror --force\r\nmdadm: Note: this array has metadata at the start and\r\n\u00a0\u00a0\u00a0 may not be suitable as a boot device.\u00a0 If you plan to\r\n\u00a0\u00a0\u00a0 store '\/boot' on this device please ensure that\r\n\u00a0\u00a0\u00a0 your boot-loader understands md\/v1.x metadata, or use\r\n\u00a0\u00a0\u00a0 --metadata=0.90\r\nContinue creating array? y\r\nmdadm: Defaulting to version 1.2 metadata\r\nmdadm: array \/dev\/md0 started.<\/pre>\n<p>Clearly the parameter &#8220;&#8211;name&#8221; is the name of the array. I would suggest you name it &#8220;&lt;OMV hostname&gt;:&lt;raid name&gt;&#8221; to fit in with what would be created if you had done it through OMV. So clearly in my case the hostname for the OMV server is &#8220;nas2&#8221;.<\/p>\n<p>Obviously you need to watch the &#8220;\/dev\/sda&#8221; matches your disk.<\/td>\n<\/tr>\n<tr style=\"height: 18px;\">\n<td style=\"width: 13px; height: 18px;\">11.<\/td>\n<td style=\"width: 570px; height: 18px;\">Now that the RAID array has been created you should add a file system so run &#8220;mkfs.ext4 -L Data \/dev\/md0&#8221;. The &#8220;-L&#8221; parameter is the name\/label for the file system, in my case &#8220;Data&#8221;. Also the &#8220;\/dev\/md0&#8221; must clearly match the details you entered when creating the array.<\/p>\n<pre class=\"crayon:false;\">root@debian:~# mkfs.ext4 -L Data \/dev\/md0\r\nmke2fs 1.42.12 (29-Aug-2014)\r\n\/dev\/md0 contains a ext4 file system labelled 'Data2'\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 last mounted on Mon Jul 11 08:46:39 2016\r\nProceed anyway? (y,n) y\r\nCreating filesystem with 732533872 4k blocks and 183140352 inodes\r\nFilesystem UUID: f20b47a4-d207-40aa-a7e6-42ea82354455\r\nSuperblock backups stored on blocks:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 102400000, 214990848, 512000000, 550731776, 644972544\r\n\r\nAllocating group tables: done\r\nWriting inode tables: done\r\nCreating journal (32768 blocks): done\r\nWriting superblocks and filesystem accounting information: done<\/pre>\n<\/td>\n<\/tr>\n<tr style=\"height: 18px;\">\n<td style=\"width: 13px; height: 18px;\">12.<\/td>\n<td style=\"width: 570px; height: 18px;\">Shutdown the Deblian live and connect your disks back and boot into OMV<\/td>\n<\/tr>\n<tr style=\"height: 18px;\">\n<td style=\"width: 13px; height: 18px;\">13.<\/td>\n<td style=\"width: 570px; height: 18px;\">Now when you boot into OMV if you select &#8220;Storage | File Systems&#8221; you will see your new file system, we called &#8220;Data&#8221;, but it won&#8217;t be mounted:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2501 size-full\" src=\"http:\/\/www.zoyinc.com\/wp-content\/uploads\/2016\/07\/OMVCreateHDD04.gif\" alt=\"OMV New RAID array\" width=\"998\" height=\"119\" \/><\/p>\n<p>You should select the &#8220;Data&#8221; file system and click on mount. After you have done that you will get the &#8220;The configuration has changed message&#8230;&#8221; and you should click on &#8220;Apply&#8221;.<\/td>\n<\/tr>\n<tr style=\"height: 18px;\">\n<td style=\"width: 13px; height: 18px;\">14.<\/td>\n<td style=\"width: 570px; height: 18px;\">From your terminal session you should add the array to the mdadm.conf:<\/p>\n<pre class=\"crayon:false;\">mdadm --detail --scan &gt;&gt; \/etc\/mdadm\/mdadm.conf<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>You should now be in a position to create shares and so on.<\/p>\n<p>&nbsp;<\/p>\n<h2>Resources<\/h2>\n<p><span class=\"title\">Setting up RAID on an existing Debian\/Ubuntu installation<\/span><\/p>\n<p><a  href=\"https:\/\/feeding.cloud.geek.nz\/posts\/setting-up-raid-on-existing\/\">https:\/\/feeding.cloud.geek.nz\/posts\/setting-up-raid-on-existing\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Mdadm Cheat Sheet<\/p>\n<p><a  href=\"http:\/\/www.ducea.com\/2009\/03\/08\/mdadm-cheat-sheet\/\">http:\/\/www.ducea.com\/2009\/03\/08\/mdadm-cheat-sheet\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a problem, I have a 3TB drive which has all my data on it but I need to move to a new RAID solution using Open Media Vault, OMV. I want to set up a mirrored, RAID1, 3TB array so will need two 3TB drives. I plan to use my current 3TB drive [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[312,313],"tags":[318,338,337,319,320,326],"class_list":["post-2336","post","type-post","status-publish","format-standard","hentry","category-debian","category-open-media-vault","tag-debian","tag-mdadm","tag-missing","tag-omv","tag-open-media-vault","tag-raid"],"_links":{"self":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/2336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2336"}],"version-history":[{"count":23,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/2336\/revisions"}],"predecessor-version":[{"id":2506,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/2336\/revisions\/2506"}],"wp:attachment":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2336"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}