{"id":880,"date":"2022-02-08T18:04:38","date_gmt":"2022-02-08T12:04:38","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=880"},"modified":"2022-02-08T18:04:38","modified_gmt":"2022-02-08T12:04:38","slug":"how-to-create-software-raid-1-on-fresh-nvme-drives-in-centos-rhel","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/how-to-create-software-raid-1-on-fresh-nvme-drives-in-centos-rhel.html","title":{"rendered":"How to create Software RAID 1 on Fresh NVMe Drives in CentOS\/RHEL"},"content":{"rendered":"\n<p>Let&#8217;s say, you just installed two NVMe drives. That means, you currently have the following devices on your system:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/dev\/nvme0n1\n\/dev\/nvme0n2<\/pre>\n\n\n\n<p>Now, to use Raid 1 on these devices, you need to first partition them. If your devices are less than 2TB, you can use label msdos with fdisk. But I prefer gpt with parted. I will partition the disks using parted.<\/p>\n\n\n\n<p>Open the disk nvme0n1 using parted<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">parted \/dev\/nvme0n1<\/pre>\n\n\n\n<p>Now, set the label to gpt<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mklabel gpt<\/pre>\n\n\n\n<p>Now, create the primary partition<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkpart primary 0TB 1.9TB<\/pre>\n\n\n\n<p>Assuming 1.9TB is the size of your drive. <\/p>\n\n\n\n<p>Run the above process for nvme1n1 as well. This will create one partition on each device which would be like the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/dev\/nvme0n1p1\n\/dev\/nvme1n1p1<\/pre>\n\n\n\n<p>Now, you may create the raid, using mdadm command as follows:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mdadm --create \/dev\/md201 --level=mirror --raid-devices=2 \/dev\/nvme0n1p1 \/dev\/nvme1n1p1<\/pre>\n\n\n\n<p>If you see, mdadm command not found, then you can install mdadm using the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">yum install mdadm -y<\/pre>\n\n\n\n<p>Once done, you may now see your raid using the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[root@bd3 ~]# cat \/proc\/mdstat\nPersonalities : [raid1]\nmd301 : active raid1 sdd1[1] sdc1[0]\n      976628736 blocks super 1.2 [2\/2] [UU]\n      bitmap: 0\/8 pages [0KB], 65536KB chunk\n\nmd201 : active raid1 nvme1n1p1[1] nvme0n1p1[0]\n      1875240960 blocks super 1.2 [2\/2] [UU]\n      bitmap: 2\/14 pages [8KB], 65536KB chunk\n\nmd124 : active raid1 sda5[0] sdb5[1]\n      1843209216 blocks super 1.2 [2\/2] [UU]\n      bitmap: 4\/14 pages [16KB], 65536KB chunk\n\nmd125 : active raid1 sda2[0] sdb2[1]\n      4193280 blocks super 1.2 [2\/2] [UU]\n\nmd126 : active raid1 sdb3[1] sda3[0]\n      1047552 blocks super 1.2 [2\/2] [UU]\n      bitmap: 0\/1 pages [0KB], 65536KB chunk\n\nmd127 : active raid1 sda1[0] sdb1[1]\n      104856576 blocks super 1.2 [2\/2] [UU]\n      bitmap: 1\/1 pages [4KB], 65536KB chunk\n\nunused devices: &lt;none><\/pre>\n\n\n\n<p>Here are a few key pieces of information about software raid:<\/p>\n\n\n\n<ol><li>It is better not to use Raid 10 with software raid. In case the raid configuration is lost, it is hard to know which drives were set as stripe and which like a mirror by the mdadm. It is a better practice to use raid 1 as a rule of thumb with software raid.<\/li><li>Raid 1 in mdadm doubles the read request in parallel. In raid 1, one request reads from one device, while the other request in parallel would read from the next device. This gives double read throughput when there is a parallel thread running. It still suffers from the write cost for writing data in two devices.<\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s say, you just installed two NVMe drives. That means, you currently have the following devices on your system: Now, to use Raid 1 on these devices, you need to first partition them. If your devices are less than 2TB, you can use label msdos with fdisk. But I prefer gpt with parted. I will &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/how-to-create-software-raid-1-on-fresh-nvme-drives-in-centos-rhel.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to create Software RAID 1 on Fresh NVMe Drives in CentOS\/RHEL&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[12,18],"tags":[666,667,552,549,665,95,664],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/880"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=880"}],"version-history":[{"count":1,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/880\/revisions"}],"predecessor-version":[{"id":881,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/880\/revisions\/881"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}