Gentoo vs. the n00b: Round 2?

I recently read Dustin Wilson’s Newbie Gentoo Review and as a ‘n00b’ who recently installed Gentoo, I found it to be a good article about Gentoo. It is a very good overview of the installation and configuration process. After reading all the comments about how most people thought or were looking for it to be a newbie walkthrough, I thought that as a ‘n00b’ who has recently installed Gentoo, I would try to write a little something about installing Gentoo for the newbie.

My command line experience, like Dustin’s, amounts to good-ole DOS back in the day.

However, having read the comments on the article, it seemed that a few people were hoping that his article would be more of a newbie walkthrough. Well, with that in mind, I have tried to create a n00b overview of the Gentoo Linux install process. I have tried to cover some of the snags I hit along the way, as well as some other parts of the install that might cause some problems for n00bs. One thing to note, that Dustin also mentioned, is the Gentoo forums. Like he said, these are probably one of the best forums out there. They are full of people, form n00bs like me with similar problems, to Gentoo vets who are always willing to lend some help to the n00bs trying to break into Gentoo. Bookmark the forums. Somewhere along the way, not matter how well prepared you are, you will need to visit them.

For starters, the Gentoo system’s default editor is nano (a modified version of pico), so you may want to take a look at nano basics to get an overview of using nano. It’s fairly straightforward, and there is a menu on the bottom of the screen with your commonly used commands. The ones we will be most concerned with are ^O (CTRL+O) for write Out and ^X (CTRL+X) for eXit.

I will be starting with Gentoo 1.4_rc2. Gentoo 1.4_rc3 is the newest release candidate at the time of this writing, but it is a very basic system and it does not provide any optimized builds for specific processor architectures. And this is one of the major “selling”-points of Gentoo. First of all, we will of course need to download the ISO images. Since this article is written for 1.4_rc2 on x86 architecture, I would recommend grabbing one of the LiveCDs for your processor architecture. This is one of the great features of Gentoo. The LiveCD images are available for specific processors. What this means is that if you start at Stage 2 or Stage 3, the “bootstrap” process has been pre-compiled on a system that uses the same processor as your system.

Like Dustin suggests, I also highly recommend printing off the installation guide. If you are going to install X or Alsa, I would also print off the Desktop Configuration and Alsa Configuration guides which you can locate from the User Docs page.

First, read the installation guide at least twice through and make sure you have at least a semi-decent idea of what is going to happen and when. I can’t stress this enough, as Dustin found out, this is imperative to getting Gentoo working without any hitches.

OK, pop the LiveCD in your CD-ROM drive and reboot. You should see a screen with the Gentoo logo on it and a boot prompt. Hit enter to begin booting the system. A bunch of messages should scroll up the screen.

While these messages are scrolling, watch for any modules (like device drivers in Windows) that failed to load. The most common ones are going to be network cards. This happened in my case. If this happens to you, you will need to manually load the module for your network card. The first thing you want to do is type

ls /lib/modules/*/kernel/drivers/net/*

to get a list of all the network card modules. Look for any of them that have a name resembling what your network card is. Once you have found one that matches, type

modprobe tulip

but replace “tulip” with the module you want to load. You should get a confirmation message that the module was loaded. If you get an error, try another module. Repeat this process for any other hardware whose modules did not load (ie. SCSI hardware, or Hardware RAID). All the modules can be found in

/lib/modules/*/kernel/drivers/

After you have loaded all your modules, you will want to make sure networking is working. Type

ifconfig -a

This should show a list of the currently configured NIC interfaces installed on the system. You should have at the least “lo” and “eth0”. The “lo” interface is the local loopback interface. The “eth0” interface is your network card. To check if it is running, look for the words “UP” and “RUNNING” in the fourth line of the eth0 interface section. If you don’t see this, try running the command

ifconfig eth0 up

This command will manually bring “up” the interface. Again, type

ifconfig -a

and look for “UP” and “RUNNING” in the output.

Once the interface is up, try pinging a website to make sure that it is actually working

ping www.osnews.com

If you get a host unknown error, you will have to manually set up your networking.

To manually set up networking, if you are running ADSL, run the

adsl-setup

script that comes on the CD, followed by the

adsl-start

script. If you are not running DSL, try running

net-setup eth0

to run the included net-setup script. If this still doesn’t work, try to manually set up the interface using ifconfig as shown in Code Listing 5.4 in the install guide. Next we need to make sure your DNS servers are set up in the

/etc/resolv.conf

file. Follow the template in code listing 5.5 in the install guide. If you are behind a proxy, follow Code Listing 5.6 in the install guide to set this up.

After completing your network setup, you should have a working internet connection. Test it to make sure it works by again running the ping command on a website.

Next we need to set up the partitions for installing Gentoo. Do this by running

cfdisk

cfdisk is a very straightforward program. I don’t think it needs any explanation for use, but make sure you use the right type for each of your partitions. Gentoo recommends creating a seperate partition for /boot. I did this on my system using the recommended size of 100 MB. Make this partition Type 83, since it will be a regular Linux filesystem (ie. ext2/3, ReiserFS, etc.). Next we need a swap partition, Type 82 (Linux Swap) and size equal to at least as much RAM as installed in your system, but up to twice the available RAM installed. Next is the partition for / (root – this is the partition where Gentoo will actually be installed). Make this as big as you want, but at least 1.5 GB if you are going to be installing any desktop environments (X with KDE, GNOME, E, etc.), and of Type 83 for a Linux filesystem.

Code Listing 6.1 in the install guide gives a command to zero a partition if it previously contained data. This is only necessary to run if you are going to make this partition a different type than it was previously. If it was unformatted, or the type you want previously, you can skip this, as the command to make the filesystem will format the partition.

First, initialize the swap with the command

mkswap /dev/hdaX

(replacing the X with the partition on which your swap is located). Next, we need to make our regular Linux filesystems on /boot and /. I used ext3 for mine and the command for this is

mke2fs -j /dev/hdaX

(replacing X with the partition for /boot). You will need to run this again for the / partition. If you want to use a different filesystem, Code Listings 6.3-6.7 give the commands for the various filesystems.

Next we will mount our new partitions so that we can access and write to them. Follow Code Listings 7.1 and 7.2 to mount your partitions, replacing hdaX with your partition number.

Now, we finally get to start installing stuff. Since we are using the LiveCD, it comes with each of the 3 stages available. I started with a Stage 2 tarball, since I did not want an extra 3 hours to compile gcc, binutils, and the other system tools. Use the command

cd /mnt/cdrom/gentoo

and

ls

to list the available stages. Now, we need to cd to the /mnt/gentoo directory (which is an alias to what will be / [root] on our system):

cd /mnt/gentoo

Now, unpack your desired stage using tar:

tar -xvjpf /mnt/cdrom/gentoo/stage?-*.tbz2

Then run

mount -o bind /proc /mnt/gentoo/proc

The proc directory contains the devices that are contained on the motherboard (ie. interfaces to the PCI bus, the processor(s), etc.). Next, we will copy our edited resolv.conf file to the new system:

cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf

A nice feature of the Gentoo LiveCD is that it comes with GRP (Gentoo Release Packages) files. The GRP files contain pre-built binaries of common packages like KDE, GNOME, Mozilla, OpenOffice, and X. If you don’t want to compile these packages (which I didn’t because most of these take forever and a day to compile), execute these commands:

mkdir /mnt/gentoo/GRP<br>mount -o bind /mnt/cdrom/gentoo/packages /mnt/gentoo/GRP

After executing these commands, we will be ready to “enter” our new Gentoo system.

To enter, our new Gentoo system, we need to execute the following:

chroot /mnt/gentoo /bin/bash<br>env-update<br>source /etc/profile

The first line changes the location of root to be in /mnt/gentoo. The next line regenerates the ld cache, and the last line points the system to the new paths. Now, we are inside our new Gentoo system and we can begin installing software and setting up other hardware.

The first thing we want to do now that we are inside our new Gentoo system, is update the Portage tree so we make sure we are getting the newest packages available. We need to run the following commands to sync the Portage tree, and get the latest version of Portage:

emerge sync<br>export CONFIG_PROTECT="-*"<br>export USE="-* bootstrap build"<br>emerge portage<br>unset USE

After executing these commands, we will have the latest Portage tree and the latest version of Portage. Next, we need to adjust our /etc/make.conf file which sets global options for compiling packages. Use the nano editor to do this:

nano -w /etc/make.conf

The /etc/make.conf file is well commented, so follow the instructions in the file to edit this to suit your system.

Now, we are ready to start building our system. If you opted to start at a Stage 1 system, you will need to execute these two commands to compile binutils, gcc, gettext, and glibc:

cd /usr/portage<br>scripts/bootstrap.sh

After this process completes (2-4 hours), your system will be equivalent to a Stage 2.

Now we need to merge the system packages. Type

emerge -p system

The -p flag does a “pretend” merge that lists all the packages to be installed, but does not install anything. If this scrolls off your screen, type

emerge -p system | more

so you can scroll through it at your leisure. Once you have taken a look at what the system will merge, execute the same command without the -p flag. This is going to take a long, long, long, long time. Do this before you go to sleep, before you go to work or school, or make sure you have something to keep you occupied for some hours to come (like Medal of Honor: Frontline for the PS2 ;).

Once this completes, you will have a system equivalent to a Stage 3. Now we will update the Portage tree, and update all installed packages.

emerge sync<br>emerge -up world<br>emerge -u world

First we update the tree, then we pretend to merge the packages (the -u flag specifies we want to update installed packages). Then we merge the packages.

Now, if you decided to use the GRP packages, we will install these. First, we need to enter the GRP directory and then use the grp-install shell script to install the packages:

cd /GRP<br>sh grp-install.sh package-list.txt

Replace “package-list.txt” with package you want to install. You can also specify multiple packages on the same line seperated by a space. Make sure that you are in the /GRP directory on your hard drive. The first time I did this, I did not mount the CD’s packages directory at /GRP and I tried to run the grp-install.sh script from the CD. Needless to say, this doesn’t work.

Now we need to set the time zone for the system. Browse to /usr/share/zoneinfo and find the timezone file for your locale. Use the command

pwd

to print the current working directory so you have the full path available to look at so you don’t have to remember it. Then make a symbolic link to the timezone file by executing this command:

ln -sf /usr/share/zoneinfo/path/to/file /etc/localtime

Next up, we will install our system kernel. I recommend using the gentoo-sources kernel as it has some desirable features already enabled by default. Read the first part of Section 17 in the installation guide carefully. It is full of useful information about things you will need to enable if you have certain hardware. Make doubly sure that you enable the module for your network card to be installed as a module in the kernel configuration. I forgot this and was without networking on my first reboot. So the first thing I did on my new Gentoo system was recompile the kernel. Also, make sure you go through every menu in the kernel configuration and look at every option, because if you skip over something you have, you won’t be able to just modprobe it to load it, because it wasn’t compiled in the first place. The next part of section 17 covers installing a system logger daemon and is pretty self-explanatory, so I will not cover this here. Section 18 of the installation guide is purely optional and only necessary if you have used any of these filesystems or have any of these devices.

Now we need to edit the /etc/fstab file to tell the system where /, /boot, /swap, and /mnt/cdrom are to be mounted from. The installation guide covers this well and the file itself is well commented.

Now we perform some necessary pre-reboot configuration for our system. Set the root password using the

passwd

command, set your hostname, if you know it, by editing the /etc/hostname file, and set the /etc/hosts file up with your IP, domain, and machine name.

Next, we have some final network configuration to do. Edit the /etc/modules.autoload file to load any modules you need automatically, especially your network card. In my case, I have “tulip” in the modules.autload because this is the module my NIC card uses. Now, edit the /etc/conf.d/net file to make sure that your network card will be properly configured on boot. This file is also well commented and needs no other explanation. After that we need to make sure that our network card is brought up on boot, so we execute

rc-update add net.eth0 default

This will add the eth0 interface to the default runlevel.

Now we configure some basic system settings by editing the rc.conf file

nano -w /etc/rc.conf

Follow the instructions in the file to set up the various variables, most importantly, the CLOCK and KEYMAP settings.

Section 25 deals with installing and configuring a bootloader. I feel that the installation guide does a top notch job of this. I decided to go with grub, so I followed the first section. If you choose grub, be careful with the numbering scheme grub uses for your partitions. The way I remember is whatever linux calls it, just subtract one. For example, my /boot partition is on /dev/hda6, so in grub, this would translate to (0,5) – first disk, partition six. grub counts from zero.

Next, we create bootdisks for our system, and again the installation guide covers this well, so I won’t go into this.

And finally, we are ready to reboot our system and get Gentoo-ing. Follow the code in Listing 27.1 to update any etc configuration files that need updating, exit the chrooted shell, unmount the filesystems, and reboot.

Upon reboot, you should have a lovely boot loader to load up Gentoo.

I hope this guide has given you some n00b insight into what goes on during the Gentoo install.

As Dustin stated in his Newbie review, this is not a distribution for the light-headed. This distro will take a lot of time and effort on your part, with the reward being a system that is totally optimized for your box.

Having been running Gentoo for a couple of weeks now myself, I love it. Portage is probably the best package manager of any that I have been exposed to (rpm, apt, etc.). It handles dependencies great, and is simply easy to use.

If you’ve ever wondered what goes on behind the scenes in your Linux distro, Gentoo will give you a hands on tutorial :).

About the Author:
Dave Scott is a 21-year-old student majoring in IT-Multimedia/Broadcast Graphics at ITT Technical Institute in Indianapolis. He is employed full-time as an engineer designing fire suppression systems. Dave’s first exposure to Linux was a Knoppix CD in an Operating Systems class at school, and he’s been hooked ever since, having run at various points over the last four months: Slackware, Mandrake, Debian, Gentoo, and Arch Linux.

36 Comments

  1. 2003-03-17 5:41 pm
  2. 2003-03-17 5:49 pm
  3. 2003-03-17 5:50 pm
  4. 2003-03-17 6:18 pm
  5. 2003-03-17 6:35 pm
  6. 2003-03-17 6:36 pm
  7. 2003-03-17 6:46 pm
  8. 2003-03-17 6:59 pm
  9. 2003-03-17 7:05 pm
  10. 2003-03-17 7:06 pm
  11. 2003-03-17 7:19 pm
  12. 2003-03-17 7:19 pm
  13. 2003-03-17 7:22 pm
  14. 2003-03-17 7:23 pm
  15. 2003-03-17 7:33 pm
  16. 2003-03-17 7:42 pm
  17. 2003-03-17 8:06 pm
  18. 2003-03-17 8:19 pm
  19. 2003-03-17 8:20 pm
  20. 2003-03-17 8:30 pm
  21. 2003-03-17 9:14 pm
  22. 2003-03-18 12:20 am
  23. 2003-03-18 1:02 am
  24. 2003-03-18 1:36 am
  25. 2003-03-18 1:37 am
  26. 2003-03-18 1:48 am
  27. 2003-03-18 2:44 am
  28. 2003-03-18 2:10 pm
  29. 2003-03-18 4:58 pm
  30. 2003-03-18 6:56 pm
  31. 2003-03-18 7:22 pm
  32. 2003-03-18 7:31 pm
  33. 2003-03-18 9:16 pm
  34. 2003-03-18 11:55 pm
  35. 2003-03-19 3:35 pm
  36. 2003-03-20 9:16 pm