分类: LINUX
2010-06-13 10:30:55
This guide contains all the 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.
Important: New users should read the as it gives a better overview about the installation process. The Quick Install guide is designed for experienced users who just need a checklist to follow. |
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.
Code Listing 1.1: Test box specs |
(The following specs and the timing information should help you determine |
2. Quick Install Guide
Download a CD from one of our . You can find the minimal CD ISO in releases/x86/current-iso/. The minimal installation CD is only useful for Internet-based installations. This guide will use the minimal CD.
the CD and boot it.
Press F2 at the boot screen to find out what boot options exist. You can either start gentoo or gentoo-nofb, the latter disables the framebuffer. If you booted the LiveCD, don't forget to add the nox option to prevent the X graphical environment from starting. Several options allow to enable or disable some features. If all goes well, your hardware will be detected and all modules will be loaded. If the kernel fails to boot properly or if your computer hangs during the boot procedure, you may have to experiment with different configurations. The safest way is probably to use the nodetect option and then load required modules explicitly.
Code Listing 2.1: Boot the minimal CD |
Gentoo Linux Installation LiveCD |
If you used the nodetect option, once booted, load the required modules. You need to enable networking and have access to your disks. The lspci command can help you identify your hardware.
Code Listing 2.2: Load required modules |
livecd root # lspci |
If your network does not work already, you can use net-setup to
configure your network. You might need to load support for your network card
using modprobe prior to the configuration. If you have ADSL, use
pppoe-setup and pppoe-start. For PPTP support, first edit
/etc/ppp/chap-secrets and /etc/ppp/options.pptp and
then use pptp
For wireless access, use iwconfig to set the wireless parameters and then use either net-setup again or run ifconfig, dhcpcd and/or route manually.
If you are behind a proxy, do not forget to initialize your system using export http_proxy, ftp_proxy and RSYNC_PROXY.
Code Listing 2.3: Configure networking the guided way |
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.
Code Listing 2.4: Configure networking the manual way |
livecd root # ifconfig eth0 192.168.1.10/24 |
The installation CD allows you to start an sshd server, add additional users, run irssi (a command-line chat client) and surf the web using links.
The most interesting feature is of course sshd. You can start it and then connect from another machine and cut and paste commands from this guide.
Code Listing 2.5: Start sshd |
livecd root # time /etc/init.d/sshd start |
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.
Code Listing 2.6: Set the root password |
livecd root # passwd |
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.
Code Listing 2.7: Connect to your new box from another PC |
(Use the IP address of your new box) |
Use fdisk or cfdisk to create your partition layout. You need at least a swap partition (type 82) and one Linux partition (type 83). The following scenario creates a /boot, a swap and a main partition as used in our handbook. Replace sda with your disk. Most systems ignore the bootable flag, but a few need it. Set this flag on your boot partition with fdisk's a command.
Code Listing 2.8: Create the partitions |
livecd ~ # fdisk /dev/sda |
Use mke2fs, mke2fs -j, mkreiserfs, mkfs.xfs and mkfs.jfs to create file systems on your Linux partitions. Initialize your swap partition using mkswap and swapon.
Code Listing 2.9: Create the file systems and activate swap |
(ext2 is all you need on the /boot partition) |
Mount the freshly created file systems on /mnt/gentoo. Create directories for the other mount points (like /mnt/gentoo/boot) if you need them and mount them too.
Code Listing 2.10: Mount the file systems |
livecd ~ # mount /dev/sda3 /mnt/gentoo |
First make sure your date and time is set correctly using date MMDDhhmmYYYY. Use UTC time.
Code Listing 2.11: Set the date and UTC time |
(Check the clock) |
Next, download a stage from one of our :
Code Listing 2.12: Download a stage3 archive |
livecd gentoo # links /main/en/mirrors.xml |
Go to /mnt/gentoo and unpack the stage using tar xjpf
Code Listing 2.13: Unpack the stage3 archive |
livecd gentoo # time tar xjpf stage3* |
Install the latest Portage snapshot. Proceed as for the stage3 archive: choose a nearby mirror from our , download the latest snapshot and unpack it.
Code Listing 2.14: Download the latest Portage snapshot |
livecd gentoo # cd /mnt/gentoo/usr |
Code Listing 2.15: Unpack the Portage snapshot |
livecd usr # time tar xjf portage-lat* |
Mount the /proc & /dev file systems, copy over the /etc/resolv.conf file, then chroot into your Gentoo environment.
Code Listing 2.16: Chroot |
livecd usr # cd / |
Set your time zone information by using the correct listing in /usr/share/zoneinfo.
Code Listing 2.17: Setting your timezone |
livecd / # ls /usr/share/zoneinfo |
Set your host name in /etc/conf.d/hostname and /etc/hosts. In the following example, we use mybox as host name and at.myplace as domain name. You can either edit the config files with nano or use the following commands:
Code Listing 2.18: Set host and domain name |
livecd / # cd /etc |
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 |
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 |
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. Either edit /etc/conf.d/net with nano or use the following commands:
Code Listing 2.21: Configure networking |
livecd etc # cd conf.d |
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 |
Edit /etc/conf.d/clock to define the time zone you used previously.
Code Listing 2.23: Edit /etc/conf.d/clock |
livecd conf.d # nano -w /etc/conf.d/clock |
Check the system configuration in /etc/rc.conf, /etc/conf.d/rc, /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 |
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 |
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) |
Emerge grub and configure it.
Code Listing 2.27: Emerge grub and edit its configuration file |
livecd conf.d # time emerge grub |
Code Listing 2.28: Example grub.conf |
default 0 |
Code Listing 2.29: Install grub |
livecd conf.d # grub |
Exit the chrooted environment, unmount all file systems and reboot:
Code Listing 2.30: Reboot |
livecd conf.d # exit |
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 |
Code Listing 2.32: Add a new user |
mybox ~ # adduser -g users -G lp,wheel,audio,cdrom,portage,cron -m john |
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 |
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 |
Recent versions of glibc use /etc/locale.gen to define locale settings.
Code Listing 2.35: Define locales |
mybox ~ # cd /etc |
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. Adding FEATURES="ccache" is also a good idea.
Code Listing 2.36: Last edit of make.conf |
mybox etc # nano -w make.conf |
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 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 |
(Install ccache) |
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.
Important: The following is only an example. It is in no way meant as a recommended setup. |
Code Listing 2.38: Emerge GNOME |
mybox etc # emerge -vp gnome |
Code Listing 2.39: Emerge KDE |
mybox etc # emerge -vp kde-meta |