Differences between revisions 3 and 74 (spanning 71 versions)
← Revision 74 as of 2008-08-06 17:00:01
|Deletions are marked like this.||Additions are marked like this.|
|Line 1:||Line 1:|
== How to configure ubuntu to access a hardware fakeraid ==
This is my first time editing a wiki, so bear with me. This page is a work in progress. I have spent the last week getting ubuntu breezy preview installed on my via sata fakeraid and finally have the system dual booting winxp and ubuntu linux on a raid-0 ( stripe ) between two 36 gig 10,000 rpm WD raptor hard drives. I thought I would create a howto to describe how I did it so that others may benefit from my work.
=== What is it? ===
In the last year or two a number of hardware products have come on the market claiming to be IDE or SATA raid controllers. Virtually all of them are not really hardware raid controllers. Instead they are simply a multi channel disk controller that has special bios and drivers for the OS to perform the software raid functions. This has the effect of giving the appearence of a hardware raid, because the raid configuration is set up using a bios setup screen and the system can be booted from the raid.
Under windows, you must supply a driver floppy to the setup process so windows can access the raid. Under linux, the hardware is seen for what it is, which is simply a multi channel IDE/SATA controller. What this means is that if you have multiple disks configured as a raid, linux sees individual disks. This page describes how to get linux to see the raid as one disk, and boot from it. In my case, I use a raid-0 configuration, but this should also apply to raid-1 and raid-5.
=== Background ===
In recent years there has been a trend to try and pull a bunch of code out of the kernel and into EarlyUserSpace. This includes stuff like nfsroot configuration, md software raid, lvm, conventional partition/disklabel support, and so on. Early user space is set up in the form of an initramfs which the boot loader loads with the kernel, and this contains user mode utilities to detect and configure the hardware, mount the correct root device, and boot the rest of the system.
Hardware fakeraid falls into this category of operation. A device driver in the kernel called device mapper is configured by user mode utilities to access software raids and partitions. If you want to be able to use a fakeraid for your root filesystem, your initramfs must be configured to detect the fakeraid and configure the kernel mapper to access it.
=== The How To ===
The key areas of work that needs done are:
1. Installing ubuntu
1. Installing lilo
1. Configuring the initramfs to boot the system
== Installing Ubuntu ==
The standard setup and livecds do not yet contain support for fakeraid. I used the livecd to boot up, and used the package manager to download the dmraid package from the universe repository. You will need to enable packages from universe in the settings of synaptic to see the package.
Once the package is installed, it will detect the raid device and any existing partitions on it, and create devices for them. In my case, initially dmraid created /dev/mapper/via_hfciifae and /dev/mapper/via_hfciifae1. These devices corresponded to my raid itself, and the single partition on it that existed at the time, which was my winxp ntfs partition. You should be able to fire up gparted and select the raw device to partition.
You can use gparted to create and delete partitions as you see fit, but at this time, it can not refresh the partition table after it modifies it, so you will need to change the partitions, then manually run dmraid -ay from the command prompt to detect the new partitions, and then refresh gparted before you can format the partition.
I needed to resize my existing NTFS partition to make space for ubuntu. Gparted currently can not do this on the mapper device so I had to use the ntfsresize program from the command line. Note that ntfsresize only resizes the filesystem, not the partition, so you have to do that manually. Use ntfsresize to shrink the filesystem, note the new size of the filesystem in sectors, then fire up fdisk. Switch fdisk to sector mode with the 'u' command. Use the 'p' command to print the current partition table. Delete the partition that you just resized and recreate it with the same starting sector. Use the new size of the filesystem in sectors to compute the ending sector of the partition. Don't forget to set the partition type to the value it was before. Now you should be able to create a new partition with the free space. In my case, I created an extended partition with 3 logical partitions inside. I made a 50 meg partition for /boot, a 1 gig partition for swap, and the rest for the root.
After saving the new partition table and exiting fdisk, run dmraid -ay again to detect the new partitions. In my case I had the following in /dev/mapper:
via_hfciifae -- the raw raid volume
via_hfciifae1 -- the NTFS partition
via_hfciifae5 -- /boot
via_hfciifae6 -- swap
via_hfciifae7 -- /
Now format your filesystems. In my case I ran an mke2fs on /dev/mapper/via_hfciifae5 and mkreiserfs on /dev/mapper/via_hfciifae7. Once that is done you can mount the new target filesystems. In my case I did:
mount -t reiserfs /dev/mapper/via_hfciifae7 /target
mount -t ext2 /dev/mapper/via_hfciifae5 /target/boot
Now you need to bootstrap a ubuntu system on the new volume. For this you will need to install the debootstrap package. Run debootstrap and have it install to /target. After the debootstrap, copy /etc/sources.list to /target/etc/sources.list.
Now chroot /target and run apt-get update, then apt-get install ubuntu-base. This will install most of the common packages for a text ubuntu system. If you also want the gui desktop environment, apt-get install ubuntu-desktop.
== Installing Lilo ==
I had to make a one line patch to the lilo sources to get this to work. I am working with the lilo maintainer right now on the issue and hopefully the next lilo release will have this resolved. Other than that, setting up lilo.conf is the tricky part to get it working with the fakeraid.
My lilo.conf file looks like this:
insert lilo.conf here
The directive use-static-bios tells lilo to not try to probe the disks and figure out the partition layout. This is needed because lilo does not understand mapper devices and this probe will fail. When you use this option, the disk= directives become required. You have to explain to lilo exactly where the partitions are on what bios disk device.
Disk 0x80 is the first hard disk bios detects. The fakeraid bios makes it look like the raid is a single big disk at device 0x80, so we must tell lilo to use device 0x80. Lilo also needs to know the starting sectors of the partitions, which you can get from fdisk.
== Configuring the initramfs ==
For the kernel to recognize the raid you have to run the dmraid utility to configure the mapper device. To do this, we need to add dmraid to the initramfs. You will find the initramfs installed in /boot/initrd.something. This file is a gzipped cpio archive. Make a new temp directory and change to it. From there, run:
gunzip -c /boot/initrd.something | cpio -i
That will extract the files in the initramfs to your temp directory. Now place a copy of the dmraid program in the bin directory of the initramfs. Create a new file in scripts/local-top that looks like this:
Now repack the initramfs. Do this from the temp directory holding the filesystem:
find * | cpio -o -H newc | gzip -9 -c > /boot/initrd.something-dmraid
Now just make sure your lilo.conf points to this new image with it's initrd= line, and run lilo.
|#REFRESH 0 http://help.ubuntu.com/community/FakeRaidHowto|