Introduction

This describes how to install Debian Woody on a RAID-1 system (mirrored disks), with RAID being implemented in the kernel rather than in a dedicated RAID controller. Note that some knowledge of RAID1 under Linux is assumed.

What you will need

A note on BIOS settings

If you have identical disks, try to ensure that the system BIOS is set such that Linux sees both disks with the same cylinder/head/sector readings. This can be checked by booting the Debian installation CD and running cfdisk on each disk, and noting how it reports the C/H/S settings. If they do differ for identical disks, try changing the disk mapping in the BIOS (Normal addressing or possibly CHS seem to work best). Sometimes zeroing the first few blocks of both disks (dd if=/dev/zero of=/dev/hda bs=512 count=10000f) can help.

Assumptions

Your system has /dev/hda and /dev/hdc, and they are identical drives (and the geometry is reported as such by the BIOS). If you are using different devices (eg, /dev/sda and /dev/sdb) then just substitute appropriately.

HOWTO!

1. Boot the Debian installation CD and proceed as usual to disk partitioning and partition /dev/hda. You will need at least two partitions of a size large enough to hold a Debian base installation. Personally, I usually use drives of at least 80Gb, and I partition them as follows:

 /dev/hda1 - / - 5Gb
 /dev/hda2 - swap - 512Mb
 /dev/hda3 - /tmp - 1Gb
 /dev/hda5 - /var - 10Gb
 /dev/hda6 - /home - remainder

You can, of course, use smaller partitions, but for the purposes of this HOWTO I'm going to assume that you have the above partitioning scheme, and that both / (root) and /home are at least 1Gb in size.

The filesystem used is not important, but ensure that all partitions on /dev/hda have valid filesystems or swap signatures. The partition types should be 0x83 except for the swap partition, which should be 0x82.

2. When mounting the root partition for the installation, use a partition other than /dev/hda1. In this HOWTO I will use /dev/hda5. At this point, do not specify any other partitions; rather, place the entire installation on /dev/hda5.

3. Continue the installation to completion, carry out the first reboot and configure the system. Do not install any additional packages yet. At this point you should have a minimal Debian system which differs from a normal system only in that it is installed in /dev/hda5 rather than the more traditional /dev/hda1.

4. The default Debian kernel include RAID modules, but if we are to boot from a RAID1 parition we will need to have the RAID1 drivers built in to the kernel, and thus the kernel needs to be rebuilt. If you need help with this, I suggest following the instructions at http://www.debian.org/doc/manuals/reference/ch-kernel.en.html#s-kernel-debian and at LinuxHints/KernelCompiling, but note that you will need to install initrd-tools in addition to the packages mentioned there. The only change you must make to the kernel configuration file is under the section "Multi-device support (RAID and LVM)", where you must change both "RAID support" and "RAID-1 (mirroring) mode" from modules ("<M>") to built-in ("<*>"). Rebuild and install the kernel, and reboot.

  * Note: Since this is from a base install you will also need to install 'build-essential' which is 
not mentioned on the linked page (pretty much  assumed really!). When it is not installed 
the error doesn't specifically request it, but if you read the output from the make 
command you see the real cause.

5. Change all partition types on the boot disk to 0xfd, regardless of filesystem used (including the swap partition)

6. Create partitions on /dev/hdc. If the disks are identical, check that the kernel sees them that way too by comparing the output of sfdisk -g /dev/hda and sfdisk -g /dev/hdc. If the kernel does see them as identical then the partition layout can be copied from /dev/hda to /dev/hdc with:

  sfdisk -d /dev/hda | sfdisk /dev/hdc
  
If the disks are not identical, manually create the partitions on `/dev/hdc` (as type `0xfd`). They must correspond to the partitions on `/dev/hda`, and must not be smaller than the corresponding partition on /dev/hda.

7. Install raidtools2: apt-get install raidtools2

8. Create /etc/raidtab - see raidtab(5). Mine is shown below, and the format should be reasonably intuitive:

 # /
 raiddev                /dev/md0
 raid-level             1
 nr-raid-disks          2
 chunk-size             32
 persistent-superblock  1
 device                 /dev/hda1
 raid-disk              0
 device                 /dev/hdc1
 raid-disk              1

 # swap
 raiddev                /dev/md1
 raid-level             1
 nr-raid-disks          2
 chunk-size             32
 persistent-superblock  1
 device                 /dev/hda2
 raid-disk              0
 device                 /dev/hdc2
 raid-disk              1

 # /tmp
 raiddev                /dev/md2
 raid-level             1
 nr-raid-disks          2
 chunk-size             32
 persistent-superblock  1
 device                 /dev/hda3
 raid-disk              0
 device                 /dev/hdc3
 raid-disk              1

 # /var
 raiddev                /dev/md3
 raid-level             1
 nr-raid-disks          2
 chunk-size             32
 persistent-superblock  1
 device                 /dev/hda5
 raid-disk              0
 device                 /dev/hdc5
 raid-disk              1

 # /home
 raiddev                /dev/md4
 raid-level             1
 nr-raid-disks          2
 chunk-size             32
 persistent-superblock  1
 device                 /dev/hda6
 raid-disk              0
 device                 /dev/hdc6
 raid-disk              1

9. Create the /dev/md0 device with:

  '''`mkraid /dev/md0`'''
  
You may need to use the -f (`--force`) switch depending upon what filesystems may have been installed before. Once the command completes, check the state of the RAID system with:

  cat /proc/mdstat
  
This should show you that `/dev/md0` is active, and probably resyncing.

10. Create the required filesystem on /dev/md0 (for example, mke2fs -j /dev/md0 for an ext3 filesystem).

11. Edit /etc/lilo.conf and change the root= line to root=/dev/md0 (leave the boot line as boot=/dev/hda).

12. Copy your one-partition Debian installation to /dev/md0:

  # mount /dev/md0 /mnt
  # tar -C / -cvlf - . | tar -C /mnt -xf -

13. chroot to your new root parition and run lilo:

  # chroot /mnt
  # lilo
  # exit

14. Edit /mnt/etc/fstab and change the root device from /dev/hda5 to /dev/md0, and the swap device from /dev/hda2 to /dev/md1.

15. Check that the RAID disk has finished resyncing (with cat /proc/mdstat)

16. Unmount /dev/md0 and stop RAID:

  # umount /dev/md0
  # raidstop /dev/md0
  
17. Reboot

You should now have a system running on /dev/md0 (check with df and also with cat /proc/mdstat).

Things to do next:

KeithEdmunds, July 2004

LinuxHints/InstallWoodyOnRAID1 (last edited 2006-02-23 16:02:35 by 194)