Mdadm: Difference between revisions

From Leo's Notes
This page was last edited on 1 May 2013, at 23:21.
No edit summary
Line 8: Line 8:


That's it! Create the file system and you're done. Using 4k chunk size.
That's it! Create the file system and you're done. Using 4k chunk size.
To save your settings, run:
# echo "DEVICES /dev/sdb /dev/sdc" > /etc/mdadm.conf
# mdadm --detail --scan >> /etc/mdadm.conf
# cat /etc/mdadm.conf
DEVICES /dev/sdb /dev/sdc
ARRAY /dev/md/0 metadata=1.2 name=data:0 UUID=5f486d36:37899fcb:99ad8485:088bc180




Line 20: Line 28:
You can assemble an array like:
You can assemble an array like:
  mdadm --assemble /dev/md0 /dev/sdb /dev/sdc
  mdadm --assemble /dev/md0 /dev/sdb /dev/sdc
== Issues ==
# mdadm -A /dev/md0 /dev/sdb /dev/sdc
mdadm: cannot open device /dev/sdb: Device or resource busy
mdadm: /dev/sdb has no superblock - assembly aborted
If you forgot to define your mdadm.conf settings and rebooted, mdadm probably tried to do something with one of your disks to create <code>/dev/md127</code>. To free <code>/dev/sdb</code> in the above example, just stop <code>/dev/md127</code> by running:
mdadm --stop /dev/md127
And then retry reassembling the array again.


[[Category:Linux]]
[[Category:Linux]]

Revision as of 23:21, 1 May 2013

Creating a Raid 1 Mirror

mdadm --zero-superblock /dev/sdb
mdadm --zero-superblock /dev/sdc

Create the array:

mdadm --create /dev/md0 --chunk=4 --level=1 --raid-devices=2 /dev/sdb /dev/sdc

That's it! Create the file system and you're done. Using 4k chunk size.

To save your settings, run:

# echo "DEVICES /dev/sdb /dev/sdc" > /etc/mdadm.conf
# mdadm --detail --scan >> /etc/mdadm.conf
# cat /etc/mdadm.conf
DEVICES /dev/sdb /dev/sdc
ARRAY /dev/md/0 metadata=1.2 name=data:0 UUID=5f486d36:37899fcb:99ad8485:088bc180


Disassemble / stop an array

mdadm --stop /dev/md0

Reassemble an array

mdadm --assemble --scan

You can assemble an array like:

mdadm --assemble /dev/md0 /dev/sdb /dev/sdc


Issues

# mdadm -A /dev/md0 /dev/sdb /dev/sdc
mdadm: cannot open device /dev/sdb: Device or resource busy
mdadm: /dev/sdb has no superblock - assembly aborted

If you forgot to define your mdadm.conf settings and rebooted, mdadm probably tried to do something with one of your disks to create /dev/md127. To free /dev/sdb in the above example, just stop /dev/md127 by running:

mdadm --stop /dev/md127

And then retry reassembling the array again.