SoftwareRaid

From SystemImager

Jump to: navigation, search

Contents

HOWTO: using Software-RAID with SystemImager

Overview

The Linux kernel software RAID driver (called md, for "multiple disk") implements a software layer that allows to share or replicate data among multiple hard drives or partitions.

RAID stands for Reduntant Array of Independent (or Inexpensive) Disks; it is used frequently on servers, to combine several physical disks into one larger "virtual" device, for performance improvements, and redundancy.

RAID can be implemented also in dedicated hardware or using hybrid solutions (partly hardware and partly software. In general hardware RAID can guarantee better performance, since there is a special-purpose RAID controller that reduce the load of the CPU, but obviously software RAID is cheaper because you can use all the common IDE/ATA, SCSI, Fibre Channel, etc. controllers and in some cases (depending of the CPU speed) software RAID can be faster than hardware RAID.

Swap on software RAID volumes

There's no reason to use software RAID to improve swap performances. The kernel itself can stripe swapping on several devices, if you give them the same priority in /etc/fstab:

 /dev/sda2     swap     swap     defaults,pri=-1        0 0
 /dev/sdb2     swap     swap     defaults,pri=-1        0 0
 /dev/sdc2     swap     swap     defaults,pri=-1        0 0
 /dev/sdd2     swap     swap     defaults,pri=-1        0 0

On the other hand software RAID with redundancy (eg. RAID1, RAID5, etc) can be used for maximum reliability; in this way a process swapping on a faulty device will survive and continue to swap without problems.

Software RAID and SystemImager

SystemImager supports software RAID volumes. When you setup a golden client and run the command si_prepareclient (see man si_prepareclient) the software RAID configuration is cloned to be exported to any number of other clients.

In versions previous to 3.7.x software RAID informations are taken directly from the /etc/raidtab file in the chrootable golden client's filesystem on the image server.

Starting from 3.7.x the Soft-RAID configuration is completely stored into the file /etc/autoinstallscript.conf in the golden client's filesystem. With si_getimage the file is automatically propagated on the image server, under the chrootable filesystem of the image (/var/lib/systemimager/<IMAGENAME>/etc/systemimager/autoinstallscript.conf).

Future customizations can be done directly in the autoinstallscript.conf stored into the chrootable image.

When you manually edit a software RAID configuration remember that:

  1. a partition can be used in a Soft-RAID disk only if you enable the flag raid
  2. to assign a list of partitions to a Soft-RAID disk use the attribute "devices" of the <raid /> element
  3. define all the Soft-RAID stuff inside the <raid /> element

The following example shows an autoinstallscript.conf file that contains software RAID configurations (IMPORTANT: it works only with versions >= 3.7.4):

 <config>
   <disk dev="/dev/sda" label_type="msdos" unit_of_measurement="MB">
     <part  num="1"  size="1027"  p_type="primary"  p_name="-"  flags="boot,raid" />
     <part  num="2"  size="*"  p_type="primary"  p_name="-"  flags="raid" />
   </disk>
   <disk dev="/dev/sdb" label_type="msdos" unit_of_measurement="MB">
     <part  num="1"  size="1027"  p_type="primary"  p_name="-"  flags="boot,raid" />
     <part  num="2"  size="*"  p_type="primary"  p_name="-"  flags="raid" />
   </disk>
   <disk dev="/dev/sdc" label_type="msdos" unit_of_measurement="MB">
     <part  num="1"  size="1027"  p_type="primary"  p_name="-"  flags="raid" />
     <part  num="2"  size="*"  p_type="primary"  p_name="-"  flags="raid" />
   </disk>
   <disk dev="/dev/sdd" label_type="msdos" unit_of_measurement="MB">
     <part  num="1"  size="1027"  p_type="primary"  p_name="-"  flags="raid" />
     <part  num="2"  size="*"  p_type="primary"  p_name="-"  flags="raid" />
   </disk>
 
   <raid name="/dev/md0"
       raid_level="raid1"
       raid_devices="2"
       spare_devices="0"
       persistence="yes"
       devices="/dev/sda1 /dev/sdb1"
   />
 
   <raid name="/dev/md1"
       raid_level="raid1"
       raid_devices="2"
       spare_devices="0"
       persistence="yes"
       devices="/dev/sda1 /dev/sdb1"
   />
 
   <raid name="/dev/md2"
       raid_level="raid5"
       raid_devices="4"
       spare_devices="0"
       persistence="yes"
       layout="left-asymmetric"
       devices="/dev/sda2 /dev/sdb2 /dev/sdc2 /dev/sdd2"
   />
 
   <fsinfo  line="10" real_dev="/dev/md2" mp="/"  fs="reiserfs" options="acl,user_xattr" dump="1" pass="1" />
   <fsinfo  line="20" real_dev="/dev/md0" mp="/boot"  fs="reiserfs" options="acl,user_xattr" dump="1" pass="2" />
   <fsinfo  line="30" real_dev="/dev/md1" mp="swap"  fs="swap" options="pri=42" dump="0" pass="0" />
   <fsinfo  line="40" real_dev="devpts" mp="/dev/pts"  fs="devpts" options="mode=0620,gid=5" dump="0" pass="0" />
   <fsinfo  line="50" real_dev="proc" mp="/proc"  fs="proc" options="defaults" dump="0" pass="0" />
   <fsinfo  line="60" real_dev="usbfs" mp="/proc/bus/usb"  fs="usbfs" options="noauto" dump="0" pass="0" />
   <fsinfo  line="70" real_dev="sysfs" mp="/sys"  fs="sysfs" options="noauto" dump="0" pass="0" />
   <fsinfo  line="80" real_dev="/dev/dvd" mp="/media/dvd"  fs="subfs" options="fs=cdfss,ro,procuid,nosuid,nodev,exec,iocharset=utf8" dump="0" pass="0" />
   <fsinfo  line="90" real_dev="/dev/fd0" mp="/media/floppy"  fs="subfs" options="fs=floppyfss,procuid,nodev,nosuid,sync" dump="0" pass="0" />
   <fsinfo  line="100" real_dev="home:/home" mp="/home"  fs="nfs" options="rw,rsize=8192,wsize=8192,timeo=14,intr,bg,soft,sync" dump="0" pass="0" />
 
   <boel devstyle="static"/>
 
 </config>

LVM over Software RAID

LVM is the solution to some partitioning limits. Unfortunately LVM does not provide redundancy functionalities (i.e. RAID1 or RAID5). On the other hand RAID provides redundancy of data but does not allow dynamic resizing and a software RAID disk cannot be partitioned like ordinary disks.

These limits can be surpassed using LVM on top of RAID disks (either hardware or software). Software RAID compared to hardware RAID needs additional configurations in your system, since the kernel (that implements RAID functionalities) must know the block devices to use and the particular RAID details. On the other hand the hardware solution is more expensive than software RAID, because you need to but a controller that implements in hardware the RAID functionalities.

SystemImager stores the software RAID configuration in the usual file /etc/autoinstallscript.conf. Cloning this kind of configuration from a golden client is supported from release 3.7.x. For the other versions you need to manually create an autoinstallscript.conf template.

To assign a software RAID disk to a LVM volume group use the attribute lvm_group to the RAID disk definition in the <raid /> section (see man autoinstallscript.conf for more details).

The following example shows how to create LVM volumes on top of a software RAID volume:

 <config>
   <disk dev="/dev/sda" label_type="msdos" unit_of_measurement="MB">
     <part  num="1"  size="1027"  p_type="primary"  p_name="-"  flags="boot,raid" />
     <part  num="2"  size="*"  p_type="primary"  p_name="-"  flags="raid" />
   </disk>
   <disk dev="/dev/sdb" label_type="msdos" unit_of_measurement="MB">
     <part  num="1"  size="1027"  p_type="primary"  p_name="-"  flags="boot,raid" />
     <part  num="2"  size="*"  p_type="primary"  p_name="-"  flags="raid" />
   </disk>
   <disk dev="/dev/sdc" label_type="msdos" unit_of_measurement="MB">
     <part  num="1"  size="1027"  p_type="primary"  p_name="-"  flags="raid" />
     <part  num="2"  size="*"  p_type="primary"  p_name="-"  flags="raid" />
   </disk>
   <disk dev="/dev/sdd" label_type="msdos" unit_of_measurement="MB">
     <part  num="1"  size="1027"  p_type="primary"  p_name="-"  flags="raid" />
     <part  num="2"  size="*"  p_type="primary"  p_name="-"  flags="raid" />
   </disk>
   
   <raid name="/dev/md0"
       raid_level="raid1"
       raid_devices="2"
       spare_devices="0"
       persistence="yes"
       devices="/dev/sda1 /dev/sdb1"
   />
   
   <raid name="/dev/md1"
       raid_level="raid1"
       raid_devices="2"
       spare_devices="0"
       persistence="yes"
       devices="/dev/sda1 /dev/sdb1"
   />
   
   <raid name="/dev/md2"
       raid_level="raid5"
       raid_devices="4"
       spare_devices="0"
       persistence="yes"
       layout="left-asymmetric"
       lvm_group="systemvg"
       devices="/dev/sda2 /dev/sdb2 /dev/sdc2 /dev/sdd2"
   />
   
   <lvm>
       <lvm_group name="systemvg" phys_exent_size="4096K">
           <lv name="rootlv" size="1024M" />
           <lv name="optlv" size="1024M" />
           <lv name="tmplv" size="1024M" />
           <lv name="usrlv" size="5120M" />
           <lv name="varlv" size="2048M" />
       </lvm_group>
   </lvm>
   
   <fsinfo  line="10" real_dev="/dev/systemvg/rootlv" mp="/"  fs="reiserfs" options="acl,user_xattr" dump="1" pass="1" />
   <fsinfo  line="20" real_dev="/dev/md0" mp="/boot"  fs="reiserfs" options="acl,user_xattr" dump="1" pass="2" />
   <fsinfo  line="30" real_dev="/dev/systemvg/optlv" mp="/opt"  fs="reiserfs" options="acl,user_xattr" dump="1" pass="2" />
   <fsinfo  line="40" real_dev="/dev/systemvg/tmplv" mp="/tmp"  fs="ext2" options="acl,user_xattr" dump="1" pass="2" />
   <fsinfo  line="50" real_dev="/dev/systemvg/usrlv" mp="/usr"  fs="reiserfs" options="acl,user_xattr" dump="1" pass="2" />
   <fsinfo  line="60" real_dev="/dev/systemvg/varlv" mp="/var"  fs="reiserfs" options="acl,user_xattr" dump="1" pass="2" />
   <fsinfo  line="70" real_dev="/dev/md1" mp="swap"  fs="swap" options="pri=42" dump="0" pass="0" />
   <fsinfo  line="80" real_dev="devpts" mp="/dev/pts"  fs="devpts" options="mode=0620,gid=5" dump="0" pass="0" />
   <fsinfo  line="90" real_dev="proc" mp="/proc"  fs="proc" options="defaults" dump="0" pass="0" />
   <fsinfo  line="100" real_dev="usbfs" mp="/proc/bus/usb"  fs="usbfs" options="noauto" dump="0" pass="0" />
   <fsinfo  line="110" real_dev="sysfs" mp="/sys"  fs="sysfs" options="noauto" dump="0" pass="0" />
   <fsinfo  line="120" real_dev="/dev/dvd" mp="/media/dvd"  fs="subfs" options="fs=cdfss,ro,procuid,nosuid,nodev,exec,iocharset=utf8" dump="0" pass="0" />
   <fsinfo  line="130" real_dev="/dev/fd0" mp="/media/floppy"  fs="subfs" options="fs=floppyfss,procuid,nodev,nosuid,sync" dump="0" pass="0" />
   <fsinfo  line="140" real_dev="home:/home" mp="/home"  fs="nfs" options="rw,rsize=8192,wsize=8192,timeo=14,intr,bg,soft,sync" dump="0" pass="0" />
 
   <boel devstyle="static"/>
 
 </config>

See also

RAID

RAID levels

See [1].

LVM over RAID


Righi 10:09, 20 September 2006 (CDT)

Personal tools