You need to edit some important configuration files. In this chapter you receive an overview of these files and an explanation on how to proceed. 34 2013-12-18
Filesystem Information What is fstab?

Under Linux, all partitions used by the system must be listed in /etc/fstab. This file contains the mount points 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 first field shows the partition described (the path to the device file)
  • The second field shows the mount point at which the partition should be mounted
  • The third field shows the filesystem used by the partition
  • The fourth field shows the mount options used by mount when it wants to mount the partition. As every filesystem has its own mount options, you are encouraged to read the mount man page (man mount) for a full listing. Multiple mount options are comma-separated.
  • The fifth field is used by dump to determine if the partition needs to be dumped or not. You can generally leave this as 0 (zero).
  • The sixth field is used by fsck to determine the order in which filesystems should be checked if the system wasn't shut down properly. The root filesystem should have 1 while the rest should have 2 (or 0 if a filesystem check isn't necessary).
The default /etc/fstab file provided by Gentoo is not a valid fstab file. You have to create your own /etc/fstab.
# nano -w /etc/fstab

In the remainder of the text, we use the default /dev/sd* block device files as partition. You can also opt to use the symbolic links in the /dev/disk/byid or /dev/disk/by-uuid. These names are not likely to change, whereas the default block device files naming depends on a number of factors (such as how and in what order the disks are attached to your system). However, if you do not intend to fiddle with the disk ordering, you can continue with the default block device files safely.

Let us take a look at how we write down the options for the /boot partition. This is just an example, if you didn't or couldn't create a /boot, don't copy it.

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

   /boot     ext2    defaults        0 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.

Add the rules that match your partitioning scheme and append rules for your CD-ROM drive(s), and of course, if you have other partitions or drives, for those too.

Now use the example below to create your /etc/fstab:

   /boot        ext2    defaults,noatime     0 2
/dev/sda3   none         swap    sw                   0 0
/dev/sda4   /            ext4    noatime              0 1

/dev/cdrom  /mnt/cdrom   auto    noauto,user          0 0
   /boot        ext2    defaults,noatime     0 2
/dev/sda2   none         swap    sw                   0 0
/dev/sda3   /            ext4    noatime              0 1

/dev/cdrom  /mnt/cdrom   auto    noauto,user          0 0
/dev/sda1   /               ext4        noatime              0 1
/dev/sda2   none            swap        sw                   0 0
/dev/sda4   /usr            ext4        noatime              0 2
/dev/sda5   /var            ext4        noatime              0 2
/dev/sda6   /home           ext4        noatime              0 2

# You must add the rules for openprom
openprom    /proc/openprom  openpromfs  defaults             0 0

/dev/cdrom  /mnt/cdrom      auto        noauto,user          0 0
/dev/sda4   /            ext4    noatime              0 1
/dev/sda3   none         swap    sw                   0 0

/dev/cdrom  /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.

To improve performance, most users would want to add the noatime mount option, which results in a faster system since access times aren't registered (you don't need those generally anyway). This is also recommended for solid state drive (SSD) users, who should also enable the discard mount option (ext4 and btrfs only for now) which makes the TRIM command work.

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

Networking Information Host name, 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.

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

(Set the hostname variable to your host name)
hostname="tux"

Second, if you need a domainname, set it in /etc/conf.d/net. You only need a domain if your ISP or network administrator says so, or if you have a DNS server but not a DHCP server. You don't need to worry about DNS or domainnames if your networking is setup for DHCP.

The /etc/conf.d/net file does not exist by default, so you might need to create it.
# nano -w /etc/conf.d/net

(Set the dns_domain variable to your domain name)
dns_domain_lo="homenetwork"
If you choose not to set a domainname, you can get rid of the "This is hostname.(none)" messages at your login screen by editing /etc/issue. Just delete the string .\O from that file.

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:

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

(Set the nis_domain variable to your NIS domain name)
nis_domain_lo="my-nisdomain"
For more information on configuring DNS and NIS, please read the examples provided in /usr/share/doc/netifrc-*/net.example.bz2 which can be read using bzless. Also, you may want to emerge openresolv to help manage your DNS/NIS setup.
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.

More detailed information about networking, including advanced topics like bonding, bridging, 802.1Q VLANs or wireless networking is covered in the Gentoo Network Configuration section.

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. A fully commented example that covers many different configurations is available in /usr/share/doc/netifrc-*/net.example.bz2.

DHCP is used by default. For DHCP to work, you will need to install a DHCP client. This is described later in Installing Necessary System Tools. Do not forget to install a DHCP client.

If you need to configure your network connection either because you need specific DHCP options or because you do not use DHCP at all, open /etc/conf.d/net with your favorite editor (nano is used in this example):

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

To enter your own IP address, netmask and gateway, you need to set both config_eth0 and routes_eth0:

This assumes that your network interface will be called eth0. This is, however, very system dependent. It is recommended to assume that the interface is named the same as the interface name when booted from the installation media if the installation media is sufficiently recent. More information can be found in Network Interface Naming.
config_eth0="192.168.0.2 netmask 255.255.255.0 brd 192.168.0.255"
routes_eth0="default via 192.168.0.1"

To use DHCP, define config_eth0:

config_eth0="dhcp"

Please read /usr/share/doc/netifrc-*/net.example.bz2 for a list of all available options. Be sure to also read your DHCP client manpage if you need to set specific DHCP options.

If you have several network interfaces repeat the above steps for config_eth1, config_eth2, etc.

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.

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

If you have several network interfaces, you need to create the appropriate net.* files just like you did with net.eth0.

If you later find out the assumption about the network interface name (which we currently document as eth0) was wrong, then

  1. update the /etc/conf.d/net file with the correct interface name (like enp3s0 instead of eth0),
  2. create new symbolic link (like /etc/init.d/net.enp3s0),
  3. remove the old symbolic link (rm /etc/init.d/net.eth0),
  4. add the new one to the default runlevel, and
  5. remove the old one using rc-update del net.eth0 default.
Writing Down Network Information

You now need to inform Linux about your network. This is defined in /etc/hosts and helps in resolving host names to IP addresses for hosts that aren't resolved by your nameserver. You need to define your system. You may also want to define other systems on your network if you don't want to set up your own internal DNS system.

# nano -w /etc/hosts
(This defines the current system)
127.0.0.1     tux.homenetwork tux localhost

(Define extra systems on your network,
they need to have a static IP to be defined this way.)
192.168.0.5   jenny.homenetwork jenny
192.168.0.6   benny.homenetwork benny

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

PCMCIA users should first install the pcmciautils package.

# emerge pcmciautils
System Information Root Password

First we set the root password by typing:

# passwd
System Information

Gentoo uses /etc/rc.conf to configure the services, startup, and shutdown of your system. Open up /etc/rc.conf and enjoy all the comments in the file.

# nano -w /etc/rc.conf

When you're finished configuring these two files, save them and exit.

Gentoo uses /etc/conf.d/keymaps to handle keyboard configuration. Edit it to configure your keyboard.

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

Take special care with the keymap variable. If you select the wrong keymap, you will get weird results when typing on your keyboard.

PPC uses x86 keymaps on most systems.

When you're finished configuring /etc/conf.d/keymaps, save and exit.

Gentoo uses /etc/conf.d/hwclock to set clock options. Edit it according to your needs.

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

If your hardware clock is not using UTC, you need to add clock="local" to the file. Otherwise you will notice some clock skew.

When you're finished configuring /etc/conf.d/hwclock, save and exit.

Configure locales

You will probably only use one or maybe two locales on your system. You have to specify locales you will need in /etc/locale.gen.

# nano -w /etc/locale.gen

The following locales are an example to get both English (United States) and German (Germany) with the accompanying character formats (like UTF-8).

en_US ISO-8859-1
en_US.UTF-8 UTF-8
de_DE ISO-8859-1
de_DE@euro ISO-8859-15
You can select your desired locales in the list given by running locale -a. We strongly suggest that you should use at least one UTF-8 locale because some applications may require it.

The next step is to run locale-gen. It will generates all the locales you have specified in the /etc/locale.gen file.

# locale-gen

You can verify that your selected locales are available by running locale -a.

Once done, you now have the possibility to set the system-wide locale settings. With eselect locale list, the available targets are displayed:

# eselect locale list
Available targets for the LANG variable:
  [1] C
  [2] POSIX
  [3] en_US
  [4] en_US.iso88591
  [5] en_US.utf8
  [6] de_DE
  [7] de_DE.iso88591
  [8] de_DE.iso885915
  [9] de_DE.utf8
  [ ] (free form)

With eselect locale set <value> the correct locale can be set:

# eselect locale set 9

Manually, this can still be accomplished through the /etc/env.d/02locale file:

LANG="de_DE.UTF-8"
LC_COLLATE="C"

Don't forget to reload your environment:

# env-update && source /etc/profile

We made a full Localization Guide to help you through this process. You can also read the detailed UTF-8 article for very specific informations to enable UTF-8 on your system.

Please continue with Installing Necessary System Tools.

Configuring the Console

If you are using a virtual console, you must uncomment the appropriate line in /etc/inittab for the virtual console to spawn a login prompt.

hvc0:12345:respawn:/sbin/agetty -L 9600 hvc0
hvsi:12345:respawn:/sbin/agetty -L 19200 hvsi0

You should also take this time to verify that the appropriate console is listed in /etc/securetty.

You may now continue with Installing Necessary System Tools.