Date created: Tuesday, September 6, 2011 7:32:13 PM. Last modified: Monday, June 19, 2023 5:33:16 PM

'mdadm' - Notes

Example mdadm.conf for building from config file;

# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#

# by default, scan all partitions (/proc/partitions) for MD superblocks.
# alternatively, specify devices to scan, using wildcards if desired.
DEVICE partitions

# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes

# automatically tag new arrays as belonging to the local system
HOMEHOST 

# instruct the monitoring daemon where to send mail alerts
MAILADDR root

# definitions of existing MD arrays
# commented out for lower entry
# ARRAY /dev/md0 level=raid6 num-devices=7
UUID=dbfdc05b:a8f54568:e368bf24:bd0fce41

# This file was auto-generated on Sat, 10 Jul 2010 22:02:49 +0100
# by mkconf $Id$

# Editied by Bensley to add the array in at start up
ARRAY /dev/md0 level=raid6 num-devices=5 metadata=00.90
UUID=dbfdc05b:a8f54568:e368bf24:bd0fce41

Add mdadm.conf array to fstab:

# Added by bensley for array at start up /dev/md0
/dev/md0        /media/Array    ext3    defaults        0       0

 

Here we can see a failed drive;

root@ubuntu:~# cat /proc/mdstat 

Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 

md0 : active raid6 sde1[7](F) sdc1[4] sdd1[1] sda1[0] sdf1[5] sdg1[2]
          4883799680 blocks level 6, 64k chunk, algorithm 2     [7/5]     [UUU_UU_]      

unused devices: <none>

It can't be removed because its not there;

root@ubuntu:~# dmesg
[ 160.111575] md: md0: recovery done.
[ 160.301399] RAID5 conf printout:
[ 160.301404] --- rd:7 wd:5
[ 160.301409] disk 0, o:1, dev:sda1
[ 160.301414] disk 1, o:1, dev:sdd1
[ 160.301418] disk 2, o:1, dev:sdg1
[ 160.301422] disk 3, o:0, dev:sde1
[ 160.301425] disk 4, o:1, dev:sdc1
[ 160.301429] disk 5, o:1, dev:sdf1
[ 160.330015] RAID5 conf printout:
[ 160.330020] --- rd:7 wd:5
[ 160.330025] disk 0, o:1, dev:sda1
[ 160.330029] disk 1, o:1, dev:sdd1
[ 160.330033] disk 2, o:1, dev:sdg1
[ 160.330037] disk 4, o:1, dev:sdc1
[ 160.330041] disk 5, o:1, dev:sdf1
[ 162.060039] ata9: SATA link down (SStatus 0 SControl 300)
[ 162.060047] ata9.00: link offline, clearing class 1 to NONE
[ 162.060055] ata9: EH complete

root@ubuntu:~# mdadm --manage /dev/md0 --remove /dev/sde1
mdadm: metadata format 00.90 unknown, ignored.
mdadm: cannot find /dev/sde: No such file or direct

root@ubuntu:~# mdadm /dev/md0 -r detached
mdadm: metadata format 00.90 unknown, ignored.
mdadm: hot removed 8:65

root@ubuntu:~# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid6 sdc1[4] sdd1[1] sda1[0] sdf1[5] sdg1[2]
4883799680 blocks level 6, 64k chunk, algorithm 2 [7/5] [UUU_UU_]

unused devices:

 

To mount at start up:

# See the RAID is online
bensley@htpc-ubuntu:~$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid5 sdd1[4] sdc1[1] sde1[2] sdb1[0]
      8790401640 blocks super 1.2 level 5, 4k chunk, algorithm 2 [4/4] [UUUU]
      bitmap: 0/22 pages [0KB], 65536KB chunk

unused devices: <none>

# Use mdadm to list the array details
bensley@htpc-ubuntu:~$ sudo mdadm --examine --scan
[sudo] password for bensley:
ARRAY /dev/md/0 metadata=1.2 UUID=8ea128cd:47130c7a:9fb4a5a5:66750b6b name=htpc-ubuntu:0

# Make sure we have a mount point created
bensley@htpc-ubuntu:~$ ls -l /media/bensley/
total 8
drwxr-xr-x 2 root root 4096 May 20 17:40 9TB-Array
drwxr-xr-x 2 root root 4096 Jul 19 20:04 temp



bensley@htpc-ubuntu:~$ sudo vi /etc/fstab
# Add this line to fstab
# Note that nofail is after auto, so that if the array isn't present at boot time the system won't stall
/dev/md/0 /media/bensley/9TB-Array ext4 rw,auto,nofail,nosuid,nodev,uhelper=udisks2 0 2

# Check
bensley@htpc-ubuntu:~$ sudo mount -a

bensley@htpc-ubuntu:~$ mount
/dev/sda6 on / type ext4 (rw,errors=remount-ro)
/dev/md0 on /media/bensley/9TB-Array type ext4 (rw,auto,nofail,nosuid,nodev,uhelper=udisks2)

bensley@htpc-ubuntu:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda6        54G  6.8G   44G  14% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            1.8G  4.0K  1.8G   1% /dev
tmpfs           364M  1.5M  363M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            1.8G   76K  1.8G   1% /run/shm
none            100M   48K  100M   1% /run/user
/dev/md0        8.2T  2.6T  5.6T  32% /media/bensley/9TB-Array

Previous page: 'jq' Notes
Next page: Music & Media Commands