Software RAID and LVM2 on Slackware 10.2 |
IntroductionLately I've been tinkering with the idea of increasing the reliability of my server, and the first thing to do, although it doesn't increase uptime it does make sure no important data is lost due to hard-drive failure, is set up RAID. Most computers nowadays come with RAID-controllers directly implemented on the motherboard, but these are usually badly made knockoffs just barely fitting the description hardware-RAID (for instance those implemented in Nvidia nForce 3/4 chipsets).The only real option with these things is simply to use software RAID instead that while having comparative performance supports a lot more features, which if you have the disks to use RAID-level 5 is a mentionable step up. In order to make the solution a little more flexible I'm also going to use LVM2 to manage the disk space on the RAID. Table of Contents0. HardwareThe computer I'm using for the purpose of this document has the following specifications, and while not everything is top dollar equipment it probably compares to most generic homebuilt Linux desktops these days:
1. Software RAIDI've recently purchased two new Western Digital Serial ATA disks that I plan to use in a RAID-mirror configuration, and my computer automatically loaded the correct modules needed to use these via the SATA-controller so in a comparable configuration there shouldn't be any problems. Software RAID is set-up and configured using the mdadm-utility (package is called "mdadm 2.1-i486-1"), but first we'll need to set up two partitions, one on each drive in the mirror (/dev/sda and /dev/sdb on my system), of equal size (I used 100GB for this purpose) with the partition type set to "Linux raid autodetect" - see the image below as to how this looks like in cfdisk (command used was "cfdisk /dev/sdb").cfdisk /dev/sda
1.0 Creating the arrayWe're now ready to set-up software RAID using the previously created partitions (make sure you've loaded the module "dm_mod") using the mdadm-utility.mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1The RAID will now have been created, but it'll take a long way for the array to be successfully built and while you could strictly speaking continue working on it until it's done I'd recommend that you wait just incase something bad happens. You can monitor the process by running the following command: mdadm --detail /dev/md0 1.1 Software RAID configurationThe RAID device should now be fully operational and ready for use, but as it is now all details about it will be lost after a reboot so we'll have to make some configuration changes in order to make the device available at boot. The first step is editing the file "/etc/mdadm.conf" and make sure it lists all the devices used in the RAID by adding a line such as the following:DEVICE /dev/sda1 /dev/sdb1We also need to specify the actual RAID-configuration and while this is a bit harder to do manually we can simply make this happen automatically by giving the following command: mdadm --examine --scan >> /etc/mdadm.conf 1.2 Altering Slackware 10.2 so that RAID-volumes can be mounted at bootThe last and final thing we now need to do is to make sure that Slackware starts the RAID before we try to use it as part of a LVM-configuration and in order to do that we need to edit the file /etc/rc.d/rc.S and add the following section just before the initialization of the Logical Volume Manager:#This should now allow any RAID-volumes to be used and mounted automatically via "/etc/fstab". 2. Logical Volume Manager, version 2 (LVM2)Setting up LVM is thankfully a lot easier, but you should first make sure that LVM version 1 isn't still installed on the system (package is named "lvm 1.0.8-i486-1") and if it is start by removing it. Packages for LVM2 aren't directly available for Slackware 10.2, but the ones in the extra packages directory for Slackware-current are and they can be used on this version of Slackware as well - download and install the packages "lvm2-2.02.09-i486-1.tgz" and "device-mapper-1.02.09-i486-1.tgz" from your local mirror, or just get them from the Norwegian mirror.From this point on LVM2 is heavily documented all over the web and there really isn't that much of a need for detailed descriptions of the configuration I'm using, but the following se of commands will set things off by first initializing LVM2 on the RAID-volume, creating a volume group on top of that and finally create an LVM-volume we'll call "mirror" that we'll finally format using the Reiser filesystem. # Initialize LVM2 on our RAID-deviceThat should be all that there is to it so enjoy your new flexible LVM2-system with added reliability of a RAID1 (mirroring) configuration. 3. Relevant links |