How to setup RAID 1 on Ubuntu Linux?

RAID 1 creates a mirror on the second drive. .You will need to create RAID aware partitions on your drives before you can create RAID and you will need to install mdadm on Ubuntu.


You may have to create the RAID device first by indicating the RAID device with the block major and minor numbers. Be sure to increment the “2” number by one each time you create an additional RAID device.

# mknod /dev/md1 b 9 2

This will create the device if you have already used /dev/md0.

Create RAID 1

# mdadm –create /dev/md1 –level=1 –raid-devices=2 /dev/sdb7 /dev/sdb8

This will create a RAID array. The device that you will use for the first RAID array is /dev/md1.

The level option determines what RAID level you will use for the RAID.

–raid-devices=2 /dev/sdb7 /dev/sdb8
Note: for illustration or practice this shows two partitions on the same drive. This is NOT what you want to do, partitions must be on separate drives. However, this will provide you with a practice scenario. You must list the number of devices in the RAID array and you must list the devices that you have partitioned with fdisk. The example shows two RAID partitions.
mdadm: array /dev/md0 started.

Verify the Create of the RAID

# cat /proc/mdstat

Personalities : [raid0] [raid1]

md2 : active raid1 sdb8[1] sdb7[0]

497856 blocks [2/2] [UU]

[======>…………..] resync = 34.4% (172672/497856) finish=0.2min speed=21584K/sec

md0 : active raid0 sdb6[1] sdb5[0]

995712 blocks 64k chunks

unused devices:

# tail /var/log/messages

You can also verify that RAID is being built in /var/log/messages.

May 19 09:21:45 ub1 kernel: [ 5320.433192] md: raid1 personality registered for level 1

May 19 09:21:45 ub1 kernel: [ 5320.433620] md2: WARNING: sdb7 appears to be on the same physical disk as sdb8.

May 19 09:21:45 ub1 kernel: [ 5320.433628] True protection against single-disk failure might be compromised.

May 19 09:21:45 ub1 kernel: [ 5320.433772] raid1: raid set md2 active with 2 out of 2 mirrors

May 19 09:21:45 ub1 kernel: [ 5320.433913] md: resync of RAID array md2

May 19 09:21:45 ub1 kernel: [ 5320.433926] md: minimum _guaranteed_ speed: 1000 KB/sec/disk.

May 19 09:21:45 ub1 kernel: [ 5320.433934] md: using maximum available idle IO bandwidth (but not more than 200000 KB/sec) for resync.

May 19 09:21:45 ub1 kernel: [ 5320.433954] md: using 128k window, over a total of 497856 blocks.

Create the File System ext 3.
You have to place a file system on your RAID device. The journaling system ext3 is placed on the device in this example.

# mke2fs -j /dev/md1

mke2fs 1.40.8 (13-Mar-2008)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

124928 inodes, 497856 blocks

24892 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=67633152

61 block groups

8192 blocks per group, 8192 fragments per group

2048 inodes per group

Superblock backups stored on blocks:

8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing inode tables: done

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

Mount the RAID on the /raid Partition

In order to use the RAID array you will need to mount it on the file system. For testing purposes you can create a mount point and test. To make a permanent mount point you will need to edit /etc/fstab.

# mount /dev/md1 /raid

# df
The df command will verify that it has mounted.

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sda2 5809368 2699256 2817328 49% /

varrun 1037732 104 1037628 1% /var/run

varlock 1037732 0 1037732 0% /var/lock

udev 1037732 80 1037652 1% /dev

devshm 1037732 12 1037720 1% /dev/shm

/dev/sda1 474440 49252 400691 11% /boot

/dev/sda4 474367664 1738024 448722912 1% /home

/dev/md1 482090 10544 446654 3% /raid

You should be able to create files on the new partition. If this works then you may edit the /etc/fstab and add a line that looks like this:

/dev/md1 /raid defaults 0 2

Be sure to test and be prepared to enter single user mode to fix any problems with the new RAID device.

Create a Failed RAID Disk

In order to test your RAID 1 you can fail a disk, remove it and reinstall it. This is an important feature to practice.

# mdadm /dev/md1 -f /dev/sdb8
This will deliberately make the /dev/sdb8 faulty.

mdadm: set /dev/sdb8 faulty in /dev/md1

root@ub1:/etc/network# cat /proc/mdstat

Personalities : [raid0] [raid1]

md2 : active raid1 sdb8[2](F) sdb7[0]

497856 blocks [2/1] [U_]

md0 : active raid0 sdb6[1] sdb5[0]

995712 blocks 64k chunks

unused devices:

Hot Remove the Failed Disk
You can remove the faulty disk from the RAID array.

# mdadm /dev/md1 -r /dev/sdb8

mdadm: hot removed /dev/sdb8

Verify the Process

You should be able to see the process as it is working.

# cat /proc/mdstat

Personalities : [raid0] [raid1]

md2 : active raid1 sdb7[0]

497856 blocks [2/1] [U_]

md0 : active raid0 sdb6[1] sdb5[0]

995712 blocks 64k chunks

unused devices:

Add a Replacement Drive HOT

This will allow you to add a device into the array to replace the bad one.
# mdadm /dev/md1 -a /dev/sdb8

mdadm: re-added /dev/sdb8

Verify the Process.

# cat /proc/mdstat

Personalities : [raid0] [raid1]

md2 : active raid1 sdb8[2] sdb7[0]

497856 blocks [2/1] [U_]

[=====>……………] recovery = 26.8% (134464/497856) finish=0.2min speed=26892K/sec

md0 : active raid0 sdb6[1] sdb5[0]

995712 blocks 64k chunks

unused devices:

Please follow and like us:

56 thoughts on “How to setup RAID 1 on Ubuntu Linux?

  1. of course like your website but you have to test the spelling on quite a few of your posts. Several of them are rife with spelling problems and I in finding it very bothersome to tell the reality then again I’ll surely come back again.

  2. What i do not realize is in reality how you are not actually much more well-liked than you may be right now. You’re so intelligent. You already know thus significantly in terms of this topic, produced me in my view believe it from so many varied angles. Its like women and men aren’t interested unless it?¦s something to do with Lady gaga! Your personal stuffs great. All the time take care of it up!

  3. I found your blog web site on google and examine a few of your early posts. Proceed to maintain up the superb operate. I just further up your RSS feed to my MSN News Reader. In search of forward to reading extra from you later on!…

  4. Fantastic goods from you, man. I’ve have in mind your stuff prior to and you are just too fantastic. I actually like what you’ve acquired right here, certainly like what you are saying and the way in which wherein you assert it. You are making it enjoyable and you continue to care for to stay it smart. I cant wait to learn far more from you. This is really a great web site.

  5. Pretty section of content. I just stumbled upon your weblog and in accession capital to assert that I acquire in fact enjoyed account your blog posts. Anyway I’ll be subscribing to your augment and even I achievement you access consistently fast.

  6. Undeniably believe that that you said. Your favorite reason appeared to be at the net the easiest factor to take into accout of. I say to you, I certainly get irked even as folks consider concerns that they just don’t understand about. You managed to hit the nail upon the top and defined out the whole thing without having side effect , folks could take a signal. Will likely be again to get more. Thank you

  7. Hi! I could have sworn I’ve been to this site before but after browsing through some of the post I realized it’s new to me. Nonetheless, I’m definitely delighted I found it and I’ll be book-marking and checking back frequently!

  8. I not to mention my buddies were reading the nice techniques located on the website then immediately I had a terrible suspicion I never thanked the web site owner for those tips. My men appeared to be consequently joyful to study all of them and have surely been loving them. I appreciate you for actually being considerably accommodating and for picking variety of good areas most people are really needing to understand about. Our honest apologies for not saying thanks to you sooner.

  9. There are certainly a number of details like that to take into consideration. That may be a great point to bring up. I supply the thoughts above as common inspiration however clearly there are questions like the one you deliver up where the most important thing will likely be working in honest good faith. I don?t know if greatest practices have emerged round things like that, but I’m certain that your job is clearly recognized as a good game. Each girls and boys really feel the impression of only a second’s pleasure, for the rest of their lives.

  10. Oh my goodness! an incredible article dude. Thank you However I am experiencing subject with ur rss . Don’t know why Unable to subscribe to it. Is there anyone getting identical rss problem? Anybody who is aware of kindly respond. Thnkx

  11. Hi there very cool blog!! Guy .. Excellent .. Superb .. I will bookmark your web site and take the feeds additionally…I’m happy to search out numerous helpful info right here within the post, we’d like develop extra techniques on this regard, thanks for sharing.

  12. Awsome info and right to the point. I am not sure if this is in fact the best place to ask but do you people have any ideea where to employ some professional writers? Thanks in advance 🙂

  13. When I originally commented I clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Thanks!

  14. Whats Going down i’m new to this, I stumbled upon this I have discovered It absolutely useful and it has helped me out loads. I hope to contribute & help different users like its aided me. Good job.

  15. I’m extremely impressed along with your writing talents and also with the format to your blog. Is this a paid subject or did you modify it yourself? Anyway keep up the excellent high quality writing, it’s uncommon to peer a nice blog like this one nowadays..

  16. I’ve been surfing on-line more than 3 hours as of late, but I never found any fascinating article like yours. It is beautiful worth enough for me. In my opinion, if all webmasters and bloggers made excellent content as you did, the internet shall be much more useful than ever before.

  17. Hello! I could have sworn I’ve been to this blog before but after checking through some of the post I realized it’s new to me. Anyhow, I’m definitely happy I found it and I’ll be bookmarking and checking back frequently!

Leave a Reply to Anonymous Cancel reply