- •255 Heads, 63 sectors/track, 72943 cylinders
- •Install the latest Portage snapshot. Proceed as for the stage3 archive: choose a nearby mirror from our list, download the latest snapshot and unpack it.
- •Install a kernel source (usually gentoo-sources), configure it, compile it and copy the arch/i386/boot/bzImage file to /boot.
- •Important: The following is only an example. It is in no way meant as a recommended setup.
Install a kernel source (usually gentoo-sources), configure it, compile it and copy the arch/i386/boot/bzImage file to /boot.
Code Listing 2.19: Install a kernel source, compile it and install the kernel
livecd etc # time emerge gentoo-sources
real 2m51.435s
user 0m58.220s
sys 0m29.890s
livecd etc # cd /usr/src/linux
livecd linux # make menuconfig
(Configure your kernel)
livecd linux # time make -j2
(Elapsed time depends highly on the options you selected)
real 3m51.962s
user 3m27.060s
sys 0m24.310s
livecd linux # make modules_install
livecd linux # cp arch/i386/boot/bzImage /boot/kernel
Configure the system
Edit your /etc/fstab and replace BOOT, ROOT and SWAP with the actual partition names. Don't forget to check that the file systems match your installation.
Code Listing 2.20: Example fstab
livecd linux # cd /etc
livecd etc # nano -w fstab
/dev/sda1 /boot ext2 noauto,noatime 1 2
/dev/sda3 / ext3 noatime 0 1
/dev/sda2 none swap sw 0 0
Configure your network in /etc/conf.d/net. Add the net.eth0 init script to the default run level. If you have multiple NICs, symlink them to the net.eth0 init script and add them to the default run level as well. Don't forget to set your hostname too. Either edit /etc/conf.d/net and /etc/conf.d/hostname with nano or use the following commands:
Code Listing 2.21: Configure networking
livecd etc # cd init.d
livecd init.d # ln -s net.lo net.eth0
livecd init.d # cd ../conf.d
livecd conf.d # echo 'config_eth0="192.168.1.10 netmask 255.255.255.0 brd 192.168.1.255"' >> net
livecd conf.d # echo 'routes_eth0="default via 192.168.1.1"' >> net
livecd conf.d # echo 'hostname="myhostname"' > hostname
livecd conf.d # rc-update add net.eth0 default
(If you compiled your network card driver as a module, add it to /etc/conf.d/modules
livecd conf.d # echo 'modules="r8169"' >> /etc/conf.d/modules
(If you want to reconnect via ssh after you have rebooted your new box)
livecd conf.d # rc-update add sshd default
Note: Emerge pcmciautils if you need support for PCMCIA cards.
Set the root password using passwd.
Code Listing 2.22: Set the root password
livecd conf.d # passwd
New UNIX password: type_the_password
Retype new UNIX password: type_the_password_again
passwd: password updated successfully
Edit /etc/timezone to define the time zone you used previously.
Code Listing 2.23: Edit /etc/timezone
Europe/Brussels
Check the system configuration in /etc/rc.conf and /etc/conf.d/keymaps and edit any of those files if required.
Code Listing 2.24: Optional: edit some config files
livecd conf.d # nano -w /etc/rc.conf
livecd conf.d # nano -w /etc/conf.d/keymaps
Installing System Tools
Install a system logger like syslog-ng and a cron daemon like vixie-cron, and add them to the default run level.
Note: Cron daemons depend on an MTA. mail-mta/ssmtp will be pulled in as a dependency. If you want to use a more advanced MTA, you might want to install it now. If you are in a hurry, let ssmtp be installed and remove it later when you install the MTA of your choice.
Code Listing 2.25: Install a syslogger and a cron daemon
livecd conf.d # time emerge syslog-ng vixie-cron
real 1m54.099s
user 1m2.630s
sys 0m34.620s
livecd conf.d # rc-update add syslog-ng default
livecd conf.d # rc-update add vixie-cron default
Install the necessary file system tools (xfsprogs, reiserfsprogs or jfsutils) and networking tools (dhcpcd or ppp) if you need any.
Code Listing 2.26: Install extra tools if required
livecd conf.d # emerge xfsprogs (If you use the XFS file system)
livecd conf.d # emerge jfsutils (If you use the JFS file system)
livecd conf.d # emerge reiserfsprogs (If you use the Reiser file system)
livecd conf.d # emerge dhcpcd (If you need a DHCP client)
livecd conf.d # emerge ppp (If you need PPPoE ADSL connectivity)
Configuring the Bootloader
Emerge grub and configure it. Do not forget to update the necessary boot parameters if you are using an initramfs.
Code Listing 2.27: Emerge grub and edit its configuration file
livecd conf.d # time emerge grub
real 1m4.634s
user 0m39.460s
sys 0m15.280s
livecd conf.d # nano -w /boot/grub/grub.conf
Code Listing 2.28: Example grub.conf
default 0
timeout 10
title Gentoo
root (hd0,0)
kernel /boot/kernel root=/dev/sda3
Code Listing 2.29: Install grub
livecd conf.d # grub
Probing devices to guess BIOS drives. This may take a long time.
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 16 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2 /boot/
grub/menu.lst"... succeeded
Done.
grub> quit
Reboot
Exit the chrooted environment, unmount all file systems and reboot:
Code Listing 2.30: Reboot
livecd conf.d # exit
livecd / # umount -l /mnt/gentoo/dev{/shm,/pts,}
livecd / # umount -l /mnt/gentoo{/proc,/boot,}
livecd / # reboot
(Don't forget to remove the CD)
Finalizing the Installation
Note: The total elapsed time between the display of the boot prompt on the minimal CD and the display of the login prompt after the reboot was 00:42:31 on our test box. Yes, less than one hour! Note that this time also includes the stage3, Portage snapshot and several packages download time and the time spent configuring the kernel.
Log in as root, then add one or more users for daily use with useradd.
Code Listing 2.31: Connect to your new box from another PC
(Clean up your known_hosts file because your new box
has generated a new definitive hostkey)
$ nano -w ~/.ssh/known_hosts
(Look for the IP of your new PC and delete the line,
then save the file and exit nano)
(Use the IP address of your new box)
$ ssh root@192.168.1.10
The authenticity of host '192.168.1.10 (192.168.1.10)' can't be established.
RSA key fingerprint is 96:e7:2d:12:ac:9c:b0:94:90:9f:40:89:b0:45:26:8f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.10' (RSA) to the list of known hosts.
Password: type_the_password
Code Listing 2.32: Add a new user
mybox ~ # useradd -g users -G lp,wheel,audio,cdrom,portage,cron -m john
mybox ~ # passwd john
New UNIX password: Set John's password
Retype new UNIX password: Type John's password again
passwd: password updated successfully
Last configuration touches
Start by selecting nearby mirrors either by defining the SYNC and GENTOO_MIRRORS variables in /etc/make.conf or by using mirrorselect. You can also define the number of concurrent compilation processes at this point.
Code Listing 2.33: Use mirrorselect and set MAKEOPTS
mybox ~ # emerge mirrorselect
mybox ~ # mirrorselect -i -o >> /etc/make.conf
mybox ~ # mirrorselect -i -r -o >> /etc/make.conf
(Usually, (the number of processors + 1) is a good value)
mybox ~ # echo 'MAKEOPTS="-j2"' >> /etc/make.conf
Now is a good time to enable or disable some USE flags. Run emerge -vpe world to list all currently installed packages and their enabled and disabled USE flags. Either edit /etc/make.conf or use the following command to define the USE variable:
Code Listing 2.34: View USE flags in use and enable or disable some
mybox ~ # emerge -vpe world
(Portage displays the packages and their USE flags, as an example, let's
disable fortran, and enable ipv6 and unicode)
mybox ~ # echo 'USE="nptl nptlonly ipv6 -fortran unicode"' >> /etc/make.conf
Recent versions of glibc use /etc/locale.gen to define locale settings.
Code Listing 2.35: Define locales
mybox ~ # cd /etc
mybox etc # nano -w locale.gen
mybox etc # locale-gen
Last but not least, you may want to alter the CFLAGS variable in your /etc/make.conf to optimise the code to your specific needs. Please note that using a long list of flags is rarely needed and can even lead to a broken system. It is recommended to specify the processor type in the march option and stick to -O2 -pipe.
You may also want to switch to ~x86. You should only do this if you can deal with the odd broken ebuild or package. If you'd rather keep your system stable, don't add the ACCEPT_KEYWORDS variable.
Code Listing 2.36: Last edit of make.conf
mybox etc # nano -w make.conf
(Set -march to your CPU type in CFLAGS)
CFLAGS="-O2 -march=athlon-xp -pipe"
(Only add the following if you know what you're doing)
ACCEPT_KEYWORDS="~x86"
You might want to recompile your whole system twice to make full use of your latest configuration changes. It would take quite a long time to complete and yield minimal speed benefits. You can let your system optimise itself gradually over time when new versions of packages are released. However, recompiling is a still good idea from the standpoint of maintaining system consistency. Please see the Gentoo GCC Upgrading Guide for a discussion on the benefits of ensuring a consistently built system and world.
Recompiling only the packages that have already been updated since the release or that are affected by your new USE flags will take enough time. You might also have to remove packages that block your upgrade. Look for "[blocks B ]" in the output of emerge -vpuD --newuse world and use emerge -C to remove them.
Code Listing 2.37: Update your packages
(Please note that the switch to ~x86 causes many packages to be upgraded)
mybox etc # emerge -vpuD --newuse world
(Take a good look at the package list and their USE flags,
remove blocking packages if any, and start the lengthy process)
mybox etc # time emerge -vuD --newuse world
(79 packages have been (re)compiled)
real 180m13.276s
user 121m22.905s
sys 36m31.472s
(Remerge libtool to avoid further potential problems)
mybox etc # emerge --oneshot libtool
(Update config files, make sure you do not let dispatch-conf
update config files you have edited)
mybox etc # dispatch-conf
(If perl has been updated, you should run the perl-cleaner script)
mybox etc # time perl-cleaner all
real 1m6.495s
user 0m42.699s
sys 0m10.641s
(In case of a major upgrade of python, you should run the python-updater script)
mybox etc # python-updater
What to do next
Depending on what your new Gentoo machine is supposed to do, you will probably want to install server applications or a desktop system. Just as an example, emerge gnome and emerge kde have been timed on the ~x86 system installed as describe above. Both have been installed from the same starting point.
You should check our documentation index to find out how to install and configure the applications of your choice.