A few weeks ago, I promised that I would put my recipe here for
creating mirrored OS drives from an existing OS Drive. This recipe
combines what I learned from MANY OTHER sometimes conflicting documents
on the same subject -- documents that were probably developed for
earlier kernels and distributions.
I tried to follow the other instructions and always found that some
steps didn't work for me or weren't necessary, or that some important
steps were missing. I hope my recipe helps others who are trying to
create mirrored drives with their recent Linux distributions.
Please keep in mind the following:
1) This recipe works with recent 2.6.x kernels and recent Linux
distributions that use UDEV. Older distributions that rely on DEVFS and
that include older versions of mdadm probably will require some
variations in the steps. I tested this with Mandriva 2006 and a 2.6.16
kernel.
2) This recipe is designed for SATA drives and a motherboard with SATA
controllers that are supported by the current Linux kernels. It might
not work with all motherboards.
3) If you have IDE drives instead of SATA drives, you should substitute
/dev/hdX where I have /dev/sdX
4) Many other instructions that I read claimed that it was necessary
to create a separate boot partition in order to boot with mirrored
drives. I found that I was able to create mirrored OS drives WITHOUT a
separate boot partition. FYI -- My installation has three partitions --
the root partition / as well as a partition for swap and home.
You may have a different layout. Just go with the layout to which you
are accustomed.
5) This recipe does NOT require compiling RAID drivers or other
drivers into the kernel. It uses an initial ramdisk (initrd) to load
the required drivers during the early stages of booting up.
6) The distribution YOU use may have some important differences from
Mandriva 2006. For instance, Mandriva puts the mdadm.conf in /etc/ and
some other distributions put it in /etc/mdadm/. In addition, Mandriva
doesn't require editing any sort of initrd.conf file in order to build
a proper initrd so that it includes the required drivers. Your
distribution may require you to specify what you want to put in the initrd.
Recipe for Creating Mirrored OS Drives from Exiting OS Drive
REQUIREMENTS:
-- One or Two NEW SATA drives of the same size. If only ONE, you must
have an existing SATA drive of the SAME size that you can use as part of
your mirrored pairs.
-- A Live CD/DVD Linux Distribution such as Mandriva One or Knoppix
CAUTION:
-- It is probably best to have two NEW SATA drives in addition to an
existing SATA OS drive. However, if you decide to use your existing SATA
drive as one of your RAID drives, you should back up your existing OS
drive. That way, if you make a mistake, you can always put the current
SATA OS drive back in your system.
For Backup, I highly recommend using Acronis True Image. It's a great,
fast, and relatively inexpensive imaging product that allows you to copy
your existing OS image from one disk and restore it to another.
IF YOU WANT TO SWITCH FROM IDE TO SATA:
If you normally boot off of an IDE drive but want to switch to SATA, you
can use Acronis True Image make an image from your IDE drive and then
restore it to a SATA drive. Then, you only need to edit your /etc/fstab
and boot loader configuration file (i.e., /etc/lilo.conf) so that they
refer to /dev/sdX instead of /dev/hdX.
THE PROCEDURE
-- Assuming you already boot from a SATA drive, install a second SATA
drive. If you are going to use both drives as members of your mirrored
pairs, the NEW drive should be the same size or larger than the first
drive.
-- Boot your computer as you normally do from the SATA drive.
-- Assuming that your existing OS drive comes up as /dev/sda and that
the new drive comes up as /dev/sdb, copy the partition layout from
/dev/sda to /dev/sdb so that you have identical partition layouts on
each disk:
sfdisk -d /dev/sda | sfdisk /dev/sdb
-- Set the partition type on all /dev/sdb partitions to raid autodetect
-- type fd, except on any EXTENDED PARTITION. For example, assuming
your root (/) partition is currently on /dev/sda1, and you have an
extended partition on 2, and two logical partitions (swap and home) on 5
and 6:
fdisk /dev/sdb
ENTER t
SELECT 1 for partition 1
ENTER fd for partition type
Repeat for partitions 5 and 6
-- Shutdown your computer
-- Reboot using a Live CD/DVD distribution (i.e., Mandriva One, or Knoppix)
-- Open a terminal (i.e., KDE's Konsole) and become root.
-- Create degraded mirrored RAIDS on /dev/sdb1, /dev/sdb5, /dev/sdb6
(or on ALL partitions that are part of your OS drive and that you want
to mirror). The basic idea is that your motherboard probably only has
built-in support for two SATA drives. In order to copy your existing OS
from the current