Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to set up software RAID-1 on my Ubuntu system, and found this example of an /etc/raidtab:

raiddev /dev/md0
    raid-level      1
    nr-raid-disks   2
    nr-spare-disks  0
    persistent-superblock 1
    device          /dev/sdb1
    raid-disk       0
    device          /dev/sdc1
    raid-disk       1

I would however like the path to the raid device to be /raid. Is it ok to just use

raiddev /raid

...or does it really have to be named /dev/md0?

share|improve this question
Wow, whatever example you've found is ancient. – derobert Sep 17 '12 at 16:58
Phew, did I dodge a bullet? What's wrong with it? – Magnus Sep 17 '12 at 16:59
Answer written. I hope it leads you in the right direction... – derobert Sep 17 '12 at 17:13
up vote 4 down vote accepted

First off, mdraid is configured with persistent superblocks since, well, a long time ago. Configuration is now typically stored internally by mdadm, inside each partition. The only configuration you normally have in /etc is an /etc/mdadm/mdadm.conf, which looks something like this (with a bunch of comments elided):

# Please refer to mdadm.conf(5) for information about this file.
DEVICE partitions
CREATE owner=root group=disk mode=0660 auto=yes
HOMEHOST <system>

# definitions of existing MD arrays
ARRAY /dev/md0 metadata=0.90 UUID=a1b8efea:2114fd99:28a5f279:815d333e
ARRAY /dev/md/pv0 metadata=1.0 UUID=c840d0de:0626d783:3f1b28dc:c5ec649a name=Zia:pv0

It gives the path (which needs to match what udev thinks, I believe) and some info to identify the array. It doesn't actually say the RAID levels, number of disks, or even which disks (DEVICE partitions means "check all connected disks"). This is actually fairly nice. If you shut down, move all the disks to different ports, and boot back up, it keeps working. Nice when you do that by mistake when replacing a disk. Or when you add in a new controller, causing a renumber. Still works.

When you create a mdraid array, you can specify a metadata version (with -e). If you use 1.x metadata, you can specify a name for the array. By default, udev will create a /dev/mdX (starting with a fairly high number, like 127) and also a /dev/md/NAME. You could change the udev configuration to put these in other places, but devices live in /dev, by a very strong tradition. You could also give them any name you want, its the device number that actually matters to the kernel.

But keep in mind that the device name and the mount point are different. You can mount the filesystem on /dev/md0 to /raid if you'd like, you do that in /etc/fstab. Just like you would with /dev/sda1, or any other partition.

Also, if you set this up in the installer, it should all be taken care of for you. At least the Debian installer does, Ubuntu should too.

share|improve this answer
Oh, ok great, I didn't realize I could mount /dev/md0 to /raid so easily. Am I correct in assuming that I should NOT be using mkraid then, and use mdadm instead because it is more modern? – Magnus Sep 17 '12 at 17:14
Yes. Use mdadm. I'm surprised Ubuntu even includes mkraid. – derobert Sep 17 '12 at 17:15
I'm not sure it does -- I have just been reading tutorials online, but apparently some of them are outdated. – Magnus Sep 17 '12 at 17:16
It looks like people are working on an updated howto at raid.wiki.kernel.org/index.php/Linux_Raid ... but it looks like they're not done yet, unfortunately. If you see anything talking about mkraid, raidtab, raidtools (except as a historical note, or similar), just close it, its hopelessly obsolete. – derobert Sep 17 '12 at 17:20
If you check the mdadm and md manpages, they're reasonably up to date. But unfortunately, they're references, not howtos, and are fairly complicated. Also there is md documentation in the kernel documentation. I wish I had a nice URL to give you of a fully up-to-date, complete howto – derobert Sep 17 '12 at 17:22

The current software RAID tool is mdadm. RAID devices, as most devices, have an entry in /dev usually of the form /dev/md999 (e.g. /dev/md0). Once the device is created, the configuration is normally stored in /etc/mdadm/mdadm.conf so the RAID device will automatically reassembled on boot.

The commands roughly equivalent to the above (plus mounting as /raid) are:

mdadm /dev/md0 --create --raid-devices=2 --level=1 /dev/sdb1 /dev/sdc1
mkfs /dev/md0 # optionally specifying -text3 or -text4
mount /dev/md0 /raid

Note that the partitions used for software RAID devices should be set to 0xDA (non-fs data) unless you have special reason (and the necessary support) to use type 0xFD (auto detect raid).

The lines specifying RAID devices in /etc/mdadm/mdadm.conf can be appended with:

mdadm --examine --scan >> /etc/mdadm/mdadm.conf
share|improve this answer
This really helps! Thank you! – Magnus Sep 17 '12 at 17:24
To quote the mdadm manpage, "In-kernel autodetect is not recommended for new installations. Using mdadm to detect and assemble arrays — possibly in an initrd — is substantially more flexible and should be preferred." So you actually don't want type FD anymore. You want 0xDA. Also, you probably want -e in there to select a 1.x superblock. And also likely -b internal. (New enough mdadm defaults to -e 1.2, but older didn't) – derobert Sep 17 '12 at 17:24
@derobert As you say, -e 1.2 is now the default (as is -b internal) so these are probably unnecessary. I've been using software RAID for a few years, but hadn't picked up the recommendation about partition type 0xDA. Thanks. – StarNamer Sep 18 '12 at 22:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.