Saturday, February 03, 2007

Part 3: Gumstick Gentoo

To recap, we've identified our trouble (portage tree); we've removed it from our final system; and, we have entered our Stage 3 install via chroot

Part 3: Fattening the Turkey
----------------------------------------

I am assuming that you know how to setup your USE, MAKEOPTS, and CFLAGS options with Gentoo. If not, go read their documentation. They are usually very good.

First things first, we need to be sure we are running the latest and greatest.

# emerge --sync
# emerge portage (if suggested)
# etc-update (if needed)


Ok, now we have the most up-to-date portage and portage tree. What to do? Why make sure we can boot this puppy! That means kernel and bootloader.

Since we will be using this stick on multiple computers, I'd definitely reccommend a microkernel approach except for a few particular modules. Namely, we expect to be putting this on a USB Drive. That means that genkernel would be a great choice since it turns most everything into modules. So:

# emerge gentoo( or vanilla)-sources genkernel grub vim(my editor of choice)
# genkernel --menuconfig all

Note: All the following is from memory, so be lenient on me for minor errors. But, please to notify me of problems!

In your menuconfig, you need to traverse through the tree to both the SCSI the USB Drivers section. Say yes(not M) to the following modules:

EHCI (usb 2.0)
UHCI (the OTHER usb 1.1)
OHCI (usb 1.1)
USB Mass Storage (and all sub modules)
USB HID (and all sub modules)

SCSI devices(your thumb drive will look like a scsi device.)

Exit and save your kernel. From here, genkernel can will take control. However, since you don't have a boot loader configured AND you're in a chroot environment, you'll have to do some boot loader config manually. Also, lets make some easy to use symbolic links in /boot.

# cd /boot
# ln -s {kernel image} vmlinuz
# ln -s
{initrd image} initrd.img



Boot Loader:
----------------

Now, you notice that I chose grub as that is my most familiar. So everything in this section is dependant on that.

First thing with grub is that you need to specify what device map to what identifier. For instance.

#vim /boot/grub/device.map (you probably don't have one of these, so this will also create it)

Inside VIM:
- /dev/sda (hd0) #USB Thumbdrive
- /dev/hda (hd1) #in case you have a kernel on the primary IDE drive you wan to use
- /dev/fd0 (fd0) #floppy disk
-

Now, we also need to create a menu for grub.

#vim /boot/grub/menu.lst (also, you probably don't have this one)

Inside VIM:
-
- defalut 0 #which "title" option to boot by default... 0-based
- timeout 5 #5 seconds to change your mind
-
- title Gentoo Stick
- root (hd0,0)
- kernel /boot/vmlinuz ro quiet rootdelay=10
- initrd /boot/initrd.img


Some explaining:

root - in this case, specifies that any "/"(root) directory is on the first partition on the first device in device.map

kernel - path to your kernel... relative to "root" plus any other options

initrd - path to your initrd... relative to "root"

rootdelay=10 - this is a bit of a hack built into 2.6 kernels. It pauses for 10 seconds just before it tries to load your root file system specified on the kernel line. This allows your usb device to actually be detected by drivers that may be a bit slow on the uptake.

NOTE: we have yet to do a "# grub-install" for a very good reason; ie We're ina chroot environment and we don't have our target drive mounted... So, DON'T try it yet.

Now, we just need the fun stuff... a GUI

# emerge fluxbox x11 xfree86-vesa xdm
# echo "exec fluxbox" >> ~.xinitrc
# passwd

Now, we should have a base system configured ready to deploy... What's one to do? Why exit our chroot.

# exit
# umount ~/gentoo/proc
# umount ~/gentoo/sys
# umount ~/gentoo/dev
# umount ~/gentoo/usr/src
# umount ~/gentoo/usr/portage
# umount ~/gentoo/var/cache
# umount ~/gentoo/var/db
# umount ~/gentoo/var/tmp/portage

On to the final Part 4

1 comment:

Unknown said...

Under you GUI stuff:
echo "exec fluxbox" >> ~.xinitrc

should be:

echo "exec fluxbox" >> ~/.xinitrc