Building a Linux Media Network, one step at a time

Tuesday, January 24, 2006

Linux is Beefy

I'm not sure if the aphorism "Linux is Beefy" means anything outside of Cray Canada. BEFE is the post code we use to indicate that the kernel is up and running, that the boot sequence is effectively complete. I've just reached this point with Fulcrum. Herewith, a description of how it got there.

I've picked Damn Small Linux as the distro for this machine. It's a compact, full-featured distribution that I've had some good luck with so far. As a LiveCD - a "self-sufficient" CD that can be used to boot a computer - it fits into 50Mb. As an installed operating system, I believe it can squeeze into around 200Mb.

Now, I don't have a spare CD drive to hook up to Fulcrum, and even if I did, the tricky route is a lot more interesting and educational. Fortunately, I have a Linux workstation to help with the task.

The first step is to get the hard disk into a system where I can lay out and format the partitions just the way I want them. So I plugged the drive into my desktop PC, which runs SUSE 10.0 and had a free IDE channel.

I used the parted utility to create three primary partitions. The first was 1GB and the second and third were 2GB each. The first partition will be used to hold the images for the boot loader (1GB is way, way too much here, but it doesn't really matter). The second partition will hold the LiveCD ISO and the third partition will hold the actual installation.

Installing the boot loader was a little harder than it should have been. First, I created three mount points for the partitions and mounted them:


mkdir /mnt/fulcrum
mkdir /mnt/fulcrum/grub
mkdir /mnt/fulcrum/iso
mkdir /mnt/fulcrum/os
mount /dev/hdc1 /mnt/fulcrum/grub
mount /dev/hdc2 /mnt/fulcrum/iso
mount /dev/hdc3 /mnt/fulcrum/os


Then I ran the grub-install command to install the boot loader on the disk:

grub-install --root-directory=/mnt/fulcrum/grub /dev/hdc

Now, as far as I know, what this should do is install GRUB boot loader into the master boot record of the disk, and install all the extra GRUB data into the /dev/hdc1 partition. But I got an error message that looked a lot like a disk error when I tried that... something like "unable to read stage1 file".

Looking at the newly-created directory tree, it was pretty apparent that some files were missing from /mnt/fulcrum/grub/boot/grub. So I cleaned out the partition and just copied over the entire /boot directory into /mnt/fulcrum/grub. What this means is, I took SUSE's /boot directory and all the GRUB data it uses and cloned it for Fulcrum.

I tweaked the device.map file a little bit - it's fairly self-explanatory and pretty well documented online - and also added a fresh entry to boot the DSL LiveCD, which we're about to install. The new entry looks like this:

###dsl-2.0-live###
title Damn Small Linux 2.0 LiveCD
root (hd0,1)
kernel /boot/isolinux/linux24 root=/dev/hdb6 init=/etc/init lang=us vga=normal BOOT_IMAGE=knoppix
initrd /boot/isolinux/minirt24.gz

This tells GRUB to look in the 1'th partition for the Damn Small Linux kernel and initrd image. I believe GRUB numbers disks and partitions starting from 0, so this corresponds to the partition we called /dev/hdc2 above.

The last step is to actually get the Damn Small Linux LiveCD into that partition, which is empty right now. This is fairly straightforward. First, we mount the LiveCD iso (which I had downloaded earlier via BitTorrent from damnsmalllinux.org):

mkdir /tmp/dsl2
mount -o loop /usr/local/downloads/dsl-2.0.iso /tmp/dsl2

Then we copy the contents into the empty partition:

cp -R /tmp/dsl2/* /mnt/fulcrum/iso

And that's it! At this point I shut down my desktop PC, removed the hard drive, and connected it back to Fulcrum. DSL booted successfully and asked me a couple questions related to video and mouse configuration, and that was it.

So now what we have is a fake LiveCD distribution. It's running Linux, sure, but it's basically treating the hard drive as a read-only file system and making all its changes in a ramdisk. That's sub-optimal, because none of our configuration changes will be saved next time we reboot.

The next step is to install the operating system to that third partition we created and really get to work setting up this media center. After that, we can start to think about cutting over to the compact flash and getting rid of this hard disk entirely.

0 Comments:

Post a Comment

<< Home