linux:centos:software-raid1-setup
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:centos:software-raid1-setup [2020/04/13 11:58] – odefta | linux:centos:software-raid1-setup [2025/01/02 18:22] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ====== Intro ====== | ====== Intro ====== | ||
| - | RAID 1 = mirrored pair of two hard disks | + | RAID 1 = mirrored pair of two hard disks \\ |
| - | If one disk fail, the raid will continue to be operational. | + | If one disk fail, the raid will continue to be operational. |
| - | Read performance will be increased for parallel read operations. | + | Read performance will be increased for parallel read operations. |
| - | Write performance will be likely the same (almost the same). | + | Write performance will be likely the same (almost the same). |
| - | ===== Prerequisites ===== | + | ====== Prerequisites |
| * Two hard disks of same size. | * Two hard disks of same size. | ||
| Line 17: | Line 17: | ||
| </ | </ | ||
| - | ===== Setup ===== | + | ====== Setup ====== |
| + | |||
| + | ==== Format first hard disk (/dev/sda) with xfs (supports also hard disks higher than 2TB) ==== | ||
| + | |||
| + | < | ||
| + | mkfs.xfs -f -L DISK1 /dev/sda | ||
| + | </ | ||
| + | |||
| + | -f = force \\ | ||
| + | -L = hdd label | ||
| + | |||
| + | ==== Format second hard disk (/dev/sdb) with xfs ==== | ||
| + | |||
| + | < | ||
| + | mkfs.xfs -f -L DISK2 /dev/sdb | ||
| + | </ | ||
| + | |||
| + | ==== Create the raid array ==== | ||
| + | |||
| + | < | ||
| + | mdadm --verbose --create /dev/md0 --level=raid1 --raid-devices=2 /dev/sda /dev/sdb | ||
| + | </ | ||
| + | |||
| + | ==== Format the raid array as xfs ==== | ||
| + | |||
| + | < | ||
| + | mkfs.xfs /dev/md0 | ||
| + | </ | ||
| + | |||
| + | ==== Mount the raid array (in /data1 folder) ==== | ||
| + | |||
| + | < | ||
| + | mkdir /data1 | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | mount /dev/md0 /data1 | ||
| + | </ | ||
| + | |||
| + | ==== Automatically mount the raid volume at startup ==== | ||
| + | |||
| + | Edit **/ | ||
| + | < | ||
| + | /dev/md0 /data1 xfs defaults 0 0 | ||
| + | </ | ||
| + | |||
| + | ==== Load automatically the raid 1 configuration at startup | ||
| + | |||
| + | < | ||
| + | mdadm --detail --scan --verbose >> / | ||
| + | </ | ||
| + | |||
| + | ==== Check the raid configuration ==== | ||
| + | |||
| + | < | ||
| + | mdadm -D /dev/md0 | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | /dev/md0: | ||
| + | | ||
| + | | ||
| + | Raid Level : raid1 | ||
| + | Array Size : 3906886464 (3725.90 GiB 4000.65 GB) | ||
| + | Used Dev Size : 3906886464 (3725.90 GiB 4000.65 GB) | ||
| + | Raid Devices : 2 | ||
| + | Total Devices : 2 | ||
| + | | ||
| + | |||
| + | | ||
| + | |||
| + | | ||
| + | State : clean, resyncing | ||
| + | Active Devices : 2 | ||
| + | | ||
| + | Failed Devices : 0 | ||
| + | Spare Devices : 0 | ||
| + | |||
| + | Consistency Policy : bitmap | ||
| + | |||
| + | | ||
| + | |||
| + | Name : medjavaro: | ||
| + | UUID : 257d9837: | ||
| + | Events : 15822 | ||
| + | |||
| + | Number | ||
| + | | ||
| + | | ||
| + | |||
| + | </ | ||
| + | ==== Replace a failed hard disk in the raid configuration ==== | ||
| + | |||
| + | Suppose the /dev/sdb hard disk failed. \\ | ||
| + | To replace it with a good hdd, set it as failed and remove it from the array: | ||
| + | < | ||
| + | mdadm /dev/md0 --fail /dev/sdb --remove /dev/sdb | ||
| + | </ | ||
| + | |||
| + | Add the new device to the array: | ||
| + | < | ||
| + | mdadm --add /dev/md0 /dev/sdb | ||
| + | </ | ||
| + | |||
| + | ==== Re-add a good hard disk (after cable disconnection for example) ==== | ||
| + | |||
| + | After reinserting the hard disk, it may be mounted now on a different device letter.\\ Ckeck it by running: | ||
| + | |||
| + | < | ||
| + | fdisk -l | ||
| + | </ | ||
| + | |||
| + | Output: | ||
| + | < | ||
| + | ... | ||
| + | Disk /dev/sdd: 4000.8 GB, 4000787029504 bytes, 7814037167 sectors | ||
| + | Units = sectors of 1 * 512 = 512 bytes | ||
| + | Sector size (logical/ | ||
| + | I/O size (minimum/ | ||
| + | </ | ||
| + | |||
| + | After identifying it, re-add it to the raid array with: | ||
| + | |||
| + | < | ||
| + | mdadm --manage /dev/md0 --add /dev/sdd | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
linux/centos/software-raid1-setup.1586779106.txt.gz · Last modified: (external edit)
