I have an existing Ubuntu 10.04 desktop system setup and running on a hard drive (drive A).

I'd like to add two more hard drives (drives B and C, same size) to the system and mount them as a RAID 1 array.

How do I do that?

I know how to create RAID arrays during the installation, but I don't want to reinstall my system, and I shouldn't have to since my system files will stay on their own drive separate from the RAID array.

I've physically added both drives to the system, and formatted them as EXT3 with gparted.

Ubuntu's disk utility has a "create raid" option, but it won't let me select any of my drives (it thinks they're all full).

I don't mind using mdadm, but I've found several guides that are old, and give conflicting advice. Some say I have to edit an /etc/raidtab file, some say this is done automatically.

What's the current (Ubuntu 10.04) preferred way of adding a RAID 1 to an existing system?

It should turn into a raid at boot, and mount itself in /home/myname/files/.

Extra Info:


DEVICE partitions
ARRAY /dev/md0 level=raid1 num-devices=2 metadata=00.90 UUID=4fd3b193:c6c09dea:46ed9f91:db68f1c3


/dev/md0 /home/myname/files auto defaults 0 0

cat /proc/mdstat (after reboot)

Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
md_d0 : inactive sdb1[1](S)
      1953511936 blocks

unused devices: <none>
  • I'm having the same problems. I have just edited the /etc/mdadm.conf as specified. Had to edit it manually, as I couldn't get the echos to work, even with sudo, permission denied. I got the file built this time, but I'm suspecting I'm still going to have problems. Why the chown, and who should the owner be?
    – user65588
    Feb 1 '11 at 7:53


All the command line stuff - assuming the new drives are /dev/sdb and /dev/sdc - check and make a note of the drives you want to work on. Double check this - you don't want to do anything with your OS disk!!!

All done as root (sudo -i) ...

1) Use fdisk to delete the new partitions as we need them setup differently - for each drive:

 fdisk /dev/sdx (eg: fdisk /dev/sdb)
  • d (delete) the current partition - follow the prompts
  • n (new partition) and create a primary partition the full size of the drive
  • t (type) and set the partition type to fd (linux raid autodetect)
  • w (write) your changes and exit

fdisk help here: http://tldp.org/HOWTO/Partition/fdisk_partitioning.html

2) Create your new RAID array - we'll assume /dev/md0 (the first RAID array)

  mdadm --create /dev/md0 --chunk=128 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1 

3) Format your new array:

  mkfs -t ext3 /dev/md0    

(or use ext4 if you want)

4) You need to create /etc/mdadm/mdadm.conf or your array disappears when you restart the server!

echo "DEVICE partitions" > /etc/mdadm/mdadm.conf
mdadm --detail --scan >> /etc/mdadm/mdadm.conf 

Once you have created this file, view/edit it to make sure that the 'DEVICE partitions' wording is on a line of its own. If the array doesn't start up automatically on reboot, see the more comprehensive .conf file at the end of this answer.

5) Make sure the mount target folder exists:

mkdir /home/myname/files/

6) Add mount to /etc/fstab - add this line at the end

/dev/md0  /home/myname/files  auto   defaults  0 0

You can check that your new RAID array is running and doing its first time sync with this command:

cat /proc/mdstat


Further to the array disappearing on reboot - try the following madam.conf, which includes the line you posted for your array:

# 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 <system>

# instruct the monitoring daemon where to send mail alerts

# definitions of existing MD arrays
ARRAY /dev/md0 level=raid1 num-devices=2 metadata=00.90 UUID=4fd3b193:c6c09dea:46ed9f91:db68f1c3
  • Awesome, thank you! It's currently re-syncing and when it's done I'll reboot and make sure its all working right. Isn't there a command that makes "cat /proc/mdstat" refresh every 10 seconds or so?
    – Nick
    Jan 8 '11 at 5:19
  • Oh, got it! "watch cat /proc/mdstat". Now I can watch paint dry. :)
    – Nick
    Jan 8 '11 at 5:24
  • Glad its working. You can speed up the sync operation: echo 100000 >/proc/sys/dev/raid/speed_limit_min and then echo 200000 >/proc/sys/dev/raid/speed_limit_max. This will max-out the sync speed at the expense of everything else running on the system
    – Linker3000
    Jan 8 '11 at 10:44
  • Sure, now you tell me after letting it run for 7 hours. :) 82 minutes to go!
    – Nick
    Jan 8 '11 at 11:32
  • OK, something still not quite right. It finished syncing and I rebooted, but it doesn't mount at bootup. I get an error screen that says that "/home/myname/files" could not be mounted. And I have to press "s" to skip it and try the next one. I've added more info to the bottom of my original post.
    – Nick
    Jan 9 '11 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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