This guide contains all commands you should use to complete a stage3 installation of Gentoo. You need a connection to the Internet to download the stage3 and Portage snapshots.
Timing output follows all commands that take more than a couple of seconds to finish. Commands were timed on an AMD 2000 1.66 Ghz PC with 512 MB of RAM and two SATA disks connected to a hardware controller.
(The following specs and the timing information should help you determine a rough estimate of the time you need to complete your install) # grep bogo /proc/cpuinfo bogomips : 3337.81 # hdparm -tT /dev/sda /dev/sda: Timing cached reads: 1100 MB in 2.00 seconds = 549.97 MB/sec Timing buffered disk reads: 224 MB in 3.01 seconds = 74.36 MB/sec # grep MemTotal /proc/meminfo MemTotal: 509248 kB
Download a CD from one of our
Press
Gentoo Linux Installation LiveCD http://www.gentoo.org Enter to Boot; F1 for kernels F2 for options. boot: gentoo-nofb(or in case of problems) boot: gentoo-nofb nodetect
If you used the
livecd root # lspci(Use lspci's output to identify required modules) (The following is an example, adapt it to your hardware) livecd root # modprobe 3w-9xxx livecd root # modprobe r8169
If your network does not work already, you can use
For wireless access, use
If you are behind a proxy, do not forget to initialize your system using
livecd root # net-setup eth0
Alternatively, you can start networking manually. The following example assigns the IP address 192.168.1.10 to your PC and defines 192.168.1.1 as your router and name server.
livecd root # ifconfig eth0 192.168.1.10/24 livecd root # route add default gw 192.168.1.1 livecd root # echo nameserver 192.168.1.1 > /etc/resolv.conf
The installation CD allows you to start an
The most interesting feature is of course
livecd root # time /etc/init.d/sshd start * Generating hostkey ...(sshd generates the key and displays more output) * starting sshd ... [ok] real 0m13.688s user 0m9.420s sys 0m0.090s
Now, set the root password on the liveCD so that you can connect to it from another PC. Please note that allowing root to connect over ssh is not recommended under normal circumstances. If you can't trust your local network, use a long and complex password, you should use it only once as it will disappear after your first reboot.
livecd root # passwd New UNIX password:type_a_password Retype new UNIX password:type_a_password passwd: password updated successfully
Now, you can start a terminal on another PC and connect to your new box, follow the rest of this guide in another window, and cut and paste commands.
(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
Use
livecd ~ # fdisk /dev/sda(The rest of this guide uses the following partitioning scheme) livecd ~ # fdisk -l /dev/sda Disk /dev/sda: 599.9 GB, 599978409984 bytes 255 heads, 63 sectors/track, 72943 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 12 96358+ 83 Linux /dev/sda2 13 110 787185 82 Linux swap / Solaris /dev/sda3 111 72943 585031072+ 83 Linux
Use
(ext2 is all you need on the /boot partition) livecd ~ # mke2fs /dev/sda1(Let's use ext3 on the main partition) livecd ~ # mke2fs -j /dev/sda3(Create and activate swap) livecd ~ # mkswap /dev/sda2 && swapon /dev/sda2
Mount the freshly created file systems on
livecd ~ # mount /dev/sda3 /mnt/gentoo livecd ~ # mkdir /mnt/gentoo/boot livecd ~ # mount /dev/sda1 /mnt/gentoo/boot
First make sure your date and time is set correctly using
(Check the clock) livecd ~ # date Mon Mar 6 00:14:13 UTC 2006(Set the current date and time if required) livecd ~ # date 030600162006(Format is MMDDhhmmYYYY) Mon Mar 6 00:16:00 UTC 2006
Next, download a stage from one of our
livecd ~ # cd /mnt/gentoo livecd gentoo # links http://www.gentoo.org/main/en/mirrors.xml(Pick a mirror, move to the releases/x86/current/stages directory highlight the stage3 of your choice, probably stage3-i686-2006.1.tar.bz2 and press D to download it) (Or download it directly with wget without choosing a nearby mirror) livecd ~ # cd /mnt/gentoo livecd gentoo # wget http://gentoo.osuosl.org/releases/x86/current/stages/stage3-i686-2006.1.tar.bz2
livecd gentoo # time tar xjpf stage3* real 1m13.157s user 1m2.920s sys 0m7.230s
Install the latest Portage snapshot. Proceed as for the stage3 archive: choose
a nearby mirror from our
livecd gentoo # cd /mnt/gentoo/usr livecd usr # links http://www.gentoo.org/main/en/mirrors.xml(Pick a mirror, move to the snapshots/ directory, highlight portage-latest.tar.bz2 and press D to download it) (Or download it directly with wget without choosing a nearby mirror) livecd gentoo # cd /mnt/gentoo/usr livecd usr # wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2
livecd usr # time tar xjf portage* real 0m51.523s user 0m28.680s sys 0m12.840s
Mount the
livecd usr # cd / livecd / # mount -t proc proc /mnt/gentoo/proc livecd / # cp -L /etc/resolv.conf /mnt/gentoo/etc/ livecd / # chroot /mnt/gentoo /bin/bash livecd / # env-update && source /etc/profile >>> Regenerating /etc/ld.so.cache...
Set your time zone information by copying the correct file from
(Using Brussels as an example) livecd / # cp /usr/share/zoneinfo/Europe/Brussels /etc/localtime livecd / # date Wed Mar 8 00:46:05 CET 2006
Set your host name in
livecd / # cd /etc livecd etc # echo "127.0.0.1 mybox.at.myplace mybox localhost" > hosts livecd etc # sed -i -e 's/HOSTNAME.*/HOSTNAME="mybox"/' conf.d/hostname(Use defined host name and check) livecd etc # hostname mybox livecd etc # hostname -f mybox.at.myplace
Install a kernel source (usually
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
Edit your
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
livecd etc # cd conf.d livecd conf.d # echo 'config_eth0=( "192.168.1.10/24" )' >> net livecd conf.d # echo 'routes_eth0=( "default via 192.168.1.1" )' >> net livecd conf.d # rc-update add net.eth0 default(If you compiled your network card driver as a module, add it to /etc/modules.autoload.d/kernel-2.6) livecd conf.d # echo r8169 >> /etc/modules.autoload.d/kernel-2.6(If you want to reconnect via ssh after you have rebooted your new box:) livecd conf.d # rc-update add sshd default
Set the root password using
livecd conf.d # passwd New UNIX password:type_the_password Retype new UNIX password:type_the_password_again passwd: password updated successfully
Check the system configuration in
livecd conf.d # nano -w /etc/rc.conf livecd conf.d # nano -w /etc/conf.d/rc livecd conf.d # nano -w /etc/conf.d/keymaps livecd conf.d # nano -w /etc/conf.d/clock
Install a system logger like
livecd conf.d # time emerge syslog-ng vixie-cron real 1m52.699s user 1m1.630s sys 0m35.220s livecd conf.d # rc-update add syslog-ng default livecd conf.d # rc-update add vixie-cron default
Install the necessary file system tools (
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 # USE="-X" emerge rp-pppoe(If you need PPPoE ADSL connectivity)
Emerge
1. Using grub
livecd conf.d # time emerge grub real 1m8.634s user 0m39.460s sys 0m15.280s livecd conf.d # nano -w /boot/grub/grub.conf
default 0 timeout 10 title=Gentoo root (hd0,0) kernel /boot/kernel root=/dev/sda3
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 0x83 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
Now, proceed with the
2. Using lilo
livecd conf.d # time emerge lilo real 0m47.016s user 0m22.770s sys 0m5.980s livecd conf.d # nano -w /etc/lilo.conf
boot=/dev/sda prompt timeout=50 default=gentoo image=/boot/kernel label=Gentoo read-only root=/dev/sda3
livecd conf.d # lilo Added Gentoo *
Exit the chrooted environment, unmount all file systems and reboot:
livecd conf.d # exit livecd / # umount /mnt/gentoo/proc /mnt/gentoo/boot /mnt/gentoo livecd / # reboot(Don't forget to remove the CD)
Log in as
(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
mybox ~ # adduser -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
Start by selecting nearby mirrors either by defining the
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
mybox ~ # emerge -vpe world(Portage displays the packages and their USE flags, as an example, let's disable ipv6 and fortran, and enable userlocales and unicode) mybox ~ # echo 'USE="nptl nptlonly -ipv6 -fortran userlocales unicode"' >> /etc/make.conf
If you enabled the
Later versions of glibc ignore the userlocales USE flag and use
mybox ~ # cd /etc(For versions of glibc with the userlocales USE flag) mybox etc # nano -w locales.build(For recent versions of glibc, convert locales.build) mybox etc # grep '^[^#].*' locales.build | sed 's:/: :' >locale.gen mybox etc # rm locales.build mybox etc # nano -w locale.gen
Last but not least, you may want to alter the
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
mybox etc # nano -w make.conf(Set -march to your CPU type in CFLAGS) CFLAGS="-O2 -march=athlon-xp -pipe"(Add the following line) FEATURES="parallel-fetch ccache"(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
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
(Install ccache) mybox etc # emerge ccache(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 libtool(Update config files, make sure you do not let etc-update update config files you have edited) mybox etc # etc-update(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
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,
You should check our
mybox etc # emerge -vp gnome(Look at the list of packages and their USE flags, then edit make.conf if required. mybox etc # nano -w /etc/make.conf(The following USE flags have been defined) USE="nptl nptlonly -ipv6 -fortran unicode svg hal dbus \ -kde -qt3 -qt4 -arts -eds -esd gnome gstreamer gtk -xmms firefox" mybox etc # time emerge gnome(326 packages have been emerged) real 520m44.532s user 339m21.144s sys 146m22.337s
mybox etc # emerge -vp kde-meta(Look at the list of packages and their USE flags, then edit make.conf if required. mybox etc # nano -w /etc/make.confThe following USE flags have been defined) USE="nptl nptlonly -ipv6 -fortran unicode svg hal dbus \ kde qt3 qt4 -arts -eds -esd -gnome -gstreamer -gtk -xmms -firefox" mybox etc # time emerge kde-meta(391 packages have been emerged) real 1171m25.318s user 851m26.393s sys 281m45.629s