Sunday 23 December 2007

Linux - Ubuntu RAID, Modules, my NAS and Fun

Ahh to be minimalist.

It all started over 3 months ago. I have taken to decluttering our house, a personal goal. (I should have set a KPI or two). One task which leads me down this path is digitizing my music and movies.

Many years ago, Sara and I decided to never rent another DVD, but to buy them. We don't buy the latest, unless we "really want it" but will buy the DVD's on special etc, or ex-rentals. Needless to say, from the past 3 years of DVD buying we have a very impressive collection, tipping the 200 mark. Digitising this lot of DVDs has caused a ripple into the Linux world. As you can gather, it takes up lots of space.

To start with, I got rid of some old servers, but kept their hard drives, as my goal is (has been) to setup a home NAS (Network Attached Storage) as the central location for all CDs and DVDs.

So, sitting in front of me is the glorious resurrected "icemaster" (i have to find my chroming again). I have the usual mechano (tip for extending drive bays) and the following drives. 40G x 3, 80G x 3 1 x 160G and 1 x 200G.

My layout is essentially to have a 40G RAID1 / and the rest in LVM as RAID5 devices (split up by like sized partitions).

To have so many drives, of course I needed to extend the IDE channels. (not upgrading to SATA yet.. maybe another few years). I purchased off eBay (new) 2 ITE 8212 IDE RAID cards. The Linux module these use is the it821x or, in the newer Ubuntu 7.10 series, the libata based pata_it821x module. This is where the fun begins.

The card supports RAID0, RAID1, RAID1+0 and JBOD, and just a standard IDE bus. I wanted the latter as I am doing all the RAID in software using the mdadm tools. (very nice).

I have been bouncing around with a few hurdles, and I will detail them each in turn, and how I have solved the, I am sure someone will come up with a similar problem.

So to give a rundown on the hardware we are using.

It's a P4 1.8Ghz, 256M RAM (yes is low spec, but it doesn't need to crunch galaxies, just serve files).
I have a Wireless RT61 based Network Card. (used to always user the rt2x00 serialmonkey module.
There is the standard USB and AGP display card, and an extra 10/100 NIC (8139too if I recall).

Problem #1 - noticing the sd[*] instead of hd[*]
So when I first dived into installing Ubuntu 7.10, I noticed that my IDE harddrives were now appearing as /dev/sd[a-z] drives, instead of the older /dev/hd[a-z] devices. This is now because of the new libata subsystem, supporting PATA and SATA (and SCSI ??) drives. This had a little flow on effect, but largely okay. (just a symantec changed, and I like it actually)

Problem #2 - Recognising the IT8212 PCI RAID Controller.
My first figured I would install onto one of the 40G hard drives, non RAID1 and standard swap of 2G and then setup my RAID and go from there. As I started before the IT8212 cards arrived from Hong Kong (yes it was cheaper then walking to the hardware shop), I actually setup a 150G RAID on booting 40G partition and transferred all my movies and music (and Gigs of data) onto the RAID array. This was on the 2 IDE buses, ie, no CDROM (DVD) after the initial install.

.. then the cards arrived.

The IT8212 by default, in Ubuntu uses the pata_it821x module. In older documentation people have asks some odd questions of this device, but it all seemed to centre around it being used as a RAID controller, ie doing RAID in hardware (good) , but I am using RAID5, which it didn't support.


On first boot, only the primary drives showed up. ie, if the it8212 had a 80G,40G and 200G,160G. Then linux would detect the 80G and 200G only. (odd I thought, must be config).

So into the BIOS of the card, and changed the config to IDE, from RAID (stripe).
Come back out, reboot Linux. no change.

Problem #3 - detected order of the /dev/sd[a-z] changed
Now, I'll pause for a moment from probem #2 and describe #3. when the drives were plugged in, my two boot drives (2 x 40G) on the first IDE bus, were moved from sda and sdb to AFTER the detected drives on the PCI card. For example.

before the IT8212 is plugged in the drives were
/dev/sda (40G)
/dev/sdb (40G)
/dev/sdc (DVD Drive)

After plugging in the card (with the problem #2 still occuring) you see the following

/dev/sda (80G)
/dev/sdb (200G)
/dev/sdc (40G)
/dev/sdd (40G)
/dev/sde (DVD Drive)

Now, the fix to this problem is possibly two areas. One is more robust, the other I had NO success, but new it would work if I persisted.

Solution to Problem #3
When Ubuntu installs, it uses UUID's in the fstab and grub to refer to a harddrive instead of using the known (possibly changing) device location. Let me explain as I see it. A UUID is a Universally Unique Idenitifer and can be created and used as a ID for something. We use them in software / computers all the time. In this case, the Harddrive has a UUID. I don't exactly know who creates them for the drive, but they do exist. Actually, it's the partitions of the disk that have the UUID that we are interested in, the UUID of the harddrive (I assume there is one) is not that important.

So, to make it so it doesn't matter "what" your root drives come under, you use the UUID everywhere to refer to it. that way, when it changes (ie moves, unplugs on the bus etc) it will still be a known device. To locate the uuid for a partition, just use vol_id

once you have the UUID, pop it in the fstab and grub.
/etc/fstab

UUID=897ef-ab67c6-7785-abcb2 / (etc)

and /boot/grub/menu.lst

Now once I had tested that I could (re)boot back in regardless of the "sd-ness" of the drive, I could go back to solving problem #2

A little better (I feel) than the UUID=... is to use LABELs .. this seems to work nicer. But it could clash if you later add a new drive from another system which has a matching label.

So make it easier for me, I just prefixed the label with the short version name of the server. so

icem-root
icem-swap

Getting initramfs to recognise my LABELs (and the UUIDs) was a tad hard.

Solution to Problem #2
Problem #2 was actually simple. and I learnt something too.

The PCI RAID controller had to be told, via the module to load in passthrough mode so it was recognised as just an IDE bus and not a RAID controller.

With the change to libata, the it821x module changed names (and code) to pata_it821x. I read some places about the noraid=1 option for the module. So I tried a few things. Firstly.
if the module (pata_it821x or it821x) is compiled into the kernel, and not as a module, then getting this paratemer into the module is via the kernel parameters (ie, in the /boot/grub/menu.lst)
so .. kernel image ... ro it821x.noraid=1 ...
note the '.' dot in between the noraid and the module name.

I intially got stumped between the pata_ and the (sans pata_) other module.

the pata_ is the newer module, so for Ubuntu 7.10, the it821x doesn't exist (isn't compiled). but I also worked out that the "kernel" line is NOT for modules loaded on the fly.

so .. after I realised that my 7.10 had no it821x, i tried kernel.... pata_it821x.noraid=1
This would have worked had the moduled been compiled into the kernel. not to be.
So .. it was actually meant to be done the way I knew from way back when days.

/etc/modprobe.d/options

option pata_it821x noraid=1

That makes the it821x show the drives on the bus as "just" drives and NOT for linux to detect them as RAID drives. YAY! they all showed up.

No comments:

Current 5 booksmarks @ del.icio.us/pefdus