Note: There is an updated version of this article for Ubuntu 6.10 here

Wanting to finally put these stupid SATA disks to good use, I managed to get them thrown into a RAID-1 configuration on my happy Ubuntu install.

Just thought I’d share how I did it, and the resources I used. Standard disclaimer applies: If you follow these instructions, and you lose all your data, or the world explodes, or the sky starts falling, or you die, I’m not liable.
Here are the resources I used.

Go to Disks Manager to figure out the Devices that you want to actually make into a RAID, for me that was /dev/sda and /dev/sdb. These are 2×160GB Seagate SATA disks attached to a Promise FastTrak 378 controller on an Asus A8V Deluxe motherboard.

So now you need to create the partitions that you want to use as a RAID.


daniel@ubuntu:~$ sudo cfdisk /dev/sda
daniel@ubuntu:~$ sudo cfdisk /dev/sdb

I made mine Primary Partitions (not sure if this is good, bad, or if it matters at all), and you NEED to make the filesystems of type Linux Raid Autodetect (FD).

After that, i loaded the RAID module for RAID-1 (Mirror) because that’s the type of RAID I wanted to build:


daniel@ubuntu:~$ sudo modprobe raid1

After this, I restarted the Disks Manager to see what the partitions had been called on my disks. I selected the disk on the left, and took a look at the partition tab on the right, noticing that one of my disk partitions was /dev/sda1 and the other was /dev/sdb1.

Now we can run mdadm:


daniel@ubuntu:~$ sudo mdadm —create /dev/md0 —level=1 —raid-devices=2 /dev/sda1 /dev/sdb1

Now let’s take a look at the status of the disks as they are rebuilding the RAID:


daniel@ubuntu:~$ sudo cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
156288256 blocks [2/2] [UU]
[>....................] resync = 0.9% (1459904/156288256) finish=54.7min speed=47093K/sec
unused devices:
daniel@ubuntu:~$

So, 54.7 minutes left for the disks to finish the sync [start twiddling thumbs].

You can get some information about the partition by going like so:


daniel@ubuntu:~$ sudo mdadm —misc —detail /dev/md0

So, once it finished, let’s make a file system. I’m going to use ext3, but you go ahead and use whatever you like, so we go:


daniel@ubuntu:~$ sudo mkfs.ext3 /dev/md0

And once it finished, we should (technically) have a nice pretty file system. But now we have to mount it. I want to mount mine in a /backup directory, because I’m going to be using this RAID for backups.

So here we go:


daniel@ubuntu:~$ sudo mkdir /backup
daniel@ubuntu:~$ sudo mount /dev/md0 /backup

Now, technically, we should have nearly 160GB of yummy RAID1 love available to us in the /backup directory. Let’s run df and see what it tells us:


daniel@ubuntu:/backup$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda2 35064712 5173932 28109576 16% /
tmpfs 1026508 0 1026508 0% /dev/shm
tmpfs 1026508 13536 1012972 2% /lib/modules/2.6.12-10-amd64-generic/volatile
/dev/sdc1 199093056 136388704 62704352 69% /media/EXTERNAL
/dev/md0 153834788 131228 145889148 1% /backup

Excellent, /dev/md0 is mounted at /backup, and we’ve got lots of backup space.

In order to get this thing to mount each time we boot, we’ll want to put it into our /etc/fstab file. Let’s do that now.

I added a line like this to my /etc/fstab:


/dev/md0 /backup ext3 defaults,errors=remount-ro 0 2

I’m not a super-linux-ninja, but I was able to figure out what I wanted to do here by reading the man page for fstab, and by looking at the other entries in the file. So run “man fstab” and then you can edit the fstab file (by using something like “sudo vi /etc/fstab” once you’re feeling like you’re comfortable with what to add there).

Ok, that’s going to be the last entry for a while, I’m heading to New Zealand tomorrow, and won’t be back for three weeks. I also haven’t rebooted my machine yet to see if that /etc/fstab change worked, so lets hope I didn’t mess something up.