<< Back to man.ChinaUnix.net

[ << ] [ < ] [ Home ] [ > ] [ >> ]

8. Configuring your System


8.a. Filesystem Information

What is fstab?

Under Linux, all partitions used by the system must be listed in /etc/fstab. This file contains the mountpoints of those partitions (where they are seen in the file system structure), how they should be mounted and with what special options (automatically or not, whether users can mount them or not, etc.)

Creating /etc/fstab

/etc/fstab uses a special syntax. Every line consists of six fields, separated by whitespace (space(s), tabs or a mixture). Each field has its own meaning:

The default /etc/fstab file provided by Gentoo is no valid fstab file, so start nano (or your favorite editor) to create your /etc/fstab:

Code listing 1: Opening /etc/fstab

# nano -w /etc/fstab

Let us take a look at how we write down the options for the /boot partition. This is just an example, so if your architecture doesn't require a /boot partition (such as PPC), don't copy it verbatim.

In our default x86 partitioning example /boot is the /dev/hda1 partition, with ext2 as filesystem. It needs to be checked during boot, so we would write down:

Code listing 2: An example /boot line for /etc/fstab

/dev/hda1   /boot     ext2    defaults        1 2

Some users don't want their /boot partition to be mounted automatically to improve their system's security. Those people should substitute defaults with noauto. This does mean that you need to manually mount this partition every time you want to use it.

Now, to improve performance, most users would want to add the noatime option as mountoption, which results in a faster system since access times aren't registered (you don't need those generally anyway):

Code listing 3: An improved /boot line for /etc/fstab

/dev/hda1   /boot     ext2    defaults,noatime    1 2

If we continue with this, we would end up with the following three lines (for /boot, / and the swap partition):

Code listing 4: Three /etc/fstab lines

/dev/hda1   /boot     ext2    defaults,noatime  1 2
/dev/hda2   none      swap    sw                0 0
/dev/hda3   /         ext3    noatime           0 1

To finish up, you should add a rule for /proc, tmpfs (required) and for your CD-ROM drive (and of course, if you have other partitions or drives, for those too):

Code listing 5: A full /etc/fstab example

/dev/hda1   /boot     ext2    defaults,noatime     1 2
/dev/hda2   none      swap    sw                   0 0
/dev/hda3   /         ext3    noatime              0 1

none        /proc     proc    defaults             0 0
none        /dev/shm  tmpfs   nodev,nosuid,noexec  0 0

/dev/cdroms/cdrom0    /mnt/cdrom    auto      noauto,user    0 0

auto makes mount guess for the filesystem (recommended for removable media as they can be created with one of many filesystems) and user makes it possible for non-root users to mount the CD.

Now use the above example to create your /etc/fstab. If you are a SPARC-user, you should add the following line to your /etc/fstab too:

Code listing 6: Adding openprom filesystem to /etc/fstab

none        /proc/openprom  openpromfs    defaults      0 0

If you need usbfs, add the following line to /etc/fstab:

Code listing 7: Adding usbfs filesystem to /etc/fstab

none        /proc/bus/usb   usbfs         defaults      0 0

Double-check your /etc/fstab, save and quit to continue.

8.b. Networking Information

Hostname, Domainname etc.

One of the choices the user has to make is name his/her PC. This seems to be quite easy, but lots of users are having difficulties finding the appropriate name for their Linux-pc. To speed things up, know that any name you choose can be changed afterwards. For all we care, you can just call your system tux and domain homenetwork.

We use these values in the next examples. First we set the hostname:

Code listing 8: Setting the hostname

# echo tux > /etc/hostname

Second we set the domainname:

Code listing 9: Setting the domainname

# echo homenetwork > /etc/dnsdomainname

If you have a NIS domain (if you don't know what that is, then you don't have one), you need to define that one too:

Code listing 10: Setting the NIS domainname

# echo nis.homenetwork > /etc/nisdomainname

Now add the domainname script to the default runlevel:

Code listing 11: Adding domainname to the default runlevel

# rc-update add domainname default

Configuring your Network

Before you get that "Hey, we've had that already"-feeling, you should remember that the networking you set up in the beginning of the gentoo installation was just for the installation. Right now you are going to configure networking for your Gentoo system permanently.

All networking information is gathered in /etc/conf.d/net. It uses a straightforward yet not intuitive syntax if you don't know how to set up networking manually. But don't fear, we'll explain everything :)

First open /etc/conf.d/net with your favorite editor (nano is used in this example):

Code listing 12: Opening /etc/conf.d/net for editing

# nano -w /etc/conf.d/net

The first variable you'll find is iface_eth0. It uses the following syntax:

Code listing 13: iface_eth0 syntaxis

iface_eth0="<your ip address> broadcast <your broadcast address> netmask <your netmask>"

If you use DHCP (automatic IP retrieval), you should just set iface_eth0 to dhcp. If you use rp-pppoe (e.g. for ADSL), set it to up. If you need to set up your network manually and you're not familiar with all the above terms, please read the section on Understanding Network Terminology if you haven't done so already.

So let us give three examples; the first one uses DHCP, the second one a static IP ( with netmask, broadcast and gateway while the third one just activates the interface for rp-pppoe usage:

Code listing 14: Examples for /etc/conf.d/net

(For DHCP)
# Some network admins require that you use the
# hostname and domainname provided by the DHCP server.
# In that case, add the following to let dhcpcd use them.
# That will override your own hostname and domainname definitions.
# If you intend on using NTP to keep your machine clock synchronized, use
# the -N option to prevent dhcpcd from overwriting your /etc/ntp.conf file

(For static IP)
iface_eth0=" broadcast netmask"

(For rp-pppoe)

If you have several network interfaces, create extra iface_eth variables, like iface_eth1, iface_eth2 etc. The gateway variable shouldn't be reproduced as you can only set one gateway per computer.

Now save the configuration and exit to continue.

Automatically Start Networking at Boot

To have your network interfaces activated at boot, you need to add them to the default runlevel. If you have PCMCIA interfaces you should skip this action as the PCMCIA interfaces are started by the PCMCIA init script.

Code listing 15: Adding net.eth0 to the default runlevel

# rc-update add net.eth0 default

If you have several network interfaces, you need to create the appropriate net.eth1, net.eth2 etc. initscripts for those. You can use ln to do this:

Code listing 16: Creating extra initscripts

# cd /etc/init.d
# ln -s net.eth0 net.eth1
# rc-update add net.eth1 default

Writing Down Network Information

You now need to inform Linux about your network. This is defined in /etc/hosts and helps in resolving hostnames to IP addresses for hosts that aren't resolved by your nameserver. For instance, if your internal network consists of three PCs called jenny (, benny ( and tux ( - this system) you would open /etc/hosts and fill in the values:

Code listing 17: Opening /etc/hosts

# nano -w /etc/hosts

Code listing 18: Filling in the networking information     localhost   jenny.homenetwork jenny   benny.homenetwork benny   tux.homenetwork tux

If your system is the only system (or the nameservers handle all name resolution) a single line is sufficient. For instance, if you want to call your system tux:

Code listing 19: /etc/hosts for lonely or fully integrated PCs     localhost tux

Save and exit the editor to continue.

If you don't have PCMCIA, you can now continue with System Information. PCMCIA-users should read the following topic on PCMCIA.

Optional: Get PCMCIA Working

Note: pcmcia-cs is only available for x86, amd64 and ppc platforms.

PCMCIA-users should first install the pcmcia-cs package. This also includes users who will be working with a 2.6 kernel (even though they won't be using the PCMCIA drivers from this package).

Code listing 20: Installing pcmcia-cs

# emerge pcmcia-cs

When pcmcia-cs is installed, add pcmcia to the default runlevel:

Code listing 21: Adding pcmcia to the default runlevel

# rc-update add pcmcia default

8.c. System Information

Root Password

First we set the root password by typing:

Code listing 22: Setting the root password

# passwd

If you want root to be able to log on through the serial console, add tts/0 to /etc/securetty:

Code listing 23: Adding tts/0 to /etc/securetty

# echo "tts/0" >> /etc/securetty

System Information

Gentoo uses /etc/rc.conf for general, system-wide configuration. Open up /etc/rc.conf and enjoy all the comments in that file :)

Code listing 24: Opening /etc/rc.conf

# nano -w /etc/rc.conf

As you can see, this file is well commented to help you set up the necessary configuration variables. Take special care with the KEYMAP setting: if you select the wrong KEYMAP you will get weird results when typing on your keyboard.

Note: Users of USB-based SPARC systems and SPARC clones might need to select an i386 keymap (such as "us") instead of "sunkeymap".

PPC uses x86 keymaps on most systems. Users who want to be able to use ADB keymaps on boot have to enable ADB keycode sendings in their kernel and have to set a mac/ppc keymap in rc.conf.

When you're finished configuring /etc/rc.conf, save and exit, then continue with Installing Necessary System Tools.

[ << ] [ < ] [ Home ] [ > ] [ >> ]