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.

At this point a file system can be created on the md device.

# mkfs.ext3 /dev/md0
mke2fs 1.41.7 (29-June-2009)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
30531584 inodes, 122095984 blocks
6104799 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
3727 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

You can then mount the file system fairly easily. For example, the following line was added to /etc/fstab:

/dev/md0                /mnt/raid1_test        ext3    defaults,data=ordered   0 0

Then the file system is mounted using “mount -a” (assuming the mount point exists).

To make sure the file system is mounted, you can check the file system

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda3              16G  5.2G   11G  34% /
/dev/sda1             147G  5.6G  134G   5% /home
/dev/hda1             969M   17M  902M   2% /boot
tmpfs                 3.8G     0  3.8G   0% /dev/shm
/dev/md0              459G  199M  435G   1% /mnt/raid1_test

Step 3 – Monitoring the RAID group
Once the RAID group is up and a file system is created, the next step is to monitor the array. There are several pieces to monitoring the array, including understanding the details of the array.

# mdadm --detail /dev/md0
/dev/md0:
        Version : 00.90.03
  Creation Time : Sun Aug 16 13:26:49 2009
     Raid Level : raid1
     Array Size : 488383936 (465.76 GiB 500.11 GB)
  Used Dev Size : 488383936 (465.76 GiB 500.11 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Sun Aug 16 15:35:13 2009
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : f10d60d8:d6f47f28:f4379aeb:ea2e53d0
         Events : 0.34

    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       1       8       33        1      active sync   /dev/sdc1

There is a great deal of information in this output. How many devices are in the RAID array, how many devices are failed, how many devices are labeled as hot spares, etc.


  • Raid Level – In this case it is “raid1″

  • Array Size – the size of the RAID array, which in this case is 465.76 GiB

  • Raid Devices – the number of devices in the raid group, which in this case is 2

  • Total Devices – the total number of devices in the raid array, which in this case is 2

  • Active Devices – the number of active devices which is 2 for this case

  • Working Devices – the number of working devices in the array, which in this case is 2

  • Failed Devices – the number of devices that have failed, which in this case is 0

  • Spare Devices – the number of spare devices to be used by the array, which in this case is 0

This command can run periodically and the output can be parsed as part of a cron job or emailed to the system administrator.

There is an option for the mdadm command, “–mail [address]“, that allows you to add an email address so that when there are events an email will be sent to the designated address. You can also add the following options:


  • –program : Allows you to add a program that is to be run whenever an alert is detected.

  • –syslog : This causes all events to be reported to the syslog of the system (always a good idea)

You can also get some of this information from the output of the file /proc/mdstat.

Let’s disect the output of cat /proc/mdstat.

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

unused devices:

The output lists the active devices. In the case of RAID-1, it also tells you which device is considered the primary device. You look for the lowest number in the line listing the devices in the raid array. In this case, it’s sdb1 because it is listed as “[0]“. The next line down, which contains the number of blocks, lists the status of each device. In this case the section of data is listed as “[UU]“. The first “U” on the left corresponds to the first device listed (in this case sdc1) and the second “U” on the right corresponds to the second device listed (/dev/sdb1). The “U” means that the device is up and running. So by looking at /proc/mdstat you can immediately tell if there is a device down (you will see a “_” in place of “U” if the device is down or failed).

There is a whole host of command and techniques for managing the RAID array. You can add and subtract hot spare devices to the RAID group (always good to have a hot spare). You can also fail certain devices if you want to pull them out and replace them. However, it is beyond the scope of this particular article to talk about managing a RAID array. There are tutorials on the web that present some practical techniques for accomplishing this.


These are only a few articles floating around the web.

Summary

Linux software RAID is a great free tool that can be used to help improve performance (RAID-0) or help data protection (RAID-1, RAID-5, RAID-6). The developers of mdadm, led by Neil Brown, have developed a wonderful tool for administering and monitoring RAID arrays. This article very quickly shows how to create a RAID-1 array to help with data protection. It couples the “suspenders” of RAID-1 with the “belt” of backups and can save your bacon in many cases.

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

Very nice post. I simply stumbled upon your weblog and wished to say that I have really enjoyed browsing your weblog posts. After all I’ll be subscribing to your rss feed and I hope you write again very soon!|

Here is a superb Weblog You might Uncover Interesting that we encourage you to visit.

We came across a cool website which you may take pleasure in. Take a search for those who want.

What’s up everyone, it’s my first go to see at this web page, and piece of writing is truly fruitful for me, keep up posting these types of content.|

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

I’m not that much of a online reader to be honest but your blogs really nice, keep it up! I’ll go ahead and bookmark your site to come back down the road. All the best|

Usually posts some extremely intriguing stuff like this. If you?re new to this site.

Thanks for making me to get new odpdoss concepts about computers. I also have the belief that one of the best ways to help keep your notebook in perfect condition has been a hard plastic case, and also shell, that fits over the top of one’s computer. These types of protective gear usually are model targeted since they are made to fit perfectly over the natural outer shell. You can buy these directly from the seller, or through third party sources if they are available for your notebook computer, however don’t assume all laptop will have a cover on the market. Yet again, thanks for your suggestions.

Please check out the sites we adhere to, including this one, as it represents our picks in the web.

Below you?ll find the link to some web sites that we believe you’ll want to visit.

Every as soon as in a even though we pick out blogs that we read. Listed below would be the most current web pages that we pick.

The time to read or go to the content material or web sites we have linked to below.

Wonderful story, reckoned we could combine some unrelated data, nevertheless actually worth taking a search, whoa did 1 study about Mid East has got much more problerms also.

The time to study or visit the content or web pages we’ve linked to beneath.

Leave a Reply