dcsimg

Linux Software RAID – A Belt and a Pair of Suspenders

Linux comes with software-based RAID that can be used to provide either a performance boost or add a degree of data protection. This article gives a quick introduction to Linux software RAID and walks through how to create a simple RAID-1 array.

There is an old phrase about wearing a belt and a pair of suspenders if you want to make sure your pants stay up (why haven’t plumbers figured that out?). The point of the phrase is that if you want to be sure that your plans will happen you should have a backup plan as well. In the case of file systems this is literally the truth. If you want to make sure you don’t lose any data, do backups as well as provide some other form of data protection. That something else for data protection is RAID (Redundant Array of Inexpensive Disks).

This article is a brief introduction to software RAID, which is really md (Multiple Device Driver) for Linux. As with the article on LVM, this article is just a quick introduction and not a deep tutorial. The intent is to quickly demonstrate Linux software RAID using md and mdadm. Perhaps this article will show you how easy it is to add software RAID to your repertoire to either help improve performance or provide extra protection. In essence, this article will introduce you to Linux software RAID becoming the “suspenders” to the “belt” of backups.

Quick Introduction

The original intent of RAID was to improve IO performance as well as using smaller disks to create larger virtual disks (although the phrase “virtual” disk was not originally used, in this age of “virtual-everything” it seems appropriate). The basic concept was then embraced and developed from the 1987 inception to today.

RAID has evolved into a technology that is ubiquitous as storage drives themselves. It allows system designers to add in performance while also providing some additional data protection (don’t forget to wear your “belt”). There are many choices with RAID such as various RAID levels and software and/or hardware RAID. Software RAID means the RAID functionality is provided in software by the OS. Hardware RAID means the RAID functionality is provided by a card, usually in a PCI or PCIe slot. There a couple of articles that can present the pros and cons of the various RAID options, here and here. But this article will focus on software RAID with Linux using the md capability of Linux.

It’s beyond the scope of this article to discuss the various RAID level options. There are better articles for this (it may be wikipedia, but it’s a good introduction to the various RAID levels). Instead this article will go through the creation of a simple RAID-1 setup. RAID-1 mirrors disks (actually disk partitions) so if you write to one, the data is copied to the other disk(s). This is a simple way to provide some data protection because you can lose a single disk without losing any data (but it is not a substitute for real backups). So what is a good way to create and manage RAID arrays on Linux?

Madam – I’m mdadm

Handling md groups can be very complex and difficult. It can require hand editing files where a mistake can cause the lose of RAID groups. If you are careful, it works very well. But to help you maintain your RAID groups, Neil Brown started a project for an administrative tool for md called mdadm.

The mdadm tool is very comprehensive and has a variety of functions:


  • Assemble: Assemble the components of a previously created array into an active array

  • Build: Build an array that doesn’t have a superblock on each device

  • Create: Create a new RAID array with a superblock on each device

  • Monitor: Monitor one or more md devices and act on any changes

  • Grow: Change the size (grow or shrink) or reshape an md device. This also allows you to add devices as needed

  • Incremental Assembly: Add a single device to an array

  • Manage: This function allows you to manage specific components of the RAID array such as adding new spare devices or removing faulty devices

  • Misc: This is the function that contains all other functions that might be needed

  • Auto-detect: This function, while not explicit, has the kernel activate any auto-detected arrays

The man pages are quite good and you can find it on-line here.

This article will present a simple example with two drives. For this article, a CentOS 5.3 distribution was used on the following system:


  • GigaByte MAA78GM-US2H motherboard
  • An AMD Phenom II X4 920 CPU
  • 8GB of memory
  • Linux 2.6.30 kernel
  • The OS and boot drive are on an IBM DTLA-307020 (20GB drive at Ulta ATA/100)
  • /home is on a Seagate ST1360827AS
  • There are two drives for testing. They are Seagate ST3500641AS-RK with 16 MB cache each. These are /dev/sdb and /dev/sdb.

Using this configuration a simple RAID-1 configuration is created between /dev/sdb and /dev/sdc.

Step 1 – Set the ID of the drives
The first step in the creation of a RAID-1 group is to set the ID of the drives that are to be part of the RAID group. The type is “fd” (Linux raid autodetect) and needs to be set for all partitions and/or drives used in the RAID group. You can check the partition types fairly easy:

# fdisk -l /dev/sdb

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       60801   488384001   fd  Linux raid autodetect
# fdisk -l /dev/sdc

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1       60801   488384001   fd  Linux raid autodetect

Step 2 – Create the RAID set using mdadm The tool mdadm allows the easy creation of a RAID group. In this article, a simple RAID-1 group, a two disk group is created.

[root@test64 ~]# mdadm --create --verbose /dev/md0 --level raid1 --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm: /dev/sdb1 appears to contain an ext2fs file system
    size=244187136K  mtime=Sun Aug 16 13:06:51 2009
mdadm: /dev/sdc1 appears to contain an ext2fs file system
    size=244187136K  mtime=Sun Aug 16 13:06:51 2009
mdadm: size set to 488383936K
Continue creating array? y
mdadm: array /dev/md0 started.

The options are fairly easy to understand. The first option “–create” creates a RAID group (naturally). After the “–verbose” option is the md device, in this case it’s /dev/md0. After that is the RAID level (“–level”) – in this case it’s raid1. Finally the RAID devices are specified using the “–raid-devices” option. Also notice that it prompts the user if there is a file system on the drives (partitions).

RAID works on a block level. That is, the RAID controller, be it software RAID or hardware RAID, works on the blocks of the devices in the RAID group. This means it’s independent of the file system. Consequently, immediately after the RAID1 group is created, the drives are “synchronized”. That is, the contents of the blocks from the first partition (drive) are copied to the second partition (drive). Below is the output of that synchronization process at very stages of completion (just to give you an idea of speed and time).

# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
      488383936 blocks [2/2] [UU]
      [>....................]  resync =  0.2% (1444224/488383936) finish=112.3min speed=72211K/sec

unused devices:

Notice that the status of the synchronization process is found by “cat-ing” the contents of the file /proc/mdstat.

# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
      488383936 blocks [2/2] [UU]
      [==========>..........]  resync = 50.1% (245077952/488383936) finish=57.4min speed=70554K/sec

unused devices:
[root@test64 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
      488383936 blocks [2/2] [UU]
      [================>....]  resync = 80.1% (391254144/488383936) finish=25.9min speed=62269K/sec

unused devices:
[root@test64 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
      488383936 blocks [2/2] [UU]
      [===================>.]  resync = 99.6% (486830720/488383936) finish=0.5min speed=47731K/sec

unused devices:

After the synchronization process is finished, the output should look like the following.

# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
      488383936 blocks [2/2] [UU]

unused devices:

Comments on "Linux Software RAID – A Belt and a Pair of Suspenders"

Great blog here! Also your website loads up very fast! What host are you using? Can I get your affiliate link to your host? I wish my website loaded up as fast as yours lol|

Every as soon as in a even though we opt for blogs that we read. Listed below are the latest internet sites that we pick out.

Hello, i think that i noticed you visited my website so i got here to return the desire?.I’m attempting to in finding issues to improve my web site!I assume its ok to use a few of your concepts!!|

Hi there, of course this paragraph is actually nice and I have learned lot of things from it concerning blogging. thanks.|

What’s up, yes this piece of writing is genuinely nice and I have learned lot of things from it about blogging. thanks.|

The time to read or pay a visit to the content or web sites we’ve linked to below.

I’m truly enjoying the design and layout of your website. It’s a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a developer to create your theme? Great work!|

Hi, I do think this is an excellent web site. I stumbledupon it ;) I may return once again since i have book-marked it. Money and freedom is the best way to change, may you be rich and continue to guide other people.|

Every once inside a whilst we pick blogs that we read. Listed beneath are the newest sites that we opt for.

I all the time emailed this web site post page to all my associates, for the reason that if like to read it next my contacts will too.|

Below you?ll locate the link to some websites that we feel you’ll want to visit.

Always a major fan of linking to bloggers that I adore but don?t get quite a bit of link appreciate from.

We came across a cool site that you simply might delight in. Take a look should you want.

Here are some of the sites we advocate for our visitors.

Here is a good Blog You might Uncover Exciting that we encourage you to visit.

One of our guests lately suggested the following website.

Just beneath, are several totally not related internet sites to ours, however, they are surely worth going over.

Although web sites we backlink to below are considerably not associated to ours, we feel they are actually really worth a go by, so possess a look.

The time to read or check out the content or web sites we have linked to below.

Way cool! Some extremely valid points! I appreciate you writing this post and also the rest of the site is very good.|

Every the moment in a though we pick out blogs that we study. Listed below are the most current web pages that we pick out.

Do you have a spam problem on this site; I also am a blogger, and I was wondering your situation; many of us have developed some nice procedures and we are looking to trade techniques with other folks, be sure to shoot me an email if interested.|

Every after in a whilst we pick out blogs that we study. Listed beneath are the most current web-sites that we pick out.

The time to read or visit the content or web sites we’ve linked to beneath.

You have made some really good points there. I looked on the net for additional information about the issue and found most individuals will go along with your views on this website.|

Below you will find the link to some websites that we think it is best to visit.

I think everything said was very reasonable. However, consider this, what if you composed a catchier title? I ain’t suggesting your information isn’t good., however what if you added a headline that grabbed folk’s attention? I mean %BLOG_TITLE% is kinda boring. You could look at Yahoo’s front page and watch how they create news titles to get viewers to open the links. You might add a video or a related picture or two to grab people excited about everything’ve got to say. Just my opinion, it would make your posts a little livelier.|

Wow, this post is fastidious, my sister is analyzing these kinds of things, so I am going to tell her.|

I wanted to thank you for this very good read!! I definitely enjoyed every little bit of it. I have you book-marked to check out new stuff you post…|

Thanks for finally writing about > %blog_title% < Loved it!|

Here is a great Blog You might Obtain Exciting that we encourage you to visit.

It’s amazing to go to see this website and reading the views of all mates on the topic of this piece of writing, while I am also zealous of getting experience.|

Hi there! Do you know if they make any plugins to protect against hackers? I’m kinda paranoid about losing everything I’ve worked hard on. Any tips?|

Thanks a bunch for sharing this with all folks you really recognise what you’re talking approximately! Bookmarked. Please also consult with my website =). We can have a link alternate contract between us|

Although web sites we backlink to beneath are considerably not connected to ours, we feel they are essentially worth a go by, so possess a look.

Please check out the web sites we stick to, like this one, as it represents our picks from the web.

I am really loving the theme/design of your blog. Do you ever run into any internet browser compatibility issues? A handful of my blog audience have complained about my website not working correctly in Explorer but looks great in Firefox. Do you have any recommendations to help fix this problem?|

My spouse and I stumbled over here different web address and thought I might check things out. I like what I see so now i’m following you. Look forward to looking at your web page repeatedly.|

Just beneath, are many absolutely not connected web sites to ours, however, they’re surely worth going over.

Superb blog odpdoss! Do you have any suggestions for aspiring writers? I’m planning to start my own blog soon but I’m a little lost on everything. Would you recommend starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m totally overwhelmed .. Any tips? Thanks!

Usually posts some very fascinating stuff like this. If you are new to this site.

Here are a few of the web sites we advise for our visitors.

What’s Going down odpsossxv i am new to this, I stumbled upon this I’ve discovered It positively helpful and it has helped me out loads. I am hoping to give a contribution & aid different users like its helped me. Good job.

We came across a cool web page which you could possibly enjoy. Take a look if you want.

Here are some of the internet sites we recommend for our visitors.

Excellent web site. Lots of useful information here. I’m sending it to some buddies ans additionally sharing in delicious. And naturally, thanks on your effort!|

Hi there to every one, because I am really eager of reading this web site’s post to be updated on a regular basis. It carries nice material.|

Every the moment inside a whilst we pick out blogs that we read. Listed beneath would be the latest web pages that we select.

Every when inside a though we select blogs that we read. Listed below are the most recent web-sites that we choose.

Hi i am kavin, its my first time to commenting anywhere, when i read this article i thought i could also create comment due to this good paragraph.|

Leave a Reply