Gentoo Stage 3 Install

The first thing I noticed when I inserted the Gentoo Live Universal CD was that the GUI for the installer was beautiful. The second thing that I noticed was that it only lasted about ten seconds before it asked me to take over. I was presented with a prompt, root privileges on a ramdrive installation (that’s what Live CD’s are), and no idea how to continue.

I navigated to the cdrom drive [cd /mnt/cdrom] and looked around for something to help me. I found a folder called ‘docs’ and figured I was in luck. There was an install.txt file that took me the rest of the way [vi Install.txt].

set up network


The first thing I needed to do when installing Gentoo was to prepare the network connection. It just so happens that I am too lazy to find an ethernet cord and there wasn’t any apparent support yet for my Intel ProWireless card, so I skipped the internet connection. The Universal LiveCD contains stage3 (Gentoo prepares ’stages’ which are tarballs of whole systems, there are three stages and they each have a unique role) so I don’t need the network anyway. At least, for all I know I don’t.

set up partitions
The next part of installing Gentoo was preparing partitions for it. I’ve got a laptop which means I don’t have the luxury of installing a test on /dev/hdb (that’s linux talk for ’second hard drive’), so I had to make do with my current partition table. Luckily, besides my Windows XP partition, FAT32 storage partition, Suse 9.2 installation and EXT3 storage partition I also had a previous linux partition that I could use. The Gentoo install manual suggested I make partitions in this way:

  • 50MB partition for /boot
  • 500MB partition for swap
  • use the rest for /
  • Because of the nature of the installation, these would all be mounted in /mnt/gentoo first, and then that whole folder would become / later on.

    I had been given only in the installer was six consoles (accessed via ALT+1 - ALT+6) and fdisk, so I didn’t seem to have the means to make a boot partition of 50MB. Well, I did, but with my lack of experience with fdisk there’s a decent chance that I would have cleverly removed all of my data from the other partitions. To avoid that, I decided to ignore the boot partition and to proceed as if I had followed the directions perfectly.

    So what I had was this:

  • 3GB partition for WinXP
  • 8GB partition for Gentoo root
  • 9GB partition for Suse 9.2
  • 0.6GB partition for SWAP
  • 8GB partition for EXT2 storage
  • 35GB partition for FAT32 storage

install stage3 tarball
Still in the LiveCD console environment, I made the folder /mnt/gentoo and I unpacked a stage3 pentium4 tarball into it [tar xvjpf /mnt/cdrom/stages/state3-pentium4-2004.3.tar.bz2]. I started typing this post in console3 while it unpacked in console 4 (way to be productive, no?)

install Portage
The next step was installing Portage. Portage is Gentoo’s mothership app. Portage is to Gentoo what Jesus is to Christians - it makes things work. A Gentoo system that doesn’t have Portage has it’s own name: the linux kernel. So, knowing how important it was that I didn’t screw this part up, I tried installing Portage.

Somehow, it was a breeze. I navigated to /mnt/cdrom/snapshots and there’s one tarball in there. I extracted it to /mnt/gentoo/usr (/usr) and copied the source code as well (/mnt/cdrom/distfiles -> /mnt/gentoo/usr/portage/distfiles). To my surprise the install manual described that as “a portage installation”. Just copying and extracting the files. Sweet.

setup Portage configuration
Portage can be passed certain variables each time it is run to define its behavior, but to save time those variables can be defined in a configuration file. The file /mnt/gentoo/etc/make.conf defines how Portage compiles programs. It can be edited using any text-editor. I prefer vi for sadistic reasons, but the install manual suggests nano. To edit this file, type:
nano -w /mnt/gentoo/usr/make.conf

The changes I made to make.conf were:

  • MAKEOPTS=”-j2″
  • which means that Portage will attempt no more than 2 simultaneous compiles. I have just one CPU, but with a gig of ram it should be able to handle two just fine.

  • USE=”-gtk -gnome kde alsa qt dvd cdr”
  • USE is sophisticated, it’s the most powerful variable in the file because it defines which libraries to use and how Portage will build your Gentoo apps. I’d recommend thoroughly checking the online handbook at Gentoo.org before setting this value.

chrooting into the new environment
If you’re setting up your Gentoo system with the same folder locations as me, you could use the exact same commands for what comes next:
chroot /mnt/gentoo /bin/bash
env-update
source /etc/profile

At this point I was totally baffled that I hadn’t received some message saying “total system failure” but rather that everything was going as described in the install doc - I was really impressed with Gentoo’s excellent documentation.

configuring the kernel
Yeah, this title scared me too. Fortunately Gentoo kept coming through for me; making things less hard (I won’t say easy).
It started with setting the timezone. Easy enough. For me and everybody else on America’s west coast that meant this command:
ln -sf /usr/share/zoneinfo/US/Pacific /etc/localtime
Next came choosing which kernel I wanted to use. Gentoo used names like gentoo-sources, vanilla-sources, gentoo-dev-sources and development-sources, but all I know is 2.4 and 2.6. From the documentation it seemed as though the 2.6 kernel that I was looking for was what Gentoo called gentoo-dev-sources so I picked that one.
emerge gentoo-dev-sources
For reasons that baffle me, this complicated process also worked perfectly. At this point Gentoo has become one of my most sucessful command-line installations of anything.

compiling the kernel source
This is the really scary part. I’ve attempted this procedure on other distros upwards of six or seven times with 0 success on each. Again, the documentation is sufficient, but this process is daunting.
cd /usr/src/linux
make menuconfig (follow your gut or the documentation to configure things right)
make && make modules_install (you should go get a cup of coffee at this point, it’ll be a few minutes)

compile programs at will


The documentation instructed for several programs to be installed at this point. It was very easy and worked flawlessly.
emerge metalog
emerge vixie-cron
emerge slocate
emerge xfsprogs
emerge reiserfsprogs
emerge dhcpcd

Note: avoid ati-drivers, xorg, X11-RC1, gnome, kde, and anything else that will require you to install X (the graphic display). You should wait until you go to bed before telling that to start.

choose Lilo or GRUB
I’ve always used Lilo though I’ve heard GRUB is better. It’s 2am, I have to work tomorrow, I’m just gonna stick to what I know.
emerge –usepkg lilo
Then I have to edit the /etc/lilo.conf file to match my system requirements. I copied the lilo.conf on my Suse installation and modified a couple of lines to look like this:

[ insert lilo.conf ]

I updated the lilo installation with the following
/sbin/lilo
and I was all set to reboot.

rebooting the new gentoo installation
This was the finger-crossing, praying-for-help moment. I rebooted the computer, lilo showed up perfectly, and then it gave me a prompt. I was in jubilation until I realized that the prompt came immediately after a bootup line that told me the root partition had failed to mount. I wasn’t prepared for this, but I knew it could probably be fixed with a simple edit of the /etc/fstab file.
So I rebooted the computer and ran my bootable Gentoo LiveCD to get a prompt. I remounted the new installation in /mnt/gentoo and edited the /etc/fstab file. Where my hda5 line used to say ‘reiserfs’ it now said ‘ext3′. Fdisk couldn’t tell me any more than that the partition was the “Linux” type. I couldn’t remember if, when I formatted it a while ago (no, I didn’t reformat for this installation. I figured it’d be fine cause the partition was blank) I’d made it a reiserfs or ext3 file system.
I reboot again, this time with the same results. I change the ‘ext3′ entry to ‘auto’ and reboot - and no change at all.

first serious problem
So now I’m looking at my first real hangup. I’ve got either an incorrect /etc/fstab file (which is unlikely because I’m pretty sure I’ve checked it multiple times, and something very much like it has been working on my Suse installation) or I’ve got an improperly formatte partition (which is likely because I didn’t format it in this installation).

It looks like I’m going to go back several steps and see how long it takes to repeat the same actions until I can get back to here.

Starting all over

reformatting the partition
I’ve been spoiled by PowerQuest. The Partition Magic series always made partitioning so damn easy. Now all I’ve got is fdisk and it’s nothing compared to PartitionMagic when I need to know if what I’m about to do is going to screw me over. Somebody needs to make Partition Magic for the CLI without needing qt or gkt.

It’s during this install that I go and get some education on Linux tools for file system management. I should have guessed from my experience so far with Linux that all the required tools are available and reliable - but that every function is divided into a different tool. So, here’s what I learned so all the other newbs out there don’t have to go through what I did.

  • fdisk use this to make/delete partitions and to change their size. You change their size by changing the first and last sector of the partition.
  • mke2fsthis is the magical utility that solved my problem with the corrrupted partition. Short for ‘make ext2 filesystem’, mke2fs formats partitions into the ext2 and ext3 file systems. This will be useful for formatting my corrupted ext3 partition.

I reformat my partition using the mke2fs command (with the -j argument it makes ext3 instead of ext2).
mke2fs -j /dev/hda5
And then I mount it and start over.
mount /dev/hda5 /mnt/gentoo
cp /mnt/cdrom/stages/stage3-pentium4-2004.3.tar.bz2 /mnt/gentoo
cd /mnt/gentoo
tar xvjfp stage3-pentium4-2004.3.tar.bz2
tar xvjf /mnt/cdrom/stages/portage20041022.tar.bz2 -C /mnt/gentoo/usr
mkdir /mnt/gentoo/usr/portage/distfiles
cp /mnt/cdrom/distfiles/* /mnt/gentoo/usr/portage/distfiles/
Then I edit the make.conf for portage to match what I did before.

using the network to update Gentoo
This time I got off my ass and plugged in an ethernet cable. I’m going to update my list of mirrors for portage and source code.
mirrorselect -a -s4 -o >> /mnt/gentoo/etc/make.conf
mount -t proc none /mnt/gentoo/proc
chroot /mnt/gentoo /bin/bash
env-update
source /etc/profile
ln -sf /usr/share/zoneinfo/US/Pacific /etc/localtime
emerge gentoo-dev-sources
cd /usr/src/linux
make menuconfig
make && make modules_install
cp arch/i386/boot/bzImage /boot/kernel-2.6.9-r1-danger
cp System.map /boot/System.map-2.6.9-r1-danger
cp .config /boot/config-2.6.9-r1-danger

Since I’ve got network this time, I can have Portage install my ATI drivers on Gentoo with the command:
emerge ati-drivers
The wonderful thing about portage is that it resolves all dependencies, so this command also installs X. I set it up to start and a half-hour into it I decided to go to bed and let it finish it’s thing.
When I came back, it was all done and it was time for me to set up fstab again. I used the same values as the first time because I’d confirmed that it was my partition that was messed up, not the fstab file.
Then I added my user again:
useradd danger -m -G users,wheel,audio,tty -s /bin/bash
passwd danger
emerge metalog
rc-update add metalog default
emerge vixie-cron
rc-update add vixie-cron default
emerge slocate
emerge xfsprogs
emerge reiserxfprogs
emerge –usepkg lilo
Then I edit lilo.conf to boot Gentoo on hda5, Windows on hda1, and Suse on hda6.
exit
cd
umount /mnt/gentoo/proc /mnt/gentoo
reboot

Kernel config problems

Upon reboot I’m happy to find that I’m able to mount my root partition just fine, but I’ve been given a notice that Gentoo needs DEVFS (which I’ve apparently left out of the kernel). So I reboot into the LiveCD once again and recompile the kernel with DEVFS support.
This kernel immediately hangs the system on boot, so I reread the documentation and find that there was another option under DEVFS that I ignored (one that automatically mounts DEVFS at boot). I select this and recompile again.

After a while it occured to me that my problem with the system hanging had nothing to do with the kernel, but I had changed the location of the kernel so Lilo was failing. I fixed Lilo and rebooted successfully.

The next few hours consisted of booting into my installation, realizing I’d forgotten to install something necessary and either emerging it right there (like emerge xorg-x11) or rebooting into the LiveCD to install it with network support (like emerge dhcpcd).

finally installing the good stuff
I eventually found myself with a working network connection and working partitions. I did the following:
emerge kde
emerge openoffice
emerge k3b
emerge dvdrip
emerge Mozilla-Firefox
emerge xine-lib
emerge kaffeine
emerge mplayer

configuring Xorg
The configuration of Xorg was pretty easy because Xorg accepts XF86Config files. I just copied the file I was using for my Suse installation to the new system and changed the location of a couple /dev locations. When I typed
startx
everything went fine.

Next up:
Thanks to Gary I’ve been inspired to try using Damn Small Linux to bootstrap a stage 1 installation of Gentoo.