{"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

Software RAID levels can be managed using 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 mdadm<\/strong><\/code> utility. There are different levels of RAID configurations ranging from 0-9. Some levels, such as RAID level 1 (mirroring<\/code><\/strong>) and RAID level 0 (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

In our previous guide, we learnt how to create and setup RAID level 1.<\/p>\n\n\n\n

Setup Software RAID on Ubuntu 20.04<\/a><\/p>\n\n\n\n

Creating RAID Level 10 on Ubuntu 20.04<\/h2>\n\n\n\n

Attach Physical Drives to your Machine<\/h3>\n\n\n\n

RAID level 10 (1+0), requires at least four drives.<\/p>\n\n\n\n

We already have physical drives attached to our system,\/dev\/sd[b-e]<\/strong>, all with 4G<\/strong> storage size.<\/p>\n\n\n\n

lsblk<\/code><\/pre>\n\n\n\n
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

Creating RAID Partitions<\/h3>\n\n\n\n

Partition and initialize the disks attached above as RAID partitions.<\/p>\n\n\n\n

for i in {b..e}; do parted -a optimal \/dev\/sd$i mklabel msdos; done<\/code><\/pre>\n\n\n\n
for i in {b..e}; do parted -a optimal \/dev\/sd$i mkpart primary ext4 0% 100%; done<\/code><\/pre>\n\n\n\n
for i in {b..e}; do parted -a optimal \/dev\/sd$i set 1 raid on; done<\/code><\/pre>\n\n\n\n

Checking the partition tables for the disk;<\/p>\n\n\n\n

parted -a optimal \/dev\/sdb print<\/code><\/pre>\n\n\n\n
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

You can do the same for other disks.<\/p>\n\n\n\n

Create RAID Level 10 (RAID 1+0)<\/h3>\n\n\n\n

Once the disks are setup, you can now create RAID level 10 (1+0) on Ubuntu 20.04 using the mdadm<\/strong><\/code> command.<\/p>\n\n\n\n

Check if the mdadm<\/code><\/strong> package is installed;<\/p>\n\n\n\n

apt list -a mdadm<\/code><\/pre>\n\n\n\n
Listing... Done\nmdadm\/focal-updates,now 4.1-5ubuntu1.2 amd64 [installed,automatic]\nmdadm\/focal 4.1-5ubuntu1 amd64<\/code><\/pre>\n\n\n\n

If not installed, you can install it by running the command below;<\/p>\n\n\n\n

apt install mdadm<\/code><\/pre>\n\n\n\n

The basic command line syntax for mdadm<\/code><\/strong> commad is;<\/p>\n\n\n\n

mdadm [mode] <raiddevice> [options] <component-devices><\/code><\/pre>\n\n\n\n

[mode]<\/strong> specifies any major mdadm operation mode which can be one of the following;<\/p>\n\n\n\n