• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to create, add and remove block devices to the Raid device on Ubuntu 21.04

  • 00:43 lsb_release -a
  • 00:48 apt install mdadm
  • 01:11 fdisk /dev/sdb
  • 02:12 fdisk /dev/sdc
  • 03:08 mdadm -C /dev/md0 -l 1 -n 2 /dev/sd[b-c]1
  • 04:01 mdadm --detail /dev/md0
  • 04:25 mkfs.ext4 /dev/md0
  • 04:44 mkdir /raid1
  • 04:54 mount /dev/md0 /raid1
  • 05:04 vi /raid1/test
  • 05:25 vi /etc/fstab
  • 06:23 mount -a
  • 06:35 mdadm -f /dev/md0 /dev/sdc1
  • 06:51 mdadm --remove /dev/md0 /dev/sdc1
  • 07:05 mdadm --detail /dev/md0
  • 07:23 cat /raid1/test
6791

To Create, add and remove block devices to the Raid device on Ubuntu 21.04

Introduction:

The RAID device is a virtual device created from two or more real block devices that allows multiple devices to be combined into one and hold a single file system. A Linux Software RAID device is implemented using the MD device driver (Multiple Devices).

Step 1: Check the installed OS version by using the following command

root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 21.04
Release:	21.04
Codename:	hirsute

Step 2: Install mdadm package by using the following command

root@linuxhelp:~# apt install mdadm
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libllvm11 net-tools
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  finalrd
Suggested packages:
  default-mta | mail-transport-agent dracut-core
The following NEW packages will be installed:
  finalrd mdadm
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 430 kB of archives.
After this operation, 1,299 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu hirsute/main amd64 finalrd all 7 [6,860 B]
Get:2 http://in.archive.ubuntu.com/ubuntu hirsute/main amd64 mdadm amd64 4.1-10ubuntu3 [423 kB]
Fetched 430 kB in 1s (833 kB/s)
Preconfiguring packages ...
Selecting previously unselected package finalrd.
(Reading database ... 209649 files and directories currently installed.)
Preparing to unpack .../apt/archives/finalrd_7_all.deb ...
Unpacking finalrd (7) ...
Selecting previously unselected package mdadm.
Preparing to unpack .../mdadm_4.1-10ubuntu3_amd64.deb ...
Unpacking mdadm (4.1-10ubuntu3) ...
Setting up finalrd (7) ...
Created symlink /etc/systemd/system/sysinit.target.wants/finalrd.service → /lib/systemd/system/finalrd.service.
Setting up mdadm (4.1-10ubuntu3) ...
Generating mdadm.conf... done.
update-initramfs: deferring update (trigger activated)
Sourcing file `/etc/default/grub'
Created symlink /etc/systemd/system/mdmonitor.service.wants/mdcheck_continue.timer → /lib/systemd/system/mdcheck_continu
e.timer.
Created symlink /etc/systemd/system/mdmonitor.service.wants/mdcheck_start.timer → /lib/systemd/system/mdcheck_start.time
r.
Created symlink /etc/systemd/system/mdmonitor.service.wants/mdmonitor-oneshot.timer → /lib/systemd/system/mdmonitor-ones
hot.timer.
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for initramfs-tools (0.139ubuntu3) ...
update-initramfs: Generating /boot/initrd.img-5.11.0-40-generic

Step 3: Open fdisk to create partions on /dev/sdb disk

root@linuxhelp:~# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xec47ae17.



Creating New Partition

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.

Using default partition number and using entire disk space partition by pressing enter for all
Partition number (1-4, default 1): 
First sector (2048-41943039, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943039, default 41943039): 

Created a new partition 1 of type 'Linux' and of size 20 GiB.


Changing the partition type to Linux raid autodetect 
Command (m for help): t

Selected partition 1
Hex code or alias (type L to list all): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.



Saving the all changes made to the disks
Command (m for help): w

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Step 4: Open fdisk to create partions on /dev/sdc disk

root@linuxhelp:~# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xa183b98d.

Creating New Partition
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.


Using default partition number and using entire disk space partition by pressing enter for all
Partition number (1-4, default 1): 
First sector (2048-41943039, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943039, default 41943039): 

Created a new partition 1 of type 'Linux' and of size 20 GiB.




Change the partition type to Linux LVM 
Command (m for help): t

Selected partition 1
Hex code or alias (type L to list all): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.


Save the all changes made to the disks
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Step 5: Create Raid device in Raid level 1 with two block devices

root@linuxhelp:~# mdadm -C /dev/md0 -l 1 -n 2 /dev/sd[b-c]1
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
Continue creating array? 
Continue creating array? (y/n) y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

Step 6: View the details of Raid device

root@linuxhelp:~# mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Mon Nov 29 19:19:08 2021
        Raid Level : raid1
        Array Size : 20953088 (19.98 GiB 21.46 GB)
     Used Dev Size : 20953088 (19.98 GiB 21.46 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

       Update Time : Mon Nov 29 19:19:27 2021
             State : clean, resyncing 
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : resync

     Resync Status : 20% complete

              Name : linuxhelp:0  (local to host linuxhelp)
              UUID : f925a91a:86f15757:d4721be4:5f6ccd45
            Events : 3

    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       1       8       33        1      active sync   /dev/sdc1

Step 7: Format Raid partition to ext4 file system

root@linuxhelp:~# mkfs.ext4 /dev/md0
mke2fs 1.45.7 (28-Jan-2021)
Creating filesystem with 5238272 4k blocks and 1310720 inodes
Filesystem UUID: 34ab81ad-6dd4-40fc-aba5-9c93acc37cb9
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

Step 8: Create directory to mount Raid partition

root@linuxhelp:~# mkdir /raid1

Step 9: Mount Raid partition on /raid1 directory

root@linuxhelp:~# mount /dev/md0 /raid1

Step 10: Create a file in Raid partition

root@linuxhelp:~# vi /raid1/test

Linuxhelp.com

Step 11: Make fstab entry for Raid partition

root@linuxhelp:~# vi /etc/fstab
/dev/md0                /raid1              ext4    defaults        0 0

Step 12: Make partition permanent

root@linuxhelp:~# mount -a

Step 13: Make one block device fault out of two then only able to remove it

root@linuxhelp:~# mdadm -f /dev/md0 /dev/sdc1
mdadm: set /dev/sdc1 faulty in /dev/md0

Step 14: Remove one block device out of two

root@linuxhelp:~# mdadm --remove /dev/md0 /dev/sdc1
mdadm: hot removed /dev/sdc1 from /dev/md0

Step 15: View the devices details

root@linuxhelp:~# mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Mon Nov 29 19:19:08 2021
        Raid Level : raid1
        Array Size : 20953088 (19.98 GiB 21.46 GB)
     Used Dev Size : 20953088 (19.98 GiB 21.46 GB)
      Raid Devices : 2
     Total Devices : 1
       Persistence : Superblock is persistent

       Update Time : Mon Nov 29 19:23:18 2021
             State : clean, degraded 
    Active Devices : 1
   Working Devices : 1
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : resync

              Name : linuxhelp:0  (local to host linuxhelp)
              UUID : f925a91a:86f15757:d4721be4:5f6ccd45
            Events : 28

    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       -       0        0        1      removed

Step 16: View the file created before removing one block device

root@linuxhelp:~# cat /raid1/test

Linuxhelp.com

By this to create, add and remove block devices to the Raid device on Ubuntu 21.04 comes to an end

Tags:
shanemichel
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What does RAID mean?

A

RAID means Redundant Array of Independent/Inexpensive Disks

Q

What is Faulty Raid?

A

Faulty is also not true RAID, and it only involves one device.

Q

Name the RAID's that supports Linux?

A

Linux supports LINEAR md devices, RAID0 , RAID1, RAID4, RAID5, RAID6, RAID10, MULTIPATH, FAULTY, and CONTAINER.

Q

How to set levels on creating Raid?

A

Use command "mdadm" with option "-l or --level=" to set Raid level.

Q

How to create a RAID array?

A

To create RAID array use the command "mdadm" with option "-C to create RAID array.

Related Tutorials in How to create, add and remove block devices to the Raid device on Ubuntu 21.04

Related Tutorials in How to create, add and remove block devices to the Raid device on Ubuntu 21.04

How to install Meld tool in Ubuntu
How to install Meld tool in Ubuntu
Feb 25, 2017
How to install Dconf-Editor on Ubuntu 18.04
How to install Dconf-Editor on Ubuntu 18.04
Jul 14, 2018
How to install and update OpenSSL on Ubuntu 16.04
How to install and update OpenSSL on Ubuntu 16.04
Mar 9, 2017
How to install GLib 2.0 on Ubuntu 17.04
How to install GLib 2.0 on Ubuntu 17.04
May 22, 2017
How to Install Android Emulator on Ubuntu 20.4.1
How to Install Android Emulator on Ubuntu 20.4.1
Jul 13, 2021
How To Install AnyDesk on Ubuntu 16.04
How To Install AnyDesk on Ubuntu 16.04
Apr 4, 2018
How to install Genymotion 2.12.1 on Ubuntu 18.04
How to install Genymotion 2.12.1 on Ubuntu 18.04
Jul 9, 2018
How to install Timeshift 18.4 on Ubuntu 18.04
How to install Timeshift 18.4 on Ubuntu 18.04
Jul 6, 2018

Related Forums in How to create, add and remove block devices to the Raid device on Ubuntu 21.04

Related Forums in How to create, add and remove block devices to the Raid device on Ubuntu 21.04

Ubuntu
matthew class=
Failed to enable unit: Refusing to operate on linked unit file sshd.service
Apr 15, 2019
Ubuntu
mason class=
Passwd: You may not view or modify password information for root On Ubuntu 19.04
May 27, 2019
Ubuntu
isaac class=
/etc/apt/sources.list Permission denied
May 18, 2017
Ubuntu
yousuf class=
lsb_release command not working : Debian
Jan 18, 2018
ifconfig command
jackbrookes class=
what is the location of the ifconfig program on your machine?
Jan 4, 2018
Ubuntu
mason class=
"E: Package 'php-mcrypt' has no installation candidate" error on Ubuntu 20.4.1
Mar 15, 2021
NFS
luke class=
clnt_create: RPC: Program not registered
Apr 25, 2017
Apache
isaac class=
How to disable apache welcome page on Ubuntu
Dec 15, 2018

Related News in How to create, add and remove block devices to the Raid device on Ubuntu 21.04

Related News in How to create, add and remove block devices to the Raid device on Ubuntu 21.04

How To Install Mixxx on Ubuntu 16.04
How To Install Mixxx on Ubuntu 16.04
Oct 11, 2017
Ubuntu 17.04 released with greater expectations
Ubuntu 17.04 released with greater expectations
Apr 15, 2017
Ubuntu Core now available on i.MX6 based TS-4900 thanks to Technologic Systems Inc.
Ubuntu Core now available on i.MX6 based TS-4900 thanks to Technologic Systems Inc.
Mar 1, 2017
Ubuntu 17.10 Artful Aardvark Beta 1 is now here. Download Now
Ubuntu 17.10 Artful Aardvark Beta 1 is now here. Download Now
Sep 2, 2017
Ubuntu Unity is no more: One Linux dream has been axed
Ubuntu Unity is no more: One Linux dream has been axed
Apr 7, 2017
What’s next for Ubuntu Linux Desktop?
What’s next for Ubuntu Linux Desktop?
Apr 11, 2017
Say Hi to Ubuntu's new mascot
Say Hi to Ubuntu's new mascot
Mar 22, 2019
KDE Connect App was removed from Google Play Store and brought back in 24 hours
KDE Connect App was removed from Google Play Store and brought back in 24 hours
Mar 22, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Luk Van De Looverbosch ?
How to create a root ?

Hello,
How to create root@linuxhelp in Linux Mint 20.1 64-bit ?
Thanks in advance for your reply.
Best regards.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.