Installing with Raid on Slackware 12.0+
This article will attempt to assist with installing slackware <version 12.0 and up> using Linux software raid. It is assumed the reader is already familiar with the various raid levels and also the difference between software and hardware raid.
Before you start, please read this important note:
You will be performing operations on your hard disks that will destroy some or in fact all of the data on those drives. Do not attempt to follow these instructions on an existing machine expecting the data to stay intact.
**You have been warned!**
When connecting disks to your computer you should (where possible) attach your drives to seperate controllers (this can be ignored for SCSI drives) or create (raid0 and raid1) sets from opposing drives. For example if you have four drives attached to an IDE motherboard you should create arrays from " /dev/hda & /dev/hdc" or "/dev/hdb & /dev/hdd".
Once you have your hardware set up you are ready to start the installation. The first thing to do after booting from your favourite install media is partitioning your disks. First you might want to be sure all your disks are present with
This should give you a partition listing of all the usable disks on your system. For the sake of simplicity we will assume there are two drives /dev/hda(primary master) and /dev/hdc(secondary master). After deciding on a partition layout begin by partitioning the first drive (use cfdisk if you are not comfortable with fdisk).
You will need at minimum two partitions, one swap and one for / , as an exercise we will also create a third partition that will be mounted as /cache (squid cache directory) during the install. So go ahead, create the partitions and toggle them as follows.
/dev/hda1 (type fd) Linux Raid Autodetect
/dev/hda2 (type fd) Linux Raid Autodetect
/dev/hda3 (type 82) Swap
After writing changes to the first disk we need to replicate the layout for the matching disk in the set. This can be easily done with sfdisk like this
sfdisk -d /dev/hda |sfdisk /dev/hdc
You should now have two disks with identical partition schemes. Now it's time to create the raid sets /dev/md0 (raid1 and /dev/md1 (raid0) using the following commands:
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/hd[ac]1
mdadm --create /dev/md1 --level=0 --raid-devices=2 /dev/hd[ac]2
Details of the raid devices can be had with:
mdadm -D /dev/md[0-9] (/dev/md0 for a single device)
Setup:If all looks good you can continue the installation with the "setup" command. When you get to the "Choosing Destination" screen choose /dev/md0 for / and then select /dev/md1 to be mounted on /cache allow setup to format these with your chosen filesystem (defaults are fine) and continue with the install in the usual manner.
Mdadm Config:Before rebooting into your shiney new system there are still a couple of steps to perform. First we'll add our raid info to mdadm.conf with the following:
mdadm -D --scan >> /mnt/etc/mdadm.conf less /mnt/etc/mdadm.confRead this file as it has some important information and examples listed. Go to the end of the file and you will see the two lines we just added.
Monitoring:Mdadm can also monitor your arrays for you, either emailing you or performing some predetermined action. If you want to be emailed you will need to provide an email address in mdadm.conf. You can start the monitor in daemon mode with something along these lines:
mdadm --monitor --daemonise /dev/md[0-9] > /var/run/mdadmI've provided an rc.mdadm file (in the resources section below) that might help starting and stopping the monitor. Note:If you call this at boot-up via rc.local or similar please be sure to also add it to your shutdown scripts or you may end up with a stale PID file.
Boot Manager:As we are installing root on raid1 we will have to use Lilo as our boot manager (besides grub just doesn't turn my crank). If you want you can let lilo install automatically (we'll be changing this later), install to the MBR and run right through to the end of the install. Our final step is to enable lilo to boot from either disk in case of faliure. Chroot into the mounted system with:
chroot /mnt vi /etc/lilo.conf
Edit the "boot" directive and add a "raid-extra-boot" line to suit your drive layout like this:
boot = /dev/md0
raid-extra-boot = "/dev/hda, /dev/hdc"
(ignore any warnings unless fatal) and exit the chroot with "exit".
You may now sacrifice $PAGAN_OBJECT to $FAVOURITE_DIETY and reboot into your newly installed Slackware on Raid.
Closing:If you are re-using an existing array or your first attempt didn't go as planned, before running setup you can activate your array with the following command:
mdadm -A /dev/md0 /dev/hda1 /dev/hdc1