How to Configure RAID 1 on Oracle Linux 8.6
- 00:42 cat /etc/os-release
- 01:00 yum install mdadm -y
- 01:19 lsblk
- 01:42 fdisk /dev/sdb
- 02:40 fdisk /dev/sdc
- 03:18 mdadm -E /dev/sd[b-c]1
- 03:40 mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sd[b-c]1
- 04:25 mdadm -E /dev/sd[b-c]1
- 05:00 mdadm --detail /dev/md1
- 05:17 mkfs.ext4 /dev/md1
- 05:38 mkdir /mnt/raid1
- 05:50 blkid /dev/md1
- 06:05 vim /etc/fstab
- 07:00 mount -av
- 07:14 df -h
To Configure RAID 1 on Oracle Linux 8.6
Introduction:
RAID 1 consists of an exact copy (or mirror) of a set of data on two or more disks; a classic RAID 1 mirrored pair contains two disks. With a RAID 1 disk volume, information is written to the first drive and then to a second (or "mirror") drive at the same time. If one of the hard drives in the mirror volume fails, the remaining hard drive can be placed in service as a single drive with no loss of information.
Advantage:
RAID 1 has the advantage of providing improved read speeds and additional protection of the hard disks.
Disadvantage:
Uses only half of the storage capacity.
More expensive (needs twice as many drivers).
Requires powering down your computer to replace failed drive.
Installation Steps:
Step 1: Check the Oracle Linux version by using the below command.
[root@linuxhelp linuxhelp]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="8.6"
ID="ol"
Step 2: Install the mdadm package which is a RAID managing tool.
[root@linuxhelp linuxhelp]# yum install mdadm -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.myfahim.com
* extras: centos.myfahim.com
* updates: mirror.ehost.v
Verifying : mdadm-4.2-2.el8.x86_64 2/2
Updated:
mdadm-4.2-2.el8.x86_64
Complete
Step 3: check if the device is available to configure RAID by running the lsblk command.
[root@linuxhelp 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
├─ol-root 252:0 0 17G 0 lvm /
└─ol-swap 252:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 10G 0 disk
sdc 8:32 0 10G 0 disk
sr0 11:0 1 1024M 0 rom
Step 4: Create the partition for two disks by executing the below command
[root@linuxhelp linuxhelp]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.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 0x9fbd27d7.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Then choose ‘P‘ for Primary partition.
Select (default p): p
Next select the partition number as 1.
Partition number (1-4, default 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.
Type ‘t‘to choose the partitions.
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): l
Choose ‘fd‘ for Linux raid auto and press Enter to apply.
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.
Next press ‘p‘ to print the defined partition.
Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
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: 0x9fbd27d7
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 10487807 10485760 5G fd Linux raid autodetect
Use ‘w‘ to write the changes.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Repeat the above mentioned steps to create partition for another block sdc and provide the Hex code for the partition as ' fd' which is the Linux Raid Autodetect assigned to the partition.
Step 5: Next check the block details for any previous configuration that has been made in the disk. Execute the following command to check it. The output shown below states that the disks have no previous RAID partition in the target system.
[root@linuxhelp 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 6: Create the md device and select the RAID levels by using the below command.
[root@linuxhelp linuxhelp]# mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sd[b-c]1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.
Step 7: Verify the status of RAID level by using the below command.
[root@linuxhelp linuxhelp]# mdadm -E /dev/sd[b-c]1
/dev/sdb1:
Raid Level : raid1
Device Role : Active device 0
/dev/sdc1:
Raid Level : raid1
Device Role : Active device 1
Step 8: To verify the md device status, run the below command.
[root@linuxhelp linuxhelp]# mdadm --detail /dev/md0
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
Step 9: Next create a filesystem for md device by executing the mkfs command followed by the type of filesystem.
[root@linuxhelp linuxhelp]# mkfs.ext4 /dev/md1
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 1309440 4k blocks and 327680 inodes
Filesystem UUID: e6feb0e3-b5bc-43d7-8b32-f36946efb2db
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 10: Now permanently mount the md device by running the blkid command and copy the UUID number. Now create a fstab file using vim editor and enter the copied UUID number in the file. Save and exit the file.
[root@linuxhelp linuxhelp]# mkdir /mnt/raid1
[root@linuxhelp linuxhelp]# blkid /dev/md1
/dev/md1: UUID=e6feb0e3-b5bc-43d7-8b32-f36946efb2db BLOCK_SIZE="4096" TYPE="ext4"
[root@linuxhelp linuxhelp]# vim /etc/fstab
UUID=e6feb0e3-b5bc-43d7-8b32-f36946efb2db /mnt/raid1 ext4 defaults 0 0
Step 11: The device is mounted successfully and to verify the status of the device, run the following set of commands.
[root@linuxhelp linuxhelp]# mount -av
/ : ignored
/boot : already mounted
none : ignored
mount: /mnt/raid0: can't find UUID=43b2f1de-bebe-412b-bc2a-645e86dfb8c5.
mount: /mnt/raid1 does not contain SELinux labels.
You just mounted an file system that supports labels which does not
contain labels, onto an SELinux box. It is likely that confined
applications will generate AVC messages and not be allowed access to
this file system. For more details see restorecon(8) and mount(8).
/mnt/raid1 : successfully mounted
[root@linuxhelp linuxhelp]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 818M 0 818M 0% /dev
tmpfs 847M 0 847M 0% /dev/shm
tmpfs 847M 9.5M 838M 2% /run
tmpfs 847M 0 847M 0% /sys/fs/cgroup
/dev/mapper/ol-root 17G 5.8G 12G 34% /
/dev/sda1 1014M 323M 692M 32% /boot
tmpfs 170M 20K 170M 1% /run/user/1000
/dev/md1 4.9G 20M 4.6G 1% /mnt/raid1
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to Configure RAID 1 on Oracle Linux 8.6. Your feedback is much welcome.
Comments ( 0 )
No comments available