{"id":9084,"date":"2021-06-15T22:32:35","date_gmt":"2021-06-15T19:32:35","guid":{"rendered":"https:\/\/kifarunix.com\/?p=9084"},"modified":"2024-03-18T21:00:18","modified_gmt":"2024-03-18T18:00:18","slug":"create-raid-level-10-raid-10-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/create-raid-level-10-raid-10-on-ubuntu-20-04\/","title":{"rendered":"Create RAID Level 10 (RAID 1+0) on Ubuntu 20.04"},"content":{"rendered":"\n<p>Software RAID levels can be managed using <code><strong>mdadm<\/strong><\/code> tool on Linux. In this tutorial, you will learn how to create RAID Level 10 (RAID 1+0) on Ubuntu 20.04 using <code><strong>mdadm<\/strong><\/code> utility. There are different levels of RAID configurations ranging from 0-9. Some levels, such as RAID level 1 (<strong><code>mirroring<\/code><\/strong>) and RAID level 0 (<code><strong>striping<\/strong><\/code>) can be combined to provide better storage redundancy and higher chances of data recovery just in case some disks get corrupted.<\/p>\n\n\n\n<p>In our previous guide, we learnt how to create and setup RAID level 1.<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/setup-software-raid-on-ubuntu-20-04\/\" target=\"_blank\" rel=\"noreferrer noopener\">Setup Software RAID on Ubuntu 20.04<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating RAID Level 10 on Ubuntu 20.04<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Attach Physical Drives to your Machine<\/h3>\n\n\n\n<p>RAID level 10 (1+0), requires at least four drives.<\/p>\n\n\n\n<p>We already have physical drives attached to our system,<strong>\/dev\/sd[b-e]<\/strong>, all with <strong>4G<\/strong> storage size.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>lsblk<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT\nloop0                       7:0    0 93.8M  1 loop \/snap\/core\/8935\nloop1                       7:1    0   67M  1 loop \/snap\/lxd\/14133\nsda                         8:0    0   15G  0 disk \n\u251c\u2500sda1                      8:1    0    1M  0 part \n\u251c\u2500sda2                      8:2    0    1G  0 part \/boot\n\u2514\u2500sda3                      8:3    0   14G  0 part \n  \u2514\u2500ubuntu--vg-ubuntu--lv 253:0    0   14G  0 lvm  \/\nsdb                         8:16   0    4G  0 disk \nsdc                         8:32   0    4G  0 disk \nsdd                         8:48   0    4G  0 disk \nsde                         8:64   0    4G  0 disk<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Creating RAID Partitions<\/h3>\n\n\n\n<p>Partition and initialize the disks attached above as RAID partitions.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>for i in {b..e}; do parted -a optimal \/dev\/sd$i mklabel msdos; done<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>for i in {b..e}; do parted -a optimal \/dev\/sd$i mkpart primary ext4 0% 100%; done<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>for i in {b..e}; do parted -a optimal \/dev\/sd$i set 1 raid on; done<\/code><\/pre>\n\n\n\n<p>Checking the partition tables for the disk;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>parted -a optimal \/dev\/sdb print<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Model: ATA VBOX HARDDISK (scsi)\nDisk \/dev\/sdb: 4295MB\nSector size (logical\/physical): 512B\/512B\nPartition Table: msdos\nDisk Flags: \n\nNumber  Start   End     Size    Type     File system  Flags\n 1      1049kB  4295MB  4294MB  primary               raid<\/code><\/pre>\n\n\n\n<p>You can do the same for other disks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create RAID Level 10 (RAID 1+0)<\/h3>\n\n\n\n<p>Once the disks are setup, you can now create RAID level 10 (1+0) on Ubuntu 20.04 using the <code><strong>mdadm<\/strong><\/code> command.<\/p>\n\n\n\n<p>Check if the <strong><code>mdadm<\/code><\/strong> package is installed;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt list -a mdadm<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Listing... Done\nmdadm\/focal-updates,now 4.1-5ubuntu1.2 amd64 &#91;installed,automatic]\nmdadm\/focal 4.1-5ubuntu1 amd64<\/code><\/pre>\n\n\n\n<p>If not installed, you can install it by running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install mdadm<\/code><\/pre>\n\n\n\n<p>The basic command line syntax for&nbsp;<strong><code>mdadm<\/code><\/strong>&nbsp;commad is;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdadm &#91;mode] &lt;raiddevice&gt; &#91;options] &lt;component-devices&gt;<\/code><\/pre>\n\n\n\n<p><strong>[mode]<\/strong>&nbsp;specifies any major mdadm operation mode which can be one of the following;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>Assemble (-A, --assemble)<\/code><\/strong>: assembles the components of a previously created array into an active array.<\/li>\n\n\n\n<li><strong><code>Build (-B, --build)<\/code><\/strong>: Builds an array that doesn\u2019t have per-device metadata (superblocks).<\/li>\n\n\n\n<li><strong><code>Create (-C, --create)<\/code><\/strong>: Creates a new array with per-device metadata (superblocks).<\/li>\n\n\n\n<li><strong><code>Follow\/Monitor (-F, --follow, --monitor)<\/code><\/strong>: Monitor one or more md devices and act on any state changes. This is only meaningful for RAID1, 4, 5, 6, 10 or multipath arrays.<\/li>\n\n\n\n<li><strong><code>Grow (-G, --grow)<\/code><\/strong>: Grow (or shrink) an array, or otherwise reshape it in some way.<\/li>\n\n\n\n<li><code><strong>Incremental Assembly (-I, --incremental)<\/strong><\/code>: Add a single device to an appropriate array.<\/li>\n\n\n\n<li><strong><code>Manage<\/code><\/strong>: This is for doing things to specific components of an array such as adding new spares and removing faulty devices.<\/li>\n\n\n\n<li><strong><code>Misc<\/code><\/strong>: This is an \u2018everything else\u2019 mode that supports operations on active arrays, operations on component devices such as erasing old superblocks, and information gathering operations.<\/li>\n\n\n\n<li><strong>Auto-detect (\u2013auto-detect)<\/strong>: This mode does not act on a specific device or array, but rather it requests the Linux Kernel to activate any auto-detected arrays.<\/li>\n<\/ul>\n\n\n\n<p>To create RAID Level 10 (RAID 1+0), such a command can be used.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mdadm --create \/dev\/md0 --level=10 --raid-devices=4 \/dev\/sd[bcde]1<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdadm: Defaulting to version 1.2 metadata\nmdadm: array \/dev\/md0 started.<\/code><\/pre>\n\n\n\n<p>For information on mdadm options, consult man pages.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Check the status of the RAID<\/h3>\n\n\n\n<p>You can check the status of the created RAID device above using the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mdadm --detail \/dev\/md0<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/dev\/md0:\n           Version : 1.2\n     Creation Time : Tue Jun 15 18:35:00 2021\n        Raid Level : raid10\n        Array Size : 8380416 (7.99 GiB 8.58 GB)\n     Used Dev Size : 4190208 (4.00 GiB 4.29 GB)\n      Raid Devices : 4\n     Total Devices : 4\n       Persistence : Superblock is persistent\n\n       Update Time : Tue Jun 15 18:35:42 2021\n             State : clean \n    Active Devices : 4\n   Working Devices : 4\n    Failed Devices : 0\n     Spare Devices : 0\n\n            Layout : near=2\n        Chunk Size : 512K\n\nConsistency Policy : resync\n\n              Name : ubuntu20:0  (local to host ubuntu20)\n              UUID : 4491a495:a29490e6:3e353c6d:cffac47d\n            Events : 17\n\n    Number   Major   Minor   RaidDevice State\n       0       8       17        0      active sync set-A   \/dev\/sdb1\n       1       8       33        1      active sync set-B   \/dev\/sdc1\n       2       8       49        2      active sync set-A   \/dev\/sdd1\n       3       8       65        3      active sync set-B   \/dev\/sde1<\/code><\/pre>\n\n\n\n<p>To list detailed information about each RAID device;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mdadm --examine \/dev\/sd[bcde]1<\/code><\/pre>\n\n\n\n<p>You can also check the status by running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cat \/proc\/mdstat<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Personalities : &#91;linear] &#91;multipath] &#91;raid0] &#91;raid1] &#91;raid6] &#91;raid5] &#91;raid4] &#91;raid10] \nmd0 : active raid10 sde1&#91;3] sdd1&#91;2] sdc1&#91;1] sdb1&#91;0]\n      8380416 blocks super 1.2 512K chunks 2 near-copies &#91;4\/4] &#91;UUUU]\n      \nunused devices: &lt;none&gt;<\/code><\/pre>\n\n\n\n<p>From the output above;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>Personalities<\/code><\/strong>&nbsp;line shows the RAID level the kernel currently supports.<\/li>\n\n\n\n<li>md device line shows the state of the array, the current raid level set on the device and the devices used in the array.<\/li>\n\n\n\n<li>The other line indicates the usable size of the array in blocks<\/li>\n\n\n\n<li>[n\/m] e.g [4\/4] &nbsp;shows that the array would have n devices however, currently, m devices are in use. When m &gt;= n then things are good. U means up, UUUU means all four devices are used on the array and all are up.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Create a Filesystem on RAID 10 Device<\/h3>\n\n\n\n<p>Once you have created a RAID 10 device, you need to create a filesystem on it to make it useable.<\/p>\n\n\n\n<p>We used four disks each having 4G. Instead of getting 16G in total, RAID 10 cuts the size by half and hence, 8G will be available for use.<\/p>\n\n\n\n<p>The data is mirrored and striped across the disks in the array.<\/p>\n\n\n\n<p>To create a filesystem on RAID 10 device. The command below creates an EXT4 filesystem.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mkfs.ext4 \/dev\/md0<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Mounting RAID 10 Device<\/h3>\n\n\n\n<p>You can now mount your RAID 10 device to start using it<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mount \/dev\/md0 \/mnt<\/code><\/pre>\n\n\n\n<p>To confirm the mounting;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>df -hT -P \/mnt\/<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Filesystem     Type  Size  Used Avail Use% Mounted on\n\/dev\/md0       ext4  7.9G   36M  7.4G   1% \/mnt<\/code><\/pre>\n\n\n\n<p>To automount the device on boot, update&nbsp;<strong><code>\/etc\/fstab<\/code><\/strong>&nbsp;file by adding the line similar to the below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/dev\/md0 \/mnt ext4 defaults 0 0<\/code><\/pre>\n\n\n\n<p>Also, you need to update the&nbsp;<strong><code>\/etc\/mdadm\/mdadm.conf<\/code><\/strong>&nbsp;by creating a prototype config file that describes currently active arrays that are known to be made from partitions of IDE or SCSI drives using the&nbsp;<code><strong>mdadm --detail --scan<\/strong><\/code>&nbsp;command<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mdadm --detail --scan<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ARRAY \/dev\/md0 metadata=1.2 name=ubuntu20:0 UUID=244a7fd9:d6fcc210:9b559249:df999270<\/code><\/pre>\n\n\n\n<p>To write the information to&nbsp;<strong><code>mdadm.conf<\/code><\/strong>, then run;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mdadm --detail --scan &gt;&gt; \/etc\/mdadm\/mdadm.conf<\/code><\/pre>\n\n\n\n<p>Once you update the&nbsp;<code><strong>mdadm.conf<\/strong><\/code>, you can then update initramfs.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>update-initramfs -u<\/code><\/pre>\n\n\n\n<p>When done, updating the initramfs, you can reboot the system to confirm if the RAID device can mount automatically.<\/p>\n\n\n\n<p>And that marks the end of our guide on how to create RAID level 10 (1+0) on Ubuntu 20.04.<\/p>\n\n\n\n<p>Consult <code><strong>man<\/strong> <strong>mdadm<\/strong><\/code> for more information on its usage.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Other Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/setup-software-raid-on-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Setup Software RAID on Rocky Linux 8<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/setup-software-raid-on-debian-10\/\" target=\"_blank\" rel=\"noreferrer noopener\">Setup Software RAID on Debian 10<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/easy-way-to-setup-nfs-server-on-ubuntu-20-04\/\" target=\"_blank\" rel=\"noreferrer noopener\">Easy way to Setup NFS Server on Ubuntu 20.04<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Software RAID levels can be managed using mdadm tool on Linux. In this tutorial, you will learn how to create RAID Level 10 (RAID 1+0)<\/p>\n","protected":false},"author":3,"featured_media":9087,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[39,121,3426],"tags":[3681,3658,3684,3686,3683,3682,3687,3685,1200,3688],"class_list":["post-9084","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-storage","category-howtos","category-raid","tag-create-raid-level-10","tag-mdadm","tag-mirroring","tag-raid","tag-raid-10-2","tag-raid-10","tag-setup-raid-10","tag-stripping","tag-ubuntu-20-04","tag-uuuu","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9084"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=9084"}],"version-history":[{"count":3,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9084\/revisions"}],"predecessor-version":[{"id":21795,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9084\/revisions\/21795"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/9087"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=9084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=9084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=9084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}