{"id":877,"date":"2020-07-14T16:19:14","date_gmt":"2020-07-14T10:19:14","guid":{"rendered":"https:\/\/hasibul.info\/blog\/?p=877"},"modified":"2021-01-07T13:06:48","modified_gmt":"2021-01-07T07:06:48","slug":"how-to-create-raid1-mirroring-with-3rd-4th-drives-in-ovh-servers","status":"publish","type":"post","link":"https:\/\/hasibul.info\/blog\/2020\/07\/14\/how-to-create-raid1-mirroring-with-3rd-4th-drives-in-ovh-servers\/","title":{"rendered":"How to create Raid1 mirroring with 3rd &#038; 4th Drives in OVH servers"},"content":{"rendered":"<p>OVH panel offers easy Raid configuration for the partitions in up to 2 drives. Recently I was working on a server that has 2 SSDs and 2 HDDs. The server is intended to serve as a Shared Hosting server. My idea was to install the OS on the SSDs and use the HDDs for hosting website data. It was not much of a hassle to install the OS on SSds on Raid1. I can easily add the two HDDs as additional drives and mount them both to be used for storage. But there&#8217;s a drawback in such configuration. There will be no redundancy for the storage drives. If any of those HDDs crash &#8211; I will lose all data on it. So, my idea is to create another Raid1 with the two HDDs. Unfortunately, it is not possible from the OVH panel and OVH denied any support on this issue. Therefore I had to do it myself.<\/p>\n<p>Since many of the server providers are offering servers with 4 drives &#8211; I believe some of you might find this useful. The idea is to create two Raid arrays of 4 drives. In this case &#8211; the two SSDs were already in Raid 1 &#8211; configured by the OVH panel. So what I needed to do is to create another Raid 1 with the other two HDDs.<\/p>\n<p>Here is how the initial configuration looked like:<\/p>\n<p>#lsblk<\/p>\n<p><img src=\"https:\/\/hasibul.info\/blog\/wp-content\/uploads\/2020\/07\/deafult-config-after-os-install-ovh.jpg\" alt=\"ovh default settings with 4 drives\"><\/p>\n<p>There already is a Raid1 between the second partitions of the two SSDs (nvme0n1p2 &amp; nvme1n1p2). The two HDDs are &#8220;sda&#8221; &amp; &#8220;sdb&#8221; which are unformatted and no partitions are created.<\/p>\n<p>The basic steps are as follows:<\/p>\n<ol>\n<li>Create a partition in sda with full volume<\/li>\n<li>Create a partition in sdb with full volume<\/li>\n<li>Create a Raid1 with the two partitions from sda &amp; sdb<\/li>\n<li>&nbsp;Set the file system (ext4) for the newly created Raid1<\/li>\n<li>Mount the newly created Raid1 to be used as the new volume in the server.<\/li>\n<\/ol>\n<p>IMPORTANT NOTES:<\/p>\n<p>To check the current Raid configuration:<br \/>\n#cat \/proc\/mdstat<\/p>\n<p>To create a new partition in a drive:<br \/>\n# fdisk \/dev\/sd[x]<\/p>\n<p><strong>fdisk can create partitions with max 2TB<\/strong>. Here in my case the two HDDs were of 4TB each. Therefore I had to use <strong>GPT parted<\/strong> to create the partition. If you want to learn more about GPT <a href=\"https:\/\/www.cyberciti.biz\/tips\/fdisk-unable-to-create-partition-greater-2tb.html\">click here<\/a>.<\/p>\n<h2><strong>1. Create a partition in sda with full volume:<\/strong><\/h2>\n<p># parted \/dev\/sda<\/p>\n<p>Output:<\/p>\n<p>GNU Parted 2.3<br \/>\nUsing \/dev\/sda<br \/>\nWelcome to GNU Parted! Type &#8216;help&#8217; to view a list of commands.<br \/>\n(parted)<br \/>\nCreates a new GPT disklabel i.e. partition table:<br \/>\n#(parted) mklabel gpt<br \/>\nSample outputs:<br \/>\nWarning: The existing disk label on \/dev\/sda will be destroyed and all data on this disk will be lost. Do you want to continue?<br \/>\nYes\/No? yes<br \/>\n(parted)<\/p>\n<p>Next, set the default unit to TB, enter:<br \/>\n#(parted) unit TB<\/p>\n<p>To create a 3.7TB partition size, enter:<br \/>\n#(parted) mkpart primary 0 0<br \/>\nOR<br \/>\n#(parted) mkpart primary 0.00TB 3.70TB<\/p>\n<p>To print the current partitions, enter:<br \/>\n#(parted) print<\/p>\n<p>Sample outputs:<br \/>\nModel: ATA ST33000651AS (scsi)<br \/>\nDisk \/dev\/sda: 3.70TB<br \/>\nSector size (logical\/physical): 512B\/512B<br \/>\nPartition Table: gpt<\/p>\n<p>Number Start End Size File system Name Flags<br \/>\n1 0.00TB 4.00TB 4.00TB ext4 primary<\/p>\n<p>Quit and save the changes, enter:<br \/>\n#(parted) quit<br \/>\nSample outputs:<br \/>\nInformation: You may need to update \/etc\/fstab. (Since we will be creating Raid with this partition &#8211; not need to add this in \/etc\/fstab in this case)<\/p>\n<p>Use the mkfs.ext3 or mkfs.ext4 (ext4 preferred) command to format the file system, enter:<br \/>\n# mkfs.ext3 \/dev\/sda1<\/p>\n<p>OR<br \/>\n# mkfs.ext4 \/dev\/sda1<\/p>\n<h2><strong>2. Create a partition in sdb with full volume<\/strong><\/h2>\n<p># parted \/dev\/sdb<\/p>\n<p>#(parted) mklabel gpt<br \/>\nWarning: The existing disk label on \/dev\/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?<br \/>\nYes\/No? yes<br \/>\n(parted)<\/p>\n<p>Next, set the default unit to TB, enter:<br \/>\n#(parted) unit TB<\/p>\n<p>To create a 3.7TB partition size, enter:<br \/>\n#(parted) mkpart primary 0 0<br \/>\nOR<br \/>\n#(parted) mkpart primary 0.00TB 3.70TB<\/p>\n<p>To print the current partitions, enter:<br \/>\n#(parted) print<br \/>\nSample outputs:<\/p>\n<p>Model: SATA ST33000651AS (scsi)<br \/>\nDisk \/dev\/sdb: 3.70TB<br \/>\nSector size (logical\/physical): 512B\/512B<br \/>\nPartition Table: gpt<\/p>\n<p>Number Start End Size File system Name Flags<br \/>\n1 0.00TB 4.00TB 4.00TB ext4 primary<\/p>\n<p>Quit and save the changes, enter:<\/p>\n<p>#(parted) quit<\/p>\n<p>Sample outputs:<br \/>\nInformation: You may need to update \/etc\/fstab.<\/p>\n<p>Use the mkfs.ext3 or mkfs.ext4 (ext4 preferred) command to format the file system, enter:<br \/>\n# mkfs.ext3 \/dev\/sdb1<br \/>\nOR<br \/>\n# mkfs.ext4 \/dev\/sdb1<\/p>\n<p>IMPORTANT NOTE:<br \/>\nBEFORE PROCEEDING TO NEXT STEP CHECK THE FILE SYSTEMS OF THE NEWLY CREATED PARTITIONS OF THE TWO DRIVES:<\/p>\n<p>#fdisk -l<\/p>\n<p>If you see something like the following:<br \/>\n<img src=\"https:\/\/hasibul.info\/blog\/wp-content\/uploads\/2020\/07\/partition-file-type-microsoft-basic.jpg\" alt=\"partition file type microsoft basic\"><\/p>\n<p>You need to do some extra steps to convert these partitions to ext4. Please check the (#13 reply) <a href=\"https:\/\/bbs.archlinux.org\/viewtopic.php?id=191163\">THIS LINK<\/a> for details.<br \/>\n=============================================================<br \/>\nSolution: Install gdisk (yum install gdisk) (Check: https:\/\/bbs.archlinux.org\/viewtopic.php?id=191163 (check #13 reply))<br \/>\nNEED TO CHANGE THE FILE SYSTEMS (reported by fdisk -l) from Microsoft Basic to &#8220;Linux File System&#8221; with the above-mentioned solution)<\/p>\n<p># yum install gdisk<br \/>\n# gdisk \/dev\/sda \ud83d\ude41<br \/>\nGPT fdisk (gdisk) version 0.8.10<\/p>\n<p>Partition table scan:<br \/>\nMBR: protective<br \/>\nBSD: not present<br \/>\nAPM: not present<br \/>\nGPT: present<\/p>\n<p>Found valid GPT with protective MBR; using GPT.<\/p>\n<p>#Command (? for help): t<br \/>\n#Partition number (1-1): 1<br \/>\nCurrent type is &#8216;Microsoft basic data&#8217;<br \/>\nHex code or GUID (L to show codes, Enter = 8300):<br \/>\nChanged type of partition to &#8216;Linux filesystem&#8217;<\/p>\n<p>#Command (? for help): p<br \/>\n#Command (? for help): w<\/p>\n<p>Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING<br \/>\nPARTITIONS!!<\/p>\n<p>Do you want to proceed? (Y\/N): Y<br \/>\nOK; writing new GUID partition table (GPT) to \/dev\/sda.<br \/>\nThe operation has completed successfully.<\/p>\n<p><strong>DO THE SAME FOR SDB<\/strong><br \/>\n=============================================================<\/p>\n<h2><strong>3. Create a Raid1 with the two partitions from sda &amp; sdb<\/strong><\/h2>\n<p>We already had a Raid1 of the two partitions from SSD named &#8220;md2&#8221;. We can find it:<\/p>\n<p># cat \/proc\/mdstat<\/p>\n<p>In steps 1 &amp; 2 &#8211; we created two new partitions in &#8220;sda&#8221; &amp; &#8220;sdb&#8221; named &#8220;sda1&#8221; &amp; &#8220;sdb1&#8221; respectively.<br \/>\n<img src=\"https:\/\/hasibul.info\/blog\/wp-content\/uploads\/2020\/07\/partitions-in-3rd-4th-drive-no-raid-yet.jpg\" alt=\"partitions 3rd 4th drive no raid yet\"><\/p>\n<p>Check the Raid status of sda1 &amp; sdb1:<br \/>\n# mdadm &#8211;examine \/dev\/sd[a-b]1<br \/>\n&#8211; it will show no raid<\/p>\n<p><strong>NOW run the following to create the Raid1 between sda1 and sdb1:<\/strong><br \/>\n# mdadm &#8211;create \/dev\/md3 &#8211;level=mirror &#8211;raid-devices=2 \/dev\/sd[a-b]1<\/p>\n<p>The name of the new Raid1 array is &#8220;md3&#8221;.<\/p>\n<p>Now check the &#8220;lsblk&#8221; again and it will show &#8220;md3&#8221; 3.7TB<br \/>\n<img src=\"https:\/\/hasibul.info\/blog\/wp-content\/uploads\/2020\/07\/md3-raid1-configured-sda1-sdb1.jpg\" alt=\"md3 raid sda1 sdb1\"><\/p>\n<p>Now if you check Raid status ( # cat \/proc\/mdstat ) you&#8217;ll see the Raid partitions sda1 &amp; sdb1 are syncing.<br \/>\n<img src=\"https:\/\/hasibul.info\/blog\/wp-content\/uploads\/2020\/07\/md3-raid1-configured-sda1-sdb1-sync.jpg\" alt=\"md3 sda1 sdb1 sync\"><\/p>\n<p>The 4TB disks took almost 5 hours to complete the syncing.<\/p>\n<h2><strong>4. Set the file system (ext4) for the newly created Raid1<\/strong><\/h2>\n<p>Execute the following command to set the file system (ext4) of the newly created md3 Raid drive:<\/p>\n<p># mkfs.ext4 \/dev\/md3<\/p>\n<h2><strong>5. Mount the newly created Raid1<br \/>\n<\/strong><\/h2>\n<p>We want to mount the newly created Raid1 (md3) to the directory &#8220;\/home2&#8221;. We need to do the following:<\/p>\n<p># mkdir \/home2<br \/>\n# mount \/dev\/md3 \/home2<\/p>\n<p><img src=\"https:\/\/hasibul.info\/blog\/wp-content\/uploads\/2020\/07\/after-finishing-config-after-os-install-ovh-e1594720509733.jpg\" alt=\"md3 mounted home2\"><\/p>\n<p>Now we need to edit \/etc\/fstab and add the new Raid volume &#8211; so that the storage volume is not lost after the server reboots.<br \/>\n<img src=\"https:\/\/hasibul.info\/blog\/wp-content\/uploads\/2020\/07\/editing-etc-fstab-to-save-the-new-storage-volume.jpg\" alt=\"edit etc fstab to save the storage volume home2\"><\/p>\n<p># nano \/etc\/fstab<\/p>\n<p>add the following line: \/dev\/md3 \/home2 ext4 defaults 0 0<\/p>\n<p>and save the file. That&#8217;s it. The new storage volume will remain after server reboot and we can use this to store our data. If we now check the storage details &#8211; we will see the following:<\/p>\n<p><img src=\"https:\/\/hasibul.info\/blog\/wp-content\/uploads\/2020\/07\/final-picture-of-storage-after-second-raid-added-as-storage.jpg\" alt=\"final storage details after adding second raid1 storage\"><\/p>\n<p>The process will be the same for servers from any provider and not only OVH. Feel free to add your suggestion if you think anything can be improved here or if you encounter any problems by following this article. Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OVH panel offers easy Raid configuration for the partitions in up to 2 drives. Recently I was working on a server that has 2 SSDs and 2 HDDs. The server is intended to serve as a Shared Hosting server. My idea was to install the OS on the SSDs and use the HDDs for hosting&hellip;<\/p>","protected":false},"author":1,"featured_media":913,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18,6,12],"tags":[430,429,437,434,436,433,432,438,224,95,435,425,431,426,424,428,427,223,134],"how-to":[],"_links":{"self":[{"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/posts\/877"}],"collection":[{"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/comments?post=877"}],"version-history":[{"count":0,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/posts\/877\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/media\/913"}],"wp:attachment":[{"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/media?parent=877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/categories?post=877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/tags?post=877"},{"taxonomy":"how-to","embeddable":true,"href":"https:\/\/hasibul.info\/blog\/wp-json\/wp\/v2\/how-to?post=877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}