How to configure RAID-1 on Fedora 34
To Configure RAID-1 on Fedora 34
Introduction:
A RAID array is a data storage virtualization technology that combines multiple physical disks into a unified logical unit to provide redundancy, performance, or both. A subsystem that enables data to be written on two disks or solid-state drives (SSDs) at the same time, thereby increasing safety. Mirroring is not more efficient than raid 1. If one drive fails, the other is used, and the failed drive is replaced manually. This tutorial covers the configuration procedure of raid 1 on fedora 34.
Installation procedure:
Step 1: Check the OS version by using the below command.
[root@linuxhelp ~]# cat /etc/os-release
NAME=Fedora
VERSION="34 (Workstation Edition)"
ID=fedora
VERSION_ID=34
VERSION_CODENAME=""
PLATFORM_ID="platform:f34"
PRETTY_NAME="Fedora 34 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:34"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/34/system-administrators-guide/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
Step 2: To list the disk block use the below command.
[root@linuxhelp ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part /home
sdb 8:16 0 10G 0 disk
sdc 8:32 0 10G 0 disk
sr0 11:0 1 1.9G 0 rom /run/media/linuxhelp/Fedora-WS-Live-34-1-2
z
ram0 252:0 0 4.1G 0 disk [SWAP]
Step 3: Create the partition for sdb disk by using the below command.
[root@linuxhelp ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.36.2).
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 0x4f464c60.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-20971519, default 20971519): +5G
Created a new partition 1 of type 'Linux' and of size 5 GiB.
Command (m for help): t
Selected partition 1
Hex code or alias (type L to list all): l
00 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
01 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
02 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
03 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
04 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
05 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
06 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
07 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
08 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
09 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
0a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
0b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
0c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Linux extended
0e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
0f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto
1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep
1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT
Aliases:
linux - 83
swap - 82
extended - 05
uefi - EF
raid - FD
lvm - 8E
linuxex - 85
Hex code or alias (type L to list all): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.
Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4f464c60
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 10487807 10485760 5G fd Linux raid autodetect
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Step 4: Create the partition for sdc disk by using the below command.
[root@linuxhelp ~]# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.36.2).
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 0x14a5264f.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-20971519, default 20971519): +5G
Created a new partition 1 of type 'Linux' and of size 5 GiB.
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'.
Command (m for help): p
Disk /dev/sdc: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x14a5264f
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 10487807 10485760 5G fd Linux raid autodetect
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Step 5: Install the mdadm package by using the below command.
[root@linuxhelp ~]# dnf install mdadm -y
Fedora Modular 34 - x86_64 5.4 kB/s | 6.4 kB 00:01
Fedora Modular 34 - x86_64 - Updates 8.7 kB/s | 6.1 kB 00:00
Fedora Modular 34 - x86_64 - Updates 52 kB/s | 148 kB 00:02
Fedora 34 - x86_64 - Updates 9.2 kB/s | 6.4 kB 00:00
Fedora 34 - x86_64 - Updates 356 kB/s | 4.7 MB 00:13
Fedora 34 - x86_64 7.8 kB/s | 6.5 kB 00:00
MySQL 8.0 Community Server 40 kB/s | 2.6 kB 00:00
MySQL Connectors Community 227 kB/s | 2.6 kB 00:00
MySQL Tools Community 217 kB/s | 2.6 kB 00:00
determining the fastest mirror (1 hosts).. done. 100% [==================================================] 9.2 kB/s | 3.4 kB 00:00 ETA
Remi's Modular repository - Fedora 34 - x86_64 592 B/s | 858 B 00:01
done.s Modular repository - Fedora 34 - x86_64 100% [==================================================] 11 kB/s | 3.4 kB 00:00 ETA
Remi's Modular repository - Fedora 34 - x86_64 424 kB/s | 503 kB 00:01
Remi's RPM repository - Fedora 34 - x86_64 1.1 kB/s | 858 B 00:00
Remi's RPM repository - Fedora 34 - x86_64 1.9 MB/s | 2.8 MB 00:01
Package mdadm-4.1-7.fc34.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Step 6: Check the RAID configuration details by using the below command.
[root@linuxhelp ~]# mdadm -E /dev/sd[b-c]1
mdadm: No md superblock detected on /dev/sdb1.
mdadm: No md superblock detected on /dev/sdc1.
Step 7: Create RAID-1 configuration by using the below command.
[root@linuxhelp ~]# mdadm --create /dev/md5 --level=mirror --raid-devices=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/md5 started.
Step 8: Check the RAID-1 configuration details by using the below command.
[root@linuxhelp ~]# mdadm -E /dev/sd[b-c]1
/dev/sdb1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 02648e9c:d2cb839b:34f97cfd:2b528d36
Name : linuxhelp:5 (local to host linuxhelp)
Creation Time : Fri Dec 3 01:25:06 2021
Raid Level : raid1
Raid Devices : 2
Avail Dev Size : 10475520 (5.00 GiB 5.36 GB)
Array Size : 5237760 (5.00 GiB 5.36 GB)
Data Offset : 10240 sectors
Super Offset : 8 sectors
Unused Space : before=10160 sectors, after=0 sectors
State : clean
Device UUID : bb47137c:6c3c818f:07e85268:6e377ea4
Update Time : Fri Dec 3 01:25:32 2021
Bad Block Log : 512 entries available at offset 16 sectors
Checksum : d4519c20 - correct
Events : 17
Device Role : Active device 0
Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
/dev/sdc1:
Magic : a92b4efc
Version : 1.2
Feature Map : 0x0
Array UUID : 02648e9c:d2cb839b:34f97cfd:2b528d36
Name : linuxhelp:5 (local to host linuxhelp)
Creation Time : Fri Dec 3 01:25:06 2021
Raid Level : raid1
Raid Devices : 2
Avail Dev Size : 10475520 (5.00 GiB 5.36 GB)
Array Size : 5237760 (5.00 GiB 5.36 GB)
Data Offset : 10240 sectors
Super Offset : 8 sectors
Unused Space : before=10160 sectors, after=0 sectors
State : clean
Device UUID : 40710e41:21c31a86:01f0545a:e33a8b4d
Update Time : Fri Dec 3 01:25:32 2021
Bad Block Log : 512 entries available at offset 16 sectors
Checksum : 2af557ca - correct
Events : 17
Device Role : Active device 1
Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
Step 9: Check the RAID configuration details by using the below command.
[root@linuxhelp ~]# cat /proc/mdstat
Personalities : [raid1]
md5 : active raid1 sdc1[1] sdb1[0]
5237760 blocks super 1.2 [2/2] [UU]
unused devices: <none>
Step 10: Check the RAID configuration details by using the below command
[root@linuxhelp ~]# mdadm --detail /dev/md5
/dev/md5:
Version : 1.2
Creation Time : Fri Dec 3 01:25:06 2021
Raid Level : raid1
Array Size : 5237760 (5.00 GiB 5.36 GB)
Used Dev Size : 5237760 (5.00 GiB 5.36 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Fri Dec 3 01:25:32 2021
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Consistency Policy : resync
Name : linuxhelp:5 (local to host linuxhelp)
UUID : 02648e9c:d2cb839b:34f97cfd:2b528d36
Events : 17
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
Step 11: Make the directory for mounting point by using the below command.
[root@linuxhelp ~]# mkdir /mnt/raid1
Step 12: Make the file system for the directory by using the below command.
[root@linuxhelp ~]# mkfs.ext4 /dev/md5
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 1309440 4k blocks and 327680 inodes
Filesystem UUID: 0712b78c-e44e-4d1a-9cff-96faa7fbf774
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
Step 13: Check the blkid details by using the below command.
[root@linuxhelp ~]# blkid /dev/md5
/dev/md5: UUID="0712b78c-e44e-4d1a-9cff-96faa7fbf774" BLOCK_SIZE="4096" TYPE="ext4"
Step 14: Open the fstab configuration file by using the below command.
[root@linuxhelp ~]# vim /etc/fstab
Step 15: To mount .
[root@linuxhelp ~]# mount -a
Step 16: Check the disk details by using the below commands.
[root@linuxhelp ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 2.1G 0 2.1G 0% /dev
tmpfs 2.1G 0 2.1G 0% /dev/shm
tmpfs 835M 1.9M 833M 1% /run
/dev/sda2 19G 4.6G 15G 25% /
/dev/sda2 19G 4.6G 15G 25% /home
/dev/sda1 976M 166M 743M 19% /boot
tmpfs 2.1G 16K 2.1G 1% /tmp
tmpfs 418M 112K 418M 1% /run/user/1000
/dev/sr0 1.9G 1.9G 0 100% /run/media/linuxhelp/Fedora-WS-Live-34-1-2
/dev/md5 4.9G 20M 4.6G 1% /mnt/raid1
Step 17: Change the directory and list the files by using the below command.
[root@linuxhelp ~]# cd /mnt/raid1/
[root@linuxhelp raid1]# ls -l
total 16
drwx------ 2 root root 16384 Dec 3 01:28 lost+found
Step 18: Create the new file and directory then list the files by using the below command.
[root@linuxhelp raid1]# cat >> test
this is the test file
[root@linuxhelp raid1]# mkdir raid1
[root@linuxhelp raid1]# ls -l
total 24
drwx------ 2 root root 16384 Dec 3 01:28 lost+found
drwxr-xr-x 2 root root 4096 Dec 3 01:37 raid1
-rw-r--r-- 1 root root 22 Dec 3 01:36 test
Step 19: Check the disk block by using the below command.
[root@linuxhelp raid1]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part /home
sdb 8:16 0 10G 0 disk
└─sdb1 8:17 0 5G 0 part
└─md5 9:5 0 5G 0 raid1 /mnt/raid1
sdc 8:32 0 10G 0 disk
└─sdc1 8:33 0 5G 0 part
└─md5 9:5 0 5G 0 raid1 /mnt/raid1
sr0 11:0 1 1.9G 0 rom /run/media/linuxhelp/Fedora-WS-Live-34-1-2
zram0 252:0 0 4.1G 0 disk [SWAP]
Step 20: Check the disk details by using the below command.
[root@linuxhelp raid1]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 2.1G 0 2.1G 0% /dev
tmpfs 2.1G 0 2.1G 0% /dev/shm
tmpfs 835M 1.9M 833M 1% /run
/dev/sda2 19G 4.6G 15G 24% /
/dev/sda2 19G 4.6G 15G 24% /home
/dev/sda1 976M 166M 743M 19% /boot
tmpfs 2.1G 16K 2.1G 1% /tmp
tmpfs 418M 112K 418M 1% /run/user/1000
/dev/sr0 1.9G 1.9G 0 100% /run/media/linuxhelp/Fedora-WS-Live-34-1-2
/dev/md5 4.9G 20M 4.6G 1% /mnt/raid1
card or as a part of the motherboard) that provides for the mirroring of data across the hard drives in the volume.
service as a single drive with no loss of information. Similar to a RAID 0 (striped) volume, RAID 1 volumes require a minimum of two (2) drives.