User Tools

Site Tools


documentation:mdadm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

documentation:mdadm [2020/02/01 12:35] – external edit 127.0.0.1documentation: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: 
- 
-<code> 
-$ sudo apt install mdadm 
-</code> 
- 
-=====Create RAID1===== 
- 
-Create partitions for each device first (don't format) 
- 
-<code> 
-$ sudo cfdisk /dev/sdX 
-</code> 
- 
-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). 
- 
-<code> 
-$ sudo mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdc1 
-</code> 
- 
-Now that the array is set-up, we can format the drives. 
-This is as easy as formatting the /dev/mdX raid "block device" we created. 
- 
-<code> 
-$ sudo mkfs.ext4 /dev/mdX 
-</code> 
- 
-====Update the configuration file==== 
- 
-By default, most of mdadm.conf is commented out, and it contains just the following: 
- 
-''/etc/mdadm.conf'' 
-<code> 
-DEVICE partitions 
-</code> 
- 
-This directive tells mdadm to examine the devices referenced by /proc/partitions and assemble as many arrays as possible. A more precise approach is to explicitly add the arrays to ''/etc/mdadm.conf'': 
- 
-<code> 
-$ sudo mdadm --detail --scan >> /etc/mdadm/mdadm.conf 
-</code> 
- 
-Once the configuration file has been updated the array can be assembled using mdadm: 
- 
-<code> 
-$ sudo mdadm --assemble --scan 
-</code> 
- 
-In order for the arrays to be detected by the initial root filesystem, the initramfs **needs** to be updated: 
-<code> 
-$ sudo update-initramfs -u 
-</code> 
-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 ''/dev/md127''. 
- 
-====Mounting MD raid in fstab==== 
- 
-Mounting an md array at boot simply requires the /dev/mdX device to be specified, such as: 
- 
-''/etc/fstab'' 
- 
-<code> 
-/dev/md0 /media/drive1 ext4 defaults 0 2 
-/dev/md1 /media/drive2 ext4 defaults 0 2 
-</code> 
- 
-====Checking Status==== 
- 
-You can check the status of any ongoing operations of your md raid anytime. 
- 
-<code> 
-$ cat /proc/mdstat 
-</code> 
- 
-The output may look something like this: 
- 
-<code> 
-Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]  
-    md0 : active raid1 sdd1[0] sde1[1] 1953382464 blocks super 1.2 [2/2] [UU]  
-    [============>........] resync = 63.6% (1242973952/1953382464) 
-    finish=83.5min speed=141708K/sec bitmap: 8/15 pages [32KB], 65536KB chunk  
- 
-    md1 : active raid1 sdb1[0] sdc1[1] 976630464 blocks super 1.2 [2/2] [UU] 
-    [===================>.] resync = 95.3% (930960832/976630464) 
-    finish=8.6min speed=88130K/sec bitmap: 4/8 pages [16KB], 65536KB chunk 
-</code> 
documentation/mdadm.1580560512.txt.gz · Last modified: 2021/06/18 16:36 (external edit)