个人工具

“UbuntuHelp:Installation/SoftwareRAID”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
 
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/Installation/SoftwareRAID}}
 
{{From|https://help.ubuntu.com/community/Installation/SoftwareRAID}}
 
{{Languages|UbuntuHelp:Installation/SoftwareRAID}}
 
{{Languages|UbuntuHelp:Installation/SoftwareRAID}}
How to install Ubuntu onto a '''''Linux Software RAID''''' system
+
How to create RAID using '''''Ubuntu Software RAID'''''. Including RAID 0, 1, 5 and 6.
Note: https://wiki.ubuntu.com/BootDegradedRaid seems to indicate that many or all of the problems mentioned here have been fixed for Intrepid.
+
Ubuntu 9.10 provides very easy way to build RAID. You can build a RAID system using Ubuntu user interface, requires no CLI anymore!
 +
Note: Be aware of the fragile state of RAID support in Ubuntu and what it takes to get a reliable raid setup (https://wiki.ubuntu.com/ReliableRaid), but most of them has fixed since Ubuntu 8.10.
 
=== Introduction ===
 
=== Introduction ===
RAID is a method of using multiple hard drives to act as one, reducing the probability of catastrophic data loss in case of drive failure. RAID is implemented in either software (where the operating system knows about both drives and actively maintains both of them) or hardware (where a special controller makes the OS think there's only one drive and maintains the drives 'invisibly').
+
RAID is a method of using multiple hard drives to act as one, there are 2 purpose of RAID:
The RAID software included with current versions of Linux (and Ubuntu) is based on the 'mdadm' driver and works very well, better even than many so-called 'hardware' RAID controllers.
+
* Expand drive capacity: RAID 0. If you have 2 x 500 GB HDD then total space become 1 TB
NOTE: Many aftermarket motherboards tout 'hardware RAID' but it's really not.  Instead, it's a software driver with a slight hardware 'assist' from the motherboard; these systems are known as "FakeRAID" in the Linux community.  If you're doing a new install, it is better to use the standard Linux drivers.  If you're trying to dual-boot an existing FakeRAID setup, or you're insistent on using it even on a new install, you need to follow these instructions, [[UbuntuHelp:FakeRaidHowto|FakeRaidHowto]].
+
* Prevent data loss in case of drive failure: RAID 1, RAID 5, and RAID 6. You can combine RAID 0 to other RAID, e.g RAID 0 + 1 become RAID 10.
 +
There are 3 ways to create RAID:
 +
<ol><li>Software-RAID: Where the RAID created by software.
 +
</li><li>Hardware-RAID: A special controller used to build RAID. RAID hardware faster, no CPU overload and can be used for any OS
 +
</li><li>FakeRAID: Since RAID hardware is very expensive, many motherboard manufacturers use multi-channel controllers with special BIOS features to perform RAID. This implementation is faster than software RAID. Read [[UbuntuHelp:FakeRaidHowto|FakeRaidHowto]] for details.</li></ol>
 +
 
 +
The RAID software included with current versions of Linux (and Ubuntu) is based on the 'mdadm' driver and works very well.
 
=== Requirements ===
 
=== Requirements ===
* The "Alternate" install CD for *buntu if you're building a desktop system. If you're building a server, the server install CD includes the necessary options. [[UbuntuHelp:GettingUbuntu#head-40b5bcdbc1d4ec7b8149519dfd4f08c7fa274559| Getting Ubuntu Alternate Install disk]]
+
* If you're building a server, the server install CD includes the necessary options.
* At least two hard drives, preferably the same mode, size, etc.
+
* If you're building a desktop then you need the "Alternate" install CD for Ubuntu. Read [[UbuntuHelp:GettingUbuntu#head-40b5bcdbc1d4ec7b8149519dfd4f08c7fa274559| Getting Ubuntu Alternate Install disk]] and [[UbuntuHelp:Installation#head-194b248381c71c37f7b187c6b814bbe7e31d91d6| How to do a Ubuntu Alternate Install]]
 +
* [[UbuntuHelp:BurningIsoHowto|How to Burn an ISO]]
 +
* At least 2 hard drives, preferably same size
 
After a successful install, you should also manually fix 2 shortcomings in the default configuration:
 
After a successful install, you should also manually fix 2 shortcomings in the default configuration:
* Install GRUB boot-loader on second drive
+
* Install GRUB boot-loader on second drive (this step is not need if you use Ubuntu 9.10)
 
* Update startup script to detect a failed drive
 
* Update startup script to detect a failed drive
 
=== Installing ===
 
=== Installing ===
[[UbuntuHelp:BurningIsoHowto|How to Burn an ISO]]
+
Install Ubuntu until you get to partitioning the disks
You must use either the alternate cd-image or the server image to install ubuntu on raid.
+
https://help.ubuntu.com/community/Installation/SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_00.png
Follow the install instruction for an Alternate Install until you get to partitioning the disks
+
[[UbuntuHelp:Installation#head-194b248381c71c37f7b187c6b814bbe7e31d91d6| How to do a Ubuntu Alternate Install]]
+
 
==== Partitioning the disk ====
 
==== Partitioning the disk ====
For a 2 hard drive system in RAID 1 configuration. (repeat steps for additional hard drives)
 
 
'''Warning: the /boot filesystem cannot use any softRAID level other than 1''' with the stock Ubuntu bootloader.  If you want to use some other RAID level for most things, you'll need to create separate partitions and make a RAID1 device for /boot.
 
'''Warning: the /boot filesystem cannot use any softRAID level other than 1''' with the stock Ubuntu bootloader.  If you want to use some other RAID level for most things, you'll need to create separate partitions and make a RAID1 device for /boot.
'''Warning: this will remove all data on hard drives.''' See [[UbuntuHelp:DrivesAndPartitions|DrivesAndPartitions]] for more information.
+
'''Warning: this will remove all data on hard drives.'''  
<ol><li>Select "Manual" as your partition method.
+
1. Select "Manual" as your partition method  
</li><li>Select your 1st hard drive, and agree to "Create a new empty partition table on this device ?"
+
</li><li>Repeat step 2 with your 2nd hard drive.
+
</li><li>Select the "FREE SPACE" on the 1st drive then select "Create a new partition"
+
</li><li>Select the size (suggestion, normally you want a root partition major part of the hard drive and swap which is 1.5 times the amount of ram )
+
</li><li>Select Primary, then Beginning.
+
</li><li>Select the "Use as:" by default this is "Ext3 journalling file system" we want to change that to "physical volume for RAID"
+
</li><li>Select "bootable flag" and set it to "on"
+
</li><li>Select "Done setting up the partition"</li></ol>
+
  
10. Repeat steps 4 to 10 for the 2nd hard drive and the other partitions.
+
https://help.ubuntu.com/community/Installation/SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_01.png
 +
2. Select your hard drive, and agree to "Create a new empty partition table on this device ?"
 +
 
 +
https://help.ubuntu.com/community/Installation/SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_02.png https://help.ubuntu.com/community/Installation/SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_03.png
 +
3. Select the "FREE SPACE" on the 1st drive then select "automatically partition the free space
 +
 
 +
https://help.ubuntu.com/community/Installation/SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_04.png https://help.ubuntu.com/community/Installation/SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_05.png
 +
4. Ubuntu will create 2 partitions: / and swap, as shown below:
 +
 
 +
https://help.ubuntu.com/community/Installation/SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_06.png
 +
5. On / partition select "bootable flag" and set it to "on"
 +
 
 +
https://help.ubuntu.com/community/Installation/SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_06.png
 +
6. Repeat steps 2 to 5 for the other hard drive
 +
 
 +
As you see Ubuntu 9.10 makes RAID creation very easy. No need to define partition manually anymore! Ubuntu 9.10 also use ext4 the latest Linux file system.
 
==== Configuring the RAID ====
 
==== Configuring the RAID ====
 
<ol><li>Once you have complete your partitioning in the main "Partition Disks" page select "Configure Software RAID"
 
<ol><li>Once you have complete your partitioning in the main "Partition Disks" page select "Configure Software RAID"
 
</li><li>Select "Yes"
 
</li><li>Select "Yes"
 
</li><li>Select "Create new MD drive"
 
</li><li>Select "Create new MD drive"
</li><li>Select RAID1, or type of RAID you want (RAID0 RAID1 RAID5)
+
</li><li>Select RAID type: RAID 0, RAID 1, RAID 5 or RAID 6
</li><li>Number of devices 2 or the amount of hard drives you have
+
</li><li>Number of devices. RAID 0 and 1 need 2 drives. 3 for RAID 5 and 4 for RAID 6.
</li><li>Number of spare devices 0
+
</li><li>Number of spare devices. Enter 0 if you have no spare drive.
 
</li><li>select which partitions to use. Generally they will be sda1 and sdb1 or hda1 or hdb1. Generally the numbers will match and the different letters are for different hard drives.
 
</li><li>select which partitions to use. Generally they will be sda1 and sdb1 or hda1 or hdb1. Generally the numbers will match and the different letters are for different hard drives.
 
</li><li>At this point the installation may become unresponsive this is the hard drives already syncing. Repeat steps 3 to 7 with each pair of partitions you have created.
 
</li><li>At this point the installation may become unresponsive this is the hard drives already syncing. Repeat steps 3 to 7 with each pair of partitions you have created.
第45行: 第58行:
  
 
==== Formatting ====
 
==== Formatting ====
You now have a list of your hard drives and your RAID drives. We will now format and set the mount point for other RAID drives. Treat the RAID drive as a local hard drive and format and mount accordingly
+
Ubuntu 9.10 will automatically format your partitions.
<ol><li>Select Partition.
+
</li><li>Go to Use as Select Ext 3 for your normal partitions or swap area for your swap partition
+
</li><li>If you select Ext 3 then select your mount point if you only have one partition for ext 3 select /
+
</li><li>Repeat for each RAID partition.</li></ol>
+
 
+
Select "Finish partitioning and write changes to disk"
+
From this point on, your hard drive lights will probably be on continuously. This indicates the array syncing. The system can be used normally and even rebooted while the array syncs.
+
 
==== Boot Loader ====
 
==== Boot Loader ====
Performing the above steps in Jaunty server, I did not experience any problems (described below) with (grub) bootloader. However I must admit that I created two raids (a 100MB raid-0 for /boot, and a 240GB raid-0 for /), hence at the time of installation completion, the 100MB raid-device was most likely finnished syncing, so the /boot partition could be found on both physical disks, and may be the reason that I did not run into any problems.
+
There are several problems reported by previous version of Ubuntu. But Ubuntu 9.10 already fixes them. In case you next HDD won't boot then simply install Grub there.
Installation continues as normal until you have to install a bootloader. GRUB installation may appear to complete successfully, but it will not actually work. The key is that GRUB can't be installed on the RAID device.  However, the individual raw partitions that make up the RAID device look just like ordinary non-RAIDed partitions to GRUB. So you need to unmount the RAID device and install grub manually. There are a few ways to go about this, but probably the easiest is to let installation finish and allow the system to begin rebooting.  You'll end up at a
+
#grub-install /dev/sdb
<pre><nowiki>
+
#grub-install /dev/sdc
GRUB>
+
==== Boot from Degraded Disk ====
</nowiki></pre>
+
If default HDD fail then RAID will ask you to boot from degraded disk. In best practice, as specially if you put your server on remote area then you may make this automatically.
prompt.  Now
+
Since Ubuntu 8.10 there is a new feature to boot automatically if default RAID disk fail. Simply:
<pre><nowiki>
+
<ol><li>edit this file /etc/initramfs-tools/conf.d/mdadm
GRUB> find /boot/grub/menu.lst
+
</li><li>change "BOOT_DEGRADED=false" to "BOOT_DEGRADED=true"</li></ol>
</nowiki></pre>
+
or if you have a separate /boot partition,
+
<pre><nowiki>
+
GRUB> find /grub/menu.lst
+
</nowiki></pre>
+
GRUB should respond with something like
+
<pre><nowiki>
+
(hd0,0)
+
(hd1,0)
+
</nowiki></pre>
+
The above says your menu.lst file was found in the first partition of each of your first two disks.
+
Then, for each <code><nowiki>(hdX,Y)</nowiki></code> line you get in response, use this pattern
+
<pre><nowiki>
+
GRUB> root (hdX,Y)
+
GRUB> setup (hdX)
+
</nowiki></pre>
+
When done, hit CTRL-ALT-DEL to reboot the machine again, and everything should work.
+
I wonder if the above steps are necessary then each time there is a kernel update, to install grub on both physical disks.
+
'''Note:''' I'm not 100% sure the above procedure works, because in my case there was probably already a grub hanging around in the MBR of (hd0), and I don't know whether the regular installer procedure will put one there when /boot is on RAID.  Without GRUB in the MBR, you wouldn't even get to a GRUB&gt; prompt at boot. If you want to be safe, please see my alternate method at http://techarcana.net/hydra/os-installation/#boot-loader, but if you try this simple approach ''please'' let me know whether it works for you or not.
+
If for some reason you are able to boot without being dropped into a <code><nowiki>GRUB></nowiki></code> prompt, you'll still want to install GRUB in the MBR (usually) of each drive in the RAID1 array that holds /boot (rather than just the first drive), so that if one drive goes down you can still boot.  So even if things seem to be working, it's a good idea to hit escape at boot to bring up the GRUB menu, drop into a <code><nowiki>GRUB></nowiki></code> prompt, and do the above exercise.
+
More info for Ubuntu 8.10
+
Grub installs correctly.
+
If you have any problems
+
<ol><li>Get hold of System Rescue Disk 1.1.5 (www.sysresccd.org)
+
</li><li>Boot from the rescue disk
+
</li><li>mdadm --stop /dev/md0</li></ol>
+
  
<pre><nowiki>
+
NB:
  mkdir /data
+
* Additionally, this can be specified on the kernel boot line with the bootdegraded=[true|false]
  mount -t ext3 /dev/sda1 /data
+
* You also can use #dpkg-reconfigure mdadm rather than CLI!
  grub-install --recheck --root-directory=/data /dev/sda
+
Now, you have completed the step of making RAID in a few minutes!
  umount /data
+
=== Test your RAID now! ===
  mount -t ext3 /dev/sdb1 /data
+
The very importing part of RAID building is ... TESTING if your RAID works! Simply follow these step to test your RAID:
  grub-install --recheck --root-directory=/data /dev/sdb
+
<ol><li>shutdown your server
  umount /data
+
</li><li>remove the power and cable data of your first drive
</nowiki></pre>
+
</li><li>start your server, see if your server can boot from degraded disk!</li></ol>
It appears that grup-install will only write to a mounted disk. There is no warning of failure if you run a 'grub-install' without mounting the partition on the device.
+
=== Updating startup script ===
+
Every time the computer boots, it scans the available hard-drives to try and identify any RAID array.  Most of the time this is easy and takes place instantaneously. If one of the drives is unusable, however, then the computer needs to operate the remaining drive in 'degraded' mode. If the bad drive failed during regular operation, then the computer will have already removed it from the configuration of the array. If the drive had previously been working, however, and failed spontaneously during power-up or boot-up, then the computer needs to figure it out on-the-fly.
+
The script which tries to detect a failed drive is called 'initramfs' and, as of Ubuntu 8.04, the default code in this script completely fails.  The procedure below adds an additional step so that it will succeed.
+
1. Update the 'initramfs' boot script,
+
  
<pre><nowiki>
 
> gksudo gedit /usr/share/initramfs-tools/scripts/local</nowiki></pre>
 
2. Find the comment,
 
 
<pre><nowiki>
 
# We've given up, but we'll let the user fix matters if they can".</nowiki></pre>
 
3. Just *before* this comment, add the following:
 
 
<pre><nowiki>
 
# The following code was added to allow degraded RAID arrays to start
 
if [ ! -e "${ROOT}" ] || ! /lib/udev/vol_id "${ROOT}" >/dev/null 2>&1; then
 
# Try mdadm and allow degraded arrays to start in case a drive has failed
 
log_begin_msg "Attempting to start RAID arrays and allow degraded arrays"
 
/sbin/mdadm --assemble --scan
 
log_end_msg
 
# If you use logical volume on raid partition, is better wait some seconds or the boot will fail!
 
sleep 10
 
fi</nowiki></pre>
 
3.a) would be better to place it in your personal configuration, because for safer-updates.
 
bash-Scripts in local-top are initiated from local-script above.
 
Create script
 
<pre><nowiki>
 
> gksudo gedit /etc/initramfs-tools/scripts/local-top/mdadm</nowiki></pre>
 
copy 3. (# The following code was added to allow degraded RAID arrays to start ...)
 
make a bash-script,
 
and change the line:
 
<pre><nowiki>
 
/sbin/mdadm --assemble --scan
 
into
 
/sbin/mdadm --examine --scan | /sbin/mdadm --assemble --scan</nowiki></pre>
 
because you mustn`t have a valid mdadm.conf in initramfs-environment.-)
 
4. Save the change and exit the editor.
 
5. Finally, update the boot image to use the updated script,
 
 
<pre><nowiki>
 
> sudo update-initramfs -u</nowiki></pre>
 
 
=== Troubleshooting ===
 
=== Troubleshooting ===
'''Swap space doesn't come up, error message in dmesg'''
+
==== Swap space doesn't come up, error message in dmesg ====
 
Provided the RAID is working fine this can be fixed with
 
Provided the RAID is working fine this can be fixed with
<pre><nowiki>
+
* sudo update-initramfs -k all -u
> sudo update-initramfs -k all -u</nowiki></pre>
+
=== Resources ===
+
* http://ubuntuforums.org/showthread.php?t=408461
+
* http://man-wiki.net/index.php/8:mdadm
+
* https://wiki.ubuntu.com/HotplugRaid Keeping your data synced and mirrored on external drives.
+
* http://en.wikipedia.org/wiki/RAID
+
* http://en.wikipedia.org/wiki/Mdadm
+
 
=== Using mdadm ===
 
=== Using mdadm ===
 
==== Checking the status of your RAID ====
 
==== Checking the status of your RAID ====
 
Two useful commands to check the status are:
 
Two useful commands to check the status are:
<pre><nowiki>
+
* cat /proc/mdstat  
cat /proc/mdstat </nowiki></pre>
+
This will show output something similar to
This will show output something similar to  
+
Personalities : [raid1] [raid6] [raid5] [raid4]
<pre><nowiki>
+
 
+
Personalities : [raid1] [raid6] [raid5] [raid4]  
+
 
md5 : active raid1 sda7[0] sdb7[1]
 
md5 : active raid1 sda7[0] sdb7[1]
      62685504 blocks [2/2] [UU]
+
62685504 blocks [2/2] [UU]
     
+
 
md0 : active raid1 sda1[0] sdb1[1]
 
md0 : active raid1 sda1[0] sdb1[1]
      256896 blocks [2/2] [UU]
+
256896 blocks [2/2] [UU]
 
+
 
md6 : active raid5 sdc1[0] sde1[2] sdd1[1]
 
md6 : active raid5 sdc1[0] sde1[2] sdd1[1]
      976767872 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
+
976767872 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
</nowiki></pre>
+
 
From this information you can see that the available personalities on this machine are "raid1, raid6, raid4, and raid5" which means this machine is setup to use raid devices configured in a raid1, raid6, raid4 and raid5 configuration.
 
From this information you can see that the available personalities on this machine are "raid1, raid6, raid4, and raid5" which means this machine is setup to use raid devices configured in a raid1, raid6, raid4 and raid5 configuration.
 
You can also see in the three example meta devices that there are two raid 1 mirrored meta devices. These are md0 and md5. You can see that md5 is a raid1 array and made up of disk /dev/sda partition 7, and /dev/sdb partition 7, containing 62685504 blocks, with 2 out of 2 disks available and both in sync.
 
You can also see in the three example meta devices that there are two raid 1 mirrored meta devices. These are md0 and md5. You can see that md5 is a raid1 array and made up of disk /dev/sda partition 7, and /dev/sdb partition 7, containing 62685504 blocks, with 2 out of 2 disks available and both in sync.
 
The same can be said of md0 only it is smaller (you can see from the blocks parameter) and is made up of /dev/sda1 and /dev/sdb1.
 
The same can be said of md0 only it is smaller (you can see from the blocks parameter) and is made up of /dev/sda1 and /dev/sdb1.
 
md6 is different in that we can see it is a raid 5 array, striped across 3 disks. These are /dev/sdc1, /dev/sde1 and /dev/sdd1, with a 64k "chunk" size which is basically a "write" size. Algorithm 2 shows it is a write algorithm patern 2 which is "left disk to right disk" writing across the array. You can see that all 3 disks are present and in sync.
 
md6 is different in that we can see it is a raid 5 array, striped across 3 disks. These are /dev/sdc1, /dev/sde1 and /dev/sdd1, with a 64k "chunk" size which is basically a "write" size. Algorithm 2 shows it is a write algorithm patern 2 which is "left disk to right disk" writing across the array. You can see that all 3 disks are present and in sync.
<pre><nowiki>
+
* sudo mdadm --query --detail /dev/md*  
sudo mdadm --query --detail /dev/md* </nowiki></pre>
+
 
( where * is the partition number)
 
( where * is the partition number)
-----
+
==== Disk Array Operation ====
[[category:CategoryInstallation]]
+
Note: You can add, remove disks or set them as faulty without stopping an array.
 +
1. To stop an array, type:
 +
 
 +
* $ sudo mdadm --stop /dev/md0
 +
* Where /dev/md0 is the array device.
 +
2. Remove a Disk from an Array
 +
 
 +
* $ sudo mdadm --remove /dev/md0 /dev/sda1
 +
* Where /dev/md0 is the array device and /dev/sda is the faulty disk.
 +
3. Add a Disk to an Array
 +
 
 +
* $ sudo mdadm --add /dev/md0 /dev/sda1
 +
* Where /dev/md0 is the array device and /dev/sda is the new disk.
 +
* Note: This is not the same as "growing" the array!
 +
4.Start an Array, to reassemble (start) an array that was previously created:
 +
* $ mdadm --assemble --scan
 +
* mdadm will scan for defined arrays and start assembling it. Use this to track its status:
 +
* $ cat /proc/mdstat
 +
=== Resources ===
 +
* http://ubuntuforums.org/showthread.php?t=408461
 +
* http://man-wiki.net/index.php/8:mdadm
 +
* https://wiki.ubuntu.com/HotplugRaid Keeping your data synced and mirrored on external drives.
 +
* http://en.wikipedia.org/wiki/RAID
 +
* http://en.wikipedia.org/wiki/Mdadm
 +
Thanks to Ubuntu 9.10 team which makes the RAID building very easy.
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2010年5月19日 (三) 22:51的最新版本

How to create RAID using Ubuntu Software RAID. Including RAID 0, 1, 5 and 6. Ubuntu 9.10 provides very easy way to build RAID. You can build a RAID system using Ubuntu user interface, requires no CLI anymore! Note: Be aware of the fragile state of RAID support in Ubuntu and what it takes to get a reliable raid setup (https://wiki.ubuntu.com/ReliableRaid), but most of them has fixed since Ubuntu 8.10.

Introduction

RAID is a method of using multiple hard drives to act as one, there are 2 purpose of RAID:

  • Expand drive capacity: RAID 0. If you have 2 x 500 GB HDD then total space become 1 TB
  • Prevent data loss in case of drive failure: RAID 1, RAID 5, and RAID 6. You can combine RAID 0 to other RAID, e.g RAID 0 + 1 become RAID 10.

There are 3 ways to create RAID:

  1. Software-RAID: Where the RAID created by software.
  2. Hardware-RAID: A special controller used to build RAID. RAID hardware faster, no CPU overload and can be used for any OS
  3. FakeRAID: Since RAID hardware is very expensive, many motherboard manufacturers use multi-channel controllers with special BIOS features to perform RAID. This implementation is faster than software RAID. Read FakeRaidHowto for details.

The RAID software included with current versions of Linux (and Ubuntu) is based on the 'mdadm' driver and works very well.

Requirements

After a successful install, you should also manually fix 2 shortcomings in the default configuration:

  • Install GRUB boot-loader on second drive (this step is not need if you use Ubuntu 9.10)
  • Update startup script to detect a failed drive

Installing

Install Ubuntu until you get to partitioning the disks SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_00.png

Partitioning the disk

Warning: the /boot filesystem cannot use any softRAID level other than 1 with the stock Ubuntu bootloader. If you want to use some other RAID level for most things, you'll need to create separate partitions and make a RAID1 device for /boot. Warning: this will remove all data on hard drives. 1. Select "Manual" as your partition method

SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_01.png 2. Select your hard drive, and agree to "Create a new empty partition table on this device ?"

SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_02.png SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_03.png 3. Select the "FREE SPACE" on the 1st drive then select "automatically partition the free space

SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_04.png SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_05.png 4. Ubuntu will create 2 partitions: / and swap, as shown below:

SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_06.png 5. On / partition select "bootable flag" and set it to "on"

SoftwareRAID?action=AttachFile&do=get&target=ubuntu_raid_06.png 6. Repeat steps 2 to 5 for the other hard drive

As you see Ubuntu 9.10 makes RAID creation very easy. No need to define partition manually anymore! Ubuntu 9.10 also use ext4 the latest Linux file system.

Configuring the RAID

  1. Once you have complete your partitioning in the main "Partition Disks" page select "Configure Software RAID"
  2. Select "Yes"
  3. Select "Create new MD drive"
  4. Select RAID type: RAID 0, RAID 1, RAID 5 or RAID 6
  5. Number of devices. RAID 0 and 1 need 2 drives. 3 for RAID 5 and 4 for RAID 6.
  6. Number of spare devices. Enter 0 if you have no spare drive.
  7. select which partitions to use. Generally they will be sda1 and sdb1 or hda1 or hdb1. Generally the numbers will match and the different letters are for different hard drives.
  8. At this point the installation may become unresponsive this is the hard drives already syncing. Repeat steps 3 to 7 with each pair of partitions you have created.
  9. Once done, select finish.

Formatting

Ubuntu 9.10 will automatically format your partitions.

Boot Loader

There are several problems reported by previous version of Ubuntu. But Ubuntu 9.10 already fixes them. In case you next HDD won't boot then simply install Grub there.

  1. grub-install /dev/sdb
  2. grub-install /dev/sdc

Boot from Degraded Disk

If default HDD fail then RAID will ask you to boot from degraded disk. In best practice, as specially if you put your server on remote area then you may make this automatically. Since Ubuntu 8.10 there is a new feature to boot automatically if default RAID disk fail. Simply:

  1. edit this file /etc/initramfs-tools/conf.d/mdadm
  2. change "BOOT_DEGRADED=false" to "BOOT_DEGRADED=true"

NB:

  • Additionally, this can be specified on the kernel boot line with the bootdegraded=[true|false]
  • You also can use #dpkg-reconfigure mdadm rather than CLI!

Now, you have completed the step of making RAID in a few minutes!

Test your RAID now!

The very importing part of RAID building is ... TESTING if your RAID works! Simply follow these step to test your RAID:

  1. shutdown your server
  2. remove the power and cable data of your first drive
  3. start your server, see if your server can boot from degraded disk!

Troubleshooting

Swap space doesn't come up, error message in dmesg

Provided the RAID is working fine this can be fixed with

  • sudo update-initramfs -k all -u

Using mdadm

Checking the status of your RAID

Two useful commands to check the status are:

  • cat /proc/mdstat

This will show output something similar to Personalities : [raid1] [raid6] [raid5] [raid4] md5 : active raid1 sda7[0] sdb7[1] 62685504 blocks [2/2] [UU] md0 : active raid1 sda1[0] sdb1[1] 256896 blocks [2/2] [UU] md6 : active raid5 sdc1[0] sde1[2] sdd1[1] 976767872 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU] From this information you can see that the available personalities on this machine are "raid1, raid6, raid4, and raid5" which means this machine is setup to use raid devices configured in a raid1, raid6, raid4 and raid5 configuration. You can also see in the three example meta devices that there are two raid 1 mirrored meta devices. These are md0 and md5. You can see that md5 is a raid1 array and made up of disk /dev/sda partition 7, and /dev/sdb partition 7, containing 62685504 blocks, with 2 out of 2 disks available and both in sync. The same can be said of md0 only it is smaller (you can see from the blocks parameter) and is made up of /dev/sda1 and /dev/sdb1. md6 is different in that we can see it is a raid 5 array, striped across 3 disks. These are /dev/sdc1, /dev/sde1 and /dev/sdd1, with a 64k "chunk" size which is basically a "write" size. Algorithm 2 shows it is a write algorithm patern 2 which is "left disk to right disk" writing across the array. You can see that all 3 disks are present and in sync.

  • sudo mdadm --query --detail /dev/md*

( where * is the partition number)

Disk Array Operation

Note: You can add, remove disks or set them as faulty without stopping an array. 1. To stop an array, type:

  • $ sudo mdadm --stop /dev/md0
  • Where /dev/md0 is the array device.

2. Remove a Disk from an Array

  • $ sudo mdadm --remove /dev/md0 /dev/sda1
  • Where /dev/md0 is the array device and /dev/sda is the faulty disk.

3. Add a Disk to an Array

  • $ sudo mdadm --add /dev/md0 /dev/sda1
  • Where /dev/md0 is the array device and /dev/sda is the new disk.
  • Note: This is not the same as "growing" the array!

4.Start an Array, to reassemble (start) an array that was previously created:

  • $ mdadm --assemble --scan
  • mdadm will scan for defined arrays and start assembling it. Use this to track its status:
  • $ cat /proc/mdstat

Resources

Thanks to Ubuntu 9.10 team which makes the RAID building very easy.