Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Create RAID 1 (mirroring) with two disks     - Android application simulates the phone keypad (Programming)

- Cryptography development environment to build under Ubuntu (Linux)

- To compile and install Clang 3.5.0 in Linux CentOS (Linux)

- Linux Workstation Security Checklist - from the Linux Foundation Internal (Linux)

- When the master key encounter NULL (Database)

- Java proxy use and proxy principle (Programming)

- linux smartd [FAILED] appears at startup (Linux)

- Install Mac OS X 10.9 systems VMware10 (Linux)

- MySQL5.7 JSON type using presentation (Database)

- Linux gprof oprofiling and performance testing tools (Linux)

- Simple Linux file system - df, du, ln (Linux)

- Syncthing: Private Security Synchronization tool to synchronize files between computers / folder (Linux)

- Using Maven to download Spring (Linux)

- Ubuntu under VirtualBox virtual machine serial port settings (Linux)

- How to set cache valid time in Apache (Server)

- Linux System Getting Started Learning: Repair fatal error openssl aes h no such file or directory (Linux)

- Linux environment variable configuration and save places (Linux)

- Hadoop scheduling availability of workflow platform - Oozie (Server)

- Ubuntu install snmp packets Unlinked OID in IPATM-IPMC-MIB: marsMIB (Linux)

- CentOS system dual network card IP information configuration (Linux)

  Create RAID 1 (mirroring) with two disks
  Add Date : 2018-11-21      
  Full clone RAID mirroring means that the same data (or mirror), respectively written to two disks. Create RAID 1 requires at least two disks, but only for reading the performance or reliability of data storage capacity is more important than the occasion.

Settings in Linux RAID 1

Create a mirror in order to prevent loss of data due to hard disk failure. Mirror each disk contains a complete copy of the data. When a disk fails, the same data can be read from other normal disk. Then, you can replace the failed disk from a computer that is running directly, without any interruption.

RAID 1 Features

Mirror has a good performance.

Disk utilization is 50%. That is, if we have two disks each 500GB, a total of 1TB, but it will only show in the mirror 500GB.

In the mirror if one disk fails no data is lost, because the same two disks content.

Read performance will be better than write performance.


Create RAID 1 at least two disks, you can also add more disks, disk number 2,4,6,8, etc. need to be even. To add more disks, you must have a RAID system physical adapter (hardware card).

Here, we use software RAID than hardware RAID, if your system has a built-in physical hardware RAID card, you can get from its functional interface or use Ctrl + I key to access it.

In my server installation

Operating System: CentOS6.5Final
IP Address:
Host Name: rd1.tecmintlocal.com
Disk 1 [20GB]: / dev / sdb
Disk 2 [20GB]: / dev / sdc
This article will guide you to use mdadm on the Linux platform (used to create and manage RAID) step by step to create a software RAID 1 (mirroring). The same also applies to such as RedHat, CentOS, Fedora and other Linux distributions.


Step 1: Install the required software and check disk

1, as I said earlier, we need to use in Linux mdadm software to create and manage RAID. So, let's install mdadm package with yum or apt-get package management tool on Linux.

# Yum install mdadm [in RedHat System]
# Apt-get install mdadm [in Debain system]
2. Once installed mdadm package, we need to use the following command to check whether the disk is configured.

# Mdadm -E / dev / sd [b-c]

Check the RAID disk

As you can see from the picture above, we did not detect any super block, which means that has not been created RAID.


Step 2: Create a partition for RAID

3, as I mentioned, we use a minimum of two partitions / dev / sdb and / dev / sdc to create RAID 1. We first use the fdisk command to create two partitions and change the type of raid.

# Fdisk / dev / sdb
Follow the instructions below

Create a new partition by n.
Then press P to select a primary partition.
Next, select the partition number 1.
Press Enter twice to assign the entire capacity of the default to it.
Then, press P to print the created partition.
Press L, lists all the available types.
Press t modify partition type.
Type fd is set to Linux RAID type, and then press Enter to confirm.
Then use p again see our changes.
Use w to save your changes.

Create Partition

After you create the "/ dev / sdb" partitions, then create a partition / dev / sdc in the same way.

# Fdisk / dev / sdc

Create a second partition

4, once the two partitions created, use the same command to check sdb and sdc partition and confirm the type of RAID partition

# Mdadm -E / dev / sd [b-c]

Verify zoning changes

Check the RAID type

Note: As you can see on the chart, there is no definition of RAID and in sdb1 sdc1, which is what we did not detect the superblock causes.

Step 3: Create a RAID 1 device

5, then use the following command to create a file called / dev / md0 is "RAID 1" device and verify that it

# Mdadm --create / dev / md0 --level = mirror --raid-devices = 2 / dev / sd [b-c] 1
# Cat / proc / mdstat

Create a RAID device

6, then use the following command to check the RAID device type and RAID arrays

# Mdadm -E / dev / sd [b-c] 1
# Mdadm --detail / dev / md0

Checking the RAID device type

Check the RAID array of devices

From the figure above, it is easy to understand, RAID 1 has been created, use the / dev / sdb1 and / dev / sdc1 partition, you can also see the status of resyncing (resynchronization).

Step 4: Create a file system on the RAID device

7, to create the md0 ext4 file system

# Mkfs.ext4 / dev / md0

Create a RAID device file system

8. Next, mount the newly created file system to the "/ mnt / raid1", and create some documents, validate data mount point

# Mkdir / mnt / raid1
# Mount / dev / md0 / mnt / raid1 /
# Touch /mnt/raid1/tecmint.txt
# Echo "tecmint raid setups"> /mnt/raid1/tecmint.txt

Mount RAID device

9, in order to restart the system to automatically mount RAID 1, you need to add an entry in the fstab file. Open the / etc / fstab file and add the following line:

/ Dev / md0 / mnt / raid1 ext4 defaults 00

Raid devices automatically mount

10, run mount -av, check whether there is an entry in fstab error

# Mount -av

Check the fstab errors

11 Next, use the following command to save the RAID configuration to a file "mdadm.conf" in.

# Mdadm --detail --scan --verbose >> /etc/mdadm.conf

Save Raid configuration

Above configuration file at system reboot will read and load the RAID device.

Step 5: Check the data after a disk failure

12, our main goal is, even when any disk failure or crash must guarantee that data is available. Let's see, when any one disk is unavailable when what happens.

# Mdadm --detail / dev / md0

Verify RAID device

In the picture above, we can see that there are two devices are available in RAID, and Active Devices is 2. Now let us see if a disk pulled (remove sdc disk) or damaged what happens.

# Ls -l / dev | grep sd
# Mdadm --detail / dev / md0

Test RAID devices

Now, in the picture above you can see that a disk was gone. I removed a disk from a virtual machine. At this point let's examine our precious data.

# Cd / mnt / raid1 /
# Cat tecmint.txt

RAID data validation

You can see that our data is still available. Thus, we can understand RAID 1 (mirroring) advantage. In the next article, we will see how to set up a RAID 5 striping with distributed parity. Hope this helps you understand RAID 1 (mirroring) is how it works.
- IOwait Linux system monitoring diagnostic tools (Linux)
- Linux System Getting Started Tutorial: How do you know Shell which is currently being used (Linux)
- Linux Security and Optimization (Linux)
- Install Linux Mint 17: 20 things to do (Linux)
- How to become a better Node.js developers in 2016 (Programming)
- Row-level security and application-level solutions for the new features of PostgreSQL9.5 (Database)
- C ++ 11 feature: decltype keywords (Programming)
- Java garbage collection (Programming)
- Open source backup software installed on Ubuntu Systemback 1.6.201 (Linux)
- Two classic macro definition under Linux (Linux)
- Debian installation (Linux)
- Ubuntu 15.10 15.04 14.10 14.04 Install Ubuntu Tweak (Linux)
- Wireshark basic introduction and learning TCP three-way handshake (Linux)
- CentOS 6.6 install Oracle 11gR2 database (Database)
- Parameters of the extra port MySQL 5.6 (Database)
- Java implementation file encryption and decryption (Programming)
- Java Builder mode (Programming)
- Linux iptables firewall settings whitelist (RHEL 6 and CentOS 7) (Linux)
- Android Studio utility plug organize, create sharp artifact (Programming)
- Java Foundation - Variables and data types (Programming)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.