documentation:mdadm
Differences
This shows you the differences between two versions of the page.
| documentation:mdadm [2020/02/01 12:35] – external edit 127.0.0.1 | documentation:mdadm [2020/02/01 13:01] (current) – removed lucid | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ======Setup software RAID1 with mdadm on Ubuntu 16.04====== | ||
| - | This guide will detail how to setup a RAID1 array using MD in Ubuntu 16.04, while also providing a demonstration of how to swap disks in the event of a failure. | ||
| - | |||
| - | =====Installing mdadm===== | ||
| - | |||
| - | First install mdadm: | ||
| - | |||
| - | < | ||
| - | $ sudo apt install mdadm | ||
| - | </ | ||
| - | |||
| - | =====Create RAID1===== | ||
| - | |||
| - | Create partitions for each device first (don't format) | ||
| - | |||
| - | < | ||
| - | $ sudo cfdisk /dev/sdX | ||
| - | </ | ||
| - | |||
| - | Follow the terminal interface to create the relevant partitions on your drives. (you can use any tool for this) | ||
| - | |||
| - | Create a RAID1 array by using the --level=mirror setting, then specify your drives. (It's that simple). | ||
| - | |||
| - | < | ||
| - | $ sudo mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdc1 | ||
| - | </ | ||
| - | |||
| - | Now that the array is set-up, we can format the drives. | ||
| - | This is as easy as formatting the /dev/mdX raid "block device" | ||
| - | |||
| - | < | ||
| - | $ sudo mkfs.ext4 /dev/mdX | ||
| - | </ | ||
| - | |||
| - | ====Update the configuration file==== | ||
| - | |||
| - | By default, most of mdadm.conf is commented out, and it contains just the following: | ||
| - | |||
| - | ''/ | ||
| - | < | ||
| - | DEVICE partitions | ||
| - | </ | ||
| - | |||
| - | This directive tells mdadm to examine the devices referenced by / | ||
| - | |||
| - | < | ||
| - | $ sudo mdadm --detail --scan >> / | ||
| - | </ | ||
| - | |||
| - | Once the configuration file has been updated the array can be assembled using mdadm: | ||
| - | |||
| - | < | ||
| - | $ sudo mdadm --assemble --scan | ||
| - | </ | ||
| - | |||
| - | In order for the arrays to be detected by the initial root filesystem, the initramfs **needs** to be updated: | ||
| - | < | ||
| - | $ sudo update-initramfs -u | ||
| - | </ | ||
| - | If this is note done, the system will hang at boot, if the md devices were added to /etc/fstab, as they will be assigned random device names such as ''/ | ||
| - | |||
| - | ====Mounting MD raid in fstab==== | ||
| - | |||
| - | Mounting an md array at boot simply requires the /dev/mdX device to be specified, such as: | ||
| - | |||
| - | ''/ | ||
| - | |||
| - | < | ||
| - | /dev/md0 / | ||
| - | /dev/md1 / | ||
| - | </ | ||
| - | |||
| - | ====Checking Status==== | ||
| - | |||
| - | You can check the status of any ongoing operations of your md raid anytime. | ||
| - | |||
| - | < | ||
| - | $ cat / | ||
| - | </ | ||
| - | |||
| - | The output may look something like this: | ||
| - | |||
| - | < | ||
| - | Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] | ||
| - | md0 : active raid1 sdd1[0] sde1[1] 1953382464 blocks super 1.2 [2/2] [UU] | ||
| - | [============> | ||
| - | finish=83.5min speed=141708K/ | ||
| - | |||
| - | md1 : active raid1 sdb1[0] sdc1[1] 976630464 blocks super 1.2 [2/2] [UU] | ||
| - | [===================> | ||
| - | finish=8.6min speed=88130K/ | ||
| - | </ | ||
documentation/mdadm.1580560512.txt.gz · Last modified: 2021/06/18 16:36 (external edit)