Build a Fast and Bulletproof Gentoo Linux System: Gentoo 2004.3 Stable Branch
Transcription
Build a Fast and Bulletproof Gentoo Linux System: Gentoo 2004.3 Stable Branch
Build a Fast and Bulletproof Gentoo Linux System: Stage 1 NPTL Installation on a Stage 3 Tarball Using GCC 3.4.3 Gentoo 2004.3 Stable Branch Alternative Installation Guide Revision 0.1.1 January 19, 2005 Originally Posted on the Documentation Tips & Tricks section of the Gentoo Discussion Forums by “Bob P” on January 5, 2005. The text of this document is © 2005 by Bob Predaina and may be distributed freely subject to the terms of the GPL. All other rights reserved. Faster than a Speeding Bullet... More Powerful than a Locomotive! How To Build a Fast and Bulletproof Gentoo System: Stage 1 Installation on a Stage 3 Tarball Using GCC 3.4.3 Warning: This is an advanced installation method. The amount of time required for you to complete this type of installation will equal or exceed that of any other Gentoo installation method. Your time will be well invested, though, as the result will be a very stable Gentoo system. This installation method may prove to be somewhat difficult and cumbersome for users who are new to Gentoo. It will prove especially painful for users who plan to install Gentoo on old hardware. Introduction: At the time of this writing, the current release of Gentoo is 2004.3. When installing 2004.3, any Gentoo installation that is performed with a Stage 1 or a Stage 2 tarball suffers from two problems: circular dependencies within the base system, and the potential to leave behind unwanted files from the stage tarball because /var/db/pkg is incomplete. Neither of these problems is encountered when installation is performed with a Stage 3 tarball. As Rac noted in a post at the Gentoo Discussion Forums, “There are some 80+ packages in a stage1ball that are not listed in /var/db/pkg. Why? When you do your ‘emerge system’, you would want your new toolchain to be used to compile all software. If portage sees that a particular version from the stageball is still current, it will omit it. The solution that somebody apparently chose was to make portage forget that most of this software is installed at all, which has the unfortunate side effect of making portage be unable to clean it when your ‘emerge system’ finishes.” So it seems that there are some good reasons to never install from a Stage 1 tarball, and some good reasons to always install from a Stage 3 tarball. The good news is that you can perform a Stage 1 installation using a Stage 3 tarball and have the best of both worlds. Objective: This Installation Guide will describe how to perform a “Stage 1 on 3” installation of Gentoo on a Pentium-class x86 platform using 2004.3 installation media, a single CD-ROM drive and a single hard disk. It will take advantage of the latest 2.6 kernels, NPTL threading, udev, and the latest GCC 3.4.3 compiler. As you read this, you might be thinking: “Why a Pentium-class PC?” The answer is simple: A Pentium-class PC is the only computer that I have left that doesn’t already have Gentoo installed on it! 8^D Besides, I’m thinking it would make a nice router... If this Installation Guide looks at all familiar -- it should! It is heavily based on a combination of the Gentoo Installation Handbook and ali3xn’s superb Stage 1 and NPTL tutorial, and a collection of tweaks to modify the tutorial to make it suitable for installation using a Stage 3 tarball. The adaptations that were required to make ali3nx’s method work well with a Stage 3 tarball became extensive enough that it seemed worthwhile to split this topic off from the Stage 1 with NPTL thread for the purpose of clarity. Although most of this should look familiar, I'm adding my own ideas about specific optimizations that need to be made to take advantage of new features offered by the GCC 3.4.3 compiler. Stage 1 NPTL on Stage 3 Tarball To perform a Stage 1 Installation on a Stage 3 Tarball, follow these steps: 1. Download and Burn the Minimal Installation CD The .ISO image required for the hardware used in this example is: http://gentoo.osuosl/releases/x86/2004.3/livecd/install-x86-minimal-2004.3-r1.iso 2. Boot Using the Minimal Installation CD At the “boot:” prompt, press <Enter> to select the default Gentoo kernel. 3. Configure LAN Card We’re assuming that your LAN card has been recognized and that you can obtain a LAN connection via DHCP. # dhcpcd eth0 4. Configure Your Hard Disk 4.1 View the Hard Drive’s Operational Parameters. In this example we will assume that only one hard disk will be installed on the system. It will be recognized by Gentoo as /dev/hda. We will start off by viewing the default disk parameters at boot: # hdparm /dev/hda /dev/hda: multcount IO_support unmaskirq using_dma keepsettings readonly readahead geometry = = = = = = = = 16 (on) 0 (default 16-bit) 0 (off) 1 (on) 0 (off) 0 (off) 256 (on) 16383/255/63, sectors = 120034123776, start = 0 # hdparm –i /dev/hda /dev/hda: Model=WDC WD1200JB-00GVA0, FwRev=08.02D08, SerialNo=WD-WMAL92634373 Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq} RawCHS=16383/16/63, TrkSize=57600, SectSize=600, ECCbytes=74 BuffType=DualPortCache, BuffSize=8192kB, MaxMultSect=16, MultSect=16 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=234441648 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120} PIO modes: pio0 pio1 pio2 pio3 pio4 DMA modes: mdma0 mdma1 mdma2 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5 AdvancedPM=no, WriteCache=enabled Drive conforms to: device does not report version: * signifies the current active mode 2 Stage 1 NPTL on Stage 3 Tarball 4.2 Tweak the Hard Disk Parameters with hdparm: In this example we’re using a WD1200JB. Its possible to get a little better performance out of this drive by issuing a few parameters with hdparm. The following parameters work well with this drive: # hdparm –a256A1c1d1m16u1 /dev/hda /dev/hda: setting fs readahead to 256 setting 32-bit IO_support flag to 1 setting multcount to 16 setting unmaskirq to 1 (on) setting using_dma to 1 (on) setting drive read-lookahead to 1 (on) multcount = 16 (on) IO_support = 1 (32-bit) unmaskirq = 1 (on) using_dma = 1 (on) readahead = 256 (on) 4.3 Test the Hard Drive’s Performance: Typical results for a Pentium-class PC without UDMA: # hdparm –tT /dev/hda /dev/hda: Timing cached reads: 144 MB in 2.04 seconds = 70.60 MB/sec Timing buffered disk reads: 26 MB in 2.65 seconds = 9.81 MB/sec Typical results for a Pentium 3 with UDMA66: # hdparm –tT /dev/hda /dev/hda: Timing cached reads: 520 MB in 2.01 seconds = 258.75 MB/sec Timing buffered disk reads: 114 MB in 3.01 seconds = 37.90 MB/sec 4.4 Partition the Hard Drive 4.4.1 Display the Partition Information Technically, the syntax of this command is used to change the partition information, but on an un-partitioned drive it will display the partition information that is available. # fdisk /dev/hda The number of cylinders for this disk is set to 14593. There is nothing wrong with that, but this is larger than 1024, and in certain setups could cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): p 3 Stage 1 NPTL on Stage 3 Tarball Disk /dev/hda: 120.0 GB, 120034123776 bytes 255 heads, 63 sectors/track, 14593 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System 4.4.2 Plan Our Partition Scheme: To keep it simple, we’re going to use the following partition scheme. I’ll leave out the details, assuming that you know how to partition your hard disk. Partition /dev/hda1 /dev/hda2 /dev/hda3 File System ReiserFS 3.6 (swap) ReiserFS 3.6 ID 83 82 83 Size 100 MB 512 MB Remainder Description Boot partition Swap partition Root Partition 4.4.3 Partition the Hard Disk (Boring details omitted in the interest of brevity) 4.4.4 Verify the Partition Configuration: Command (m for help): p Disk /dev/hda: 120.0 GB, 120034123776 bytes 255 heads, 63 sectors/track, 14593 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device /dev/hda1 /dev/hda2 /dev/hda3 Boot * Start 1 14 77 End 13 76 14593 Blocks 104391 506047+ 116607802+ Id 83 82 83 System Linux Linux swap Linux 4.4.5 Exit Fdisk and Save the Partition Layout: Press “w” to write the partition table to disk and exit fdisk. Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks 4.5 Install File Systems. This example covers the installation of Reiser FS 3.6 on the /boot and /root partitions, and swap on the /swap partition. 4.5.1 Install Reiser FS on /dev/hda1 and /dev/hda3: # mkreiserfs /dev/hda1 && mkreiserfs /dev/hda3 You will need to answer “Y” when asked if you want to continue installing Reiser FS on the hard disk. 4 Stage 1 NPTL on Stage 3 Tarball 4.5.2 Install the swap partition on /dev/hda2: # mkswap /dev/hda2 && swapon /dev/hda2 4.6 Mount the File Systems. # mount /dev/hda3 /mnt/gentoo # mkdir /mnt/gentoo/boot # mount /dev/hda1 /mnt/gentoo/boot 5. Install the Gentoo System Files 5.1 Download the Stage 3 Tarball from the Internet. Go to the Gentoo mount point on your hard disk: # cd /mnt/gentoo We will need to download 2 files from the mirrors: The Stage 3 tarball and its checksum file. These files are located on the mirrors in the following directory: /releases/x86/2004.3/stages/x86/ We will download the following four files using the “wget” command at the bash prompt. The entire command must be typed on one line: # wget http://gentoo.osuosl.org/releases/x86/2004.3/stages/x86/stage3-x862004.3.tar.bz2 # wget http://gentoo.osuosl.org/releases/x86/2004.3/stages/x86/stage3-x862004.3.tar.bz2.md5 If you need to check the list of Gentoo Mirrors, go to: http://www.gentoo.org/main/en/mirrors.xml (If your architecture is not x86 you will need to change the path and filename to suit your needs.) 5.2 Verify the md5sum of the Tarballs. # md5sum -c stage3-x86-2004.3.tar.bz2.md5 stage3-x86-2004.3.tar.bz2: OK 5.3 Unpack the Stage 3 Tarball. tar –xjpvf stage3-x86-2004.3.tar.bz2 Now is a good time to take a break, as this step will take a little while… 5 Stage 1 NPTL on Stage 3 Tarball 5.4 Install Portage 5.4.1 Download a Fresh Portage Snapshot from the Internet. # wget http://gentoo.osuosl.org/snapshots/<most_recent_snapshot>.tar.bz2 5.4.2 Extract the Portage Snapshot tar –xjvf /mnt/gentoo/<portage_snapshot>.tar.bz2 –C /mnt/gentoo/usr The Portage snapshot files are named in the format "portage-YYYYMMDD.tar.bz2", where YYYY, MM, and DD represent the numbers of the year, month, and day that the snapshot was created. As I write this Installation Guide, the most recent portage snapshot is portage-20050101.tar.bz2, so the commands to download, verify and extract the snapshot would look like this: # # # # wget http://gentoo.osuosl.org/snapshots/portage-20050101.tar.bz2 wget http://gentoo.osuosl.org/snapshots/portage-20050101.tar.bz2.md5sum md5sum –c portage-20050101.tar.bz2.md5sum tar –xjvf /mnt/gentoo/portage-20050101.tar.bz2 –C /mnt/gentoo/usr Some of these steps will take a while to complete. 6. Configure the Gentoo Base System 6.1 Copy DNS Information Copy the DNS information in /etc/resolv.conf to ensure that networking works in our new Gentoo environment. # cp –L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf 6.2 Mount the proc Filesystem We will mount the /proc file system to allow our Gentoo installation to use kernel-provided information within the chrooted environment. # mount -t proc none /mnt/gentoo/proc 6.3 Chroot into the New Environment # chroot /mnt/gentoo /bin/bash # env-update && source /etc/profile 6.4 Set the Date and Time 6.4.1 Set the Correct Date and Time. The date command is executed using the format MMDDHHMMYYYY, where the MM is the month, DD is the day, HHMM is the time in hours and minutes in 24-hour format, and YYYY is the year. As I type this Installation Guide it is Sunday January 2, 2005 at 19:30. 6 Stage 1 NPTL on Stage 3 Tarball # date 010219302005 Sun Jan 2 19:30:00 Local time zone must be set--see zic manual page 2005 6.4.2 Set the Time Zone Symlink. This example displays the available time zone selections for the Western Hemisphere: # ls /usr/share/zoneinfo/America In this example we’ll set the local time zone to Central Time for Chicago, IL. To do this, first remove the symlink to the default time zone, and then replace it with a symlink to the local time zone. Then issue the date command without any parameters to verify the results. # rm /etc/localtime # ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime # date Sun Jan 2 19:32:50 CST 2005 6.5 Configure USE Flags, Portage Options, and Compiler Options: /etc/make.conf In this example, we're compiling for the ~x86 architecture and a Pentium-class i586 sub-architecture. Our CHOST settings will be i586-pc-linux-gnu. I am not going to say much on the subject of USE flags other than to say that the current state of USE flag documentation is rather incomplete. At this time there are over 100 USE flags which have been left undocumented. The inclusion of the nptl, ithreads, and pthreads USE flags and the exclusion of the nptlonly USE flag is intentional, in order to provide both NPTL threading support in glibc as well as fallback support for linuxthreads (pthreads). These USE flags are necessary for the system and should not be changed. Feel free to add or remove other USE flags to suit your specific system requirements. Note: This Installation Guide uses the Gentoo stable branch as default. If you choose to use the testing branch, proceed at your own risk. # cat /etc/make.conf CHOST="i586-pc-linux-gnu" CFLAGS="-O2 -march=pentium -pipe” CXXFLAGS=${CFLAGS} # “x86” refers to the stable software branch # “~x86” refers to the testing software branch ACCEPT_KEYWORDS="x86" PORTAGE_TMPDIR=/var/tmp PORTDIR=/usr/portage DISTDIR=${PORTDIR}/distfiles PKGDIR=${PORTDIR}/packages PORT_LOGDIR=/var/log/portage PORTDIR_OVERLAY=/usr/local/portage GENTOO_MIRRORS="<your mirror goes here> http://gentoo.osuosl.org http://www.ibiblio.org/pub/Linux/distributions/gentoo" SYNC="rsync://rsync.gentoo.org/gentoo-portage" RSYNC_RETRIES="3" RSYNC_TIMEOUT=180 MAKEOPTS="-j2" 7 Stage 1 NPTL on Stage 3 Tarball PORTAGE_NICENESS=3 AUTOCLEAN="yes" FEATURES="candy ccache distlocks sandbox" CCACHE_SIZE="512M" RSYNC_EXCLUDEFROM=/etc/portage/rsync_excludes USE="acpi cups ithreads ldap nptl pam pthreads python readline samba ssl tcpd" 6.6 Additional Portage Configuration 6.6.1 Create Portage Directories The sample /etc/make.conf file listed above specifies directories for Portage log files and overlays that are not included as part of a standard Gentoo installation. If you are going to use the logging and overlay functions listed in the sample make.conf file, then you will need to create to additional directories on your system. # mkdir /var/log/portage # mkdir /usr/local/portage 6.6.2 Package Keywords - Enabling GCC 3.4.3 in the Stable Branch Skip this step and proceed to the next section if you have configured your system to use the “~x86” testing branch. At the time that I write this Installation Guide, GCC 3.4.3 is part of the unstable or “testing” branch in Portage. If you will be using the Gentoo “x86” stable branch, then the default compiler will be GCC 3.3.x. To get the best performance out of Gentoo, this Installation Guide will configure Portage to enable the use of GCC 3.4.3 and some other toolkit components, even though they are currently classified in the testing branch. To configure a stable branch system to utilize a testing branch ebuild, we need to let Portage know that we have approved this subset of the testing branch for use on our system. This is accomplished by specifying the name of the package and the applicable keyword in the /etc/portage/package.keywords file. We will enable support for four testing branch ebuilds in our system. # cat /etc/portage/package.keywords sys-devel/gcc ~x86 sys-devel/gcc-config ~x86 sys-libs/libstdc++-v3 ~x86 sys-libs/glibc ~x86 6.6.3 Update the Portage Tree Update our portage snapshot to include the current portage tree. emerge --sync 6.7 Activate User Locales When compiling glibc (we’ll do this in an upcoming step), Gentoo’s default behavior is to compile a full set of all of the available user locales. We will activate the userlocales USE flag to limit the compilation of userlocales to those that we specify. Limiting the scope of userlocales will save us a tremendous amount of time when we recompile glibc in an upcoming step. 8 Stage 1 NPTL on Stage 3 Tarball 6.7.1 Activate the userlocales USE flag for glibc # cat /etc/portage/package.use sys-libs/glibc userlocales 6.7.2 Specify the User locales to build. Edit the /etc/locales.build file with your favorite editor: I’m located in the USA, so I’ll use the following values: # cat /etc/locales.build en_US/ISO-8859-1 en_US.UTF-8/UTF-8 7. Build the Toolkit 7.1 Build the Toolkit: GCC 3.3.4 To enable NPTL support we are required to use a 2.6 kernel and linux26-headers. Unfortunately, the 2004.3 Stage 3 tarball includes linux-headers, which act as a blocker when attempting to emerge linux26-headers. In building the toolkit, we will first unmerge linux-headers and then emerge linux26-headers. The linux kernel headers are typically updated only when updating a version of glibc. We will recompile glibc after emerging linux26-headers. We will also emerge new versions of binutils and upgrade to the current version of gcc when building our toolkit. # env-update && source /etc/profile # emerge -C linux-headers # emerge linux26-headers gcc-config glibc binutils gcc Or if you prefer a one-liner: # env-update && source /etc/profile && emerge -C linux-headers && emerge linux26-headers gcc-config glibc binutils gcc This is a good opportunity to take an extended break, as these instructions will take quite some time to complete. 7.2 Re-Build the Toolkit: GCC 3.4.3 After emerging a new version of GCC, we need to pause for a moment and think about what we’ve done. We’ve just used GCC 3.3.4 and a toolkit built with GCC 3.3.4 to compile GCC 3.4.3. Before we spend any more time building our Gentoo system we should rebuild the entire toolkit, compiling it with GCC 3.4.3. To do this we need to examine /etc/make.conf and make changes to the CFLAGS statements in order to take advantage of the new performance-enhancing features of GCC 3.4.3. After making necessary updates to /etc/make.conf we need to rebuild the toolkit using the new GCC 3.4.3 compiler. The result will be a 3.4.3 toolkit, compiled by a 3.4.3 toolkit that was built with a 3.3.4 toolkit. Clear as mud? 9 Stage 1 NPTL on Stage 3 Tarball 7.2.1 Update /etc/make.conf Here are some settings for /etc/make.conf that may be worth considering. They are the actual CFLAGS that I used to build my systems and have proven reliable on multiple installations. They include extreme levels of code optimization (notice the -O3 flag), and some very safe and stable performance-enhancing CFLAGS. Depending upon your individual hardware, you may have to simplify some of the CFLAGS settings. Note that the referenced architecture in this example is Intel Pentium. CFLAGS="-O3 -march=pentium -mtune=pentium -fforce-addr -momit-leaf-framepointer -fomit-frame-pointer -ftracer -pipe" CXXFLAGS=”${CFLAGS} -fvisibility-inlines-hidden” If you don’t feel comfortable using such extreme levels of optimization, you can ease-up on the CFLAGS settings and fall back to a less-optimized system. This will save you some compile time, at the expense of some system performance. You’ll still be getting most of the benefits of GCC 3.4.3, so this isn’t a bad compromise. This may be a better approach for those who don’t want to be on the bleeding edge or don’t want to spend time troubleshooting. CFLAGS="-O2 -march=pentium -mtune=pentium -pipe” CXXFLAGS=${CFLAGS} 7.2.2 Configure the Default C Compiler Although we have emerged GCC 3.4.3, it has not been automatically installed as our default compiler. If you have any doubts about this, take a quick peek at the output of “emerge info” or “gcc-config -l”. Although GCC 3.4.3 has already been ermerged, GCC 3.3.4 is still installed as out default compiler: # gcc-config -l [1] i586-pc-linux-gnu-3.3.4 * [2] i586-pc-linux-gnu-3.4.3 [3] i586-pc-linux-gnu-3.4.3-hardened [4] i586-pc-linux-gnu-3.4.3-hardenednopie [5] i586-pc-linux-gnu-3.4.3-hardenednossp Change the default compiler to gcc 3.4.3 by issuing the following command: # gcc-config 2 7.2.3 Update the System Environment An additional command updates our system environment: # env-update && source /etc/profile 7.2.4 Rebuild the System Toolkit Now its time to rebuild the toolkit. We’ll start off by recompiling glibc, binutils, gcc, and by updating portage. This will rebuild our GCC 3.4.3 compiling toolkit (which had previously been compiled with GCC 3.3.4) with the GCC 3.4.3 compiler, taking advantage of our new USE flags and CFLAGS compiler settings. # emerge glibc binutils gcc portage 10 Stage 1 NPTL on Stage 3 Tarball Upon completion of the rebuild of the compiling toolkit, we will recompile the entire system to assure that our toolkit and entire system has been compiled using GCC 3.4.3 and our hardware-specific settings. The result will be a 3.4.3 toolkit and an entire system that is built with a 3.4.3 toolkit, that was built with a 3.4.3 toolkit. ;) # emerge -e system 7.2.5 Summary Although these command have been broken down into separate steps for the purpose of clarity, they can be concatenated into three steps. The one-liners in Steps 1 and 3 will take quite some time to complete, and represent good opportunities for you to take an extended break while Gentoo does its thing. Step 1: # env-update && source /etc/profile && emerge -C linux-headers && emerge linux26-headers && emerge gcc-config glibc binutils gcc Step 2: update your USE flags and CFLAGS in /etc/make.conf Step 3: # gcc-config 2 && env-update && source /etc/profile && emerge glibc binutils gcc portage && emerge -e system 7.3 Build the World 7.3.1 Emerge Programs Now its time to add a few useful packages to our world profile: # emerge syslog-ng xinetd grub vixie-cron reiserfsprogs sysfsutils udev dhcpcd hotplug coldplug gentoolkit # emerge --nodeps acpid ntp 7.3.2 Update the Environment # # # # # # # # rc-update rc-update rc-update rc-update rc-update rc-update rc-update rc-update add add add add add add add add syslog-ng default net.eth0 default vixie-cron default xinetd default sshd default hotplug default coldplug default acpid default or if you prefer a one-liner: # rc-update add syslog-ng default && rc-update add net.eth0 default && rcupdate add vixie-cron default && rc-update add xinetd default && rc-update add sshd default && rc-update add hotplug default && rc-update add coldplug default && rc-update add acpid default 11 Stage 1 NPTL on Stage 3 Tarball 7.3.3 Configure the NTP Client In the previous steps we emerged a Network Time Protocol client to allow us to use NTP timeservers to synchronize our system clock. In this step we’ll configure the ntp-client to eliminate clock skew: # rc-update add ntp-client default && ntpdate -b -u pool.ntp.org 8. Kernel 8.1 Download the Kernel The decision to enable NPTL support requires that we use a 2.6 kernel. You are free to choose any flavor of 2.6 kernel that you like. In this example, we’ll be using the Gentoo Development Sources kernel. Note that a 2.4 kernel will not work properly with this Installation Guide. # emerge gentoo-dev-sources 8.2 Build the Kernel Symlink # rm /usr/src/linux # cd /usr/src # ln -s linux-2.6.10-gentoo-r2 linux 8.3 Configuration 8.3.1 Edit /etc/conf.d to Enable udev Support Edit your /etc/conf.d/rc file so that it contains the following statements: RC_NET_STRICT_CHECKING="no" RC_DEVICES="udev" RC_DEVICE_TARBALL="no" 8.3.2 Configure Kernel Options If you’re following this Installation Guide, we’re going to assume that you want the best performance from your system, and that you’ll be using a custom-compiled kernel instead of genkernel. When configuring your kernel, be sure to include support for hotplug firmware loading. Also be sure to remove devfs filesystem support, as we are designing udev support into our system. Configure the kernel: # cd /usr/src/linux # make menuconfig 8.3.3 Compile the Kernel To compile your kernel and install the kernel and selected modules, issue the following command. I find that this one works a bit better than some of the other one-liner kernel compilation commands. If you should run into a problem where kernel compilation fails, its easy to determine where the problem occurred. In addition, this command will also install the kernel for you. 12 Stage 1 NPTL on Stage 3 Tarball # make && make modules && make modules_install && make install 9. Configure the System 9.1 Networking - Configuring Network Adapters Configure your network adapters as recommended in the Gentoo Installation Handbook. In our case, we’ll use DHCP: # cat /etc/conf.d/net iface_eth0=”dhcp” dhcpcd_eth0="-t 10" If this isn’t suitable for you, consider these options as listed in the GIH: # (For DHCP) iface_eth0="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. dhcpcd_eth0="-HD" # 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 dhcpcd_eth0="-N" #(For static IP) iface_eth0="192.168.0.2 broadcast 192.168.0.255 netmask 255.255.255.0" gateway="eth0/192.168.0.1" #(For rp-pppoe) iface_eth0="up" 9.2 Networking – Set Up Hostnames and Domainnames The following hostname and domainname locations referenced in the Gentoo Installation Handbook and some of the other HowTo appear to have been deprecated. The first example in each of the following two sections uses the old configuration method, which has been deprecated by recent dev-sources kernels but this is not yet reflected in many of the installation guides. The second option in each of the following two examples is more current: 9.2.1 Set Your Hostname The following examples provide instruction for setting the hostname on your Gentoo box. Since we’re installing Gentoo on an old Pentium-class PC, we’ll use the “boatanchor” as the hostname and “mydomain.com” as the domainname in this example. # echo boatanchor > /etc/hostname or # cat /etc/conf.d/hostname HOSTNAME=”boatanchor” 13 Stage 1 NPTL on Stage 3 Tarball 9.2.2 Set Your Domainname # echo mydomain.com > /etc/dnsdomainname # echo nis.mydomain.com > /etc/nisdomainname or # cat /etc/conf.d/domainname OVERRIDE=1 DNSDOMAIN=”mydomain.com” NISDOMAIN=”nis.mydomain.com” 9.2.3 Update /etc/hosts If nameservers on your network handle all name resolution, then you can skip this step. If your PC is a standalone system, or if your PC has a static IP address and you don’t have DNS entries for your machine in a nameserver somewhere on your network, then you should specify the following information in the /etc/hosts file. 127.0.1 static.ip.addr.ess localhost.localdomain boatanchor.mydomain.com localhost boatanchor The value of “static.ip.addr.ess” needs to be substituted with the IP address of your Gentoo box. For example, if your Gentoo box’s IP address is 192.168.0.5, your /etc/hosts file should contain the following lines: 127.0.1 192.168.0.5 localhost.localdomain boatanchor.mydomain.com localhost boatanchor 9.2.4 Add domainname to the Default Runlevel # rc-update add domainname default 9.2.5 Verify the Results # hostname -f boatanchor.mydomain.com 9.3 Gensplash For all of you eye-candy addicts who can’t live without it, here’s the section where we add Gensplash to give us those ultra-cool ☺ framebuffer images in our consoles. Because some of us have really big monitors, we’ll configure splash screens at your choice of 1024x768, 1280x1024, and 1600x1200 resolutions: # emerge splashutils && splash_geninitramfs -v -g /boot/fbsplash-emergence1024x768 -r 1024x768 emergence && splash_geninitramfs -v -g /boot/fbsplashemergence-1280x1024 -r 1280x1024 emergence && splash_geninitramfs -v -g /boot/fbsplash-emergence-1600x1200 -r 1600x1200 emergence && rc-update add splash default 14 Stage 1 NPTL on Stage 3 Tarball 9.4 Grub Bootloader 9.4.1 Configuration - Grub.conf To boot our installation of Gentoo Linux we’ll need to configure a boot menu for the Grub Bootloader. Use your favorite text editor to create the /boot/grub/grub.conf file. In this case we’ll use nano: # cd /boot/grub # nano -w grub.conf You can either cut and paste the following text into the file, or type it in manually. Note that the lines that are indented are actually word-wrapped continuations of the previous line of text. When you type them, the entire string should be put on one line in your text editor. For example, the lines beginning with the word “kernel” and ending with the words “splash=verbose,theme:emergence” need to be typed on one line. In this example, we’re using the vesafb-tng video driver, and the video= statements are formatted accordingly. # Grub boot menu configuration file # # Boot automatically after 30 secs. timeout 30 # By default, boot the second entry (grub starts counting at zero). default 1 # Fallback to the first entry. fallback 0 # Use default Grub Splash image # splashimage=(hd0,0)/grub/splash.xpm.gz # # Use custom (downloaded) Gentoo Splash Image splashimage=(hd0,0)/grub/gentoo.xpm.gz # Boot Gentoo Linux (no framebuffer) title Gentoo-2.6.10-r2 root (hd0,0) kernel (hd0,0)/vmlinuz ro root=/dev/hda3 video=vesafb:ywrap,pmipal,1024x76816@85 # Boot Gentoo Linux at 1024x768 framebuffer resolution title Gentoo-2.6.10-r2, 1024x768 root (hd0,0) kernel (hd0,0)/vmlinuz ro root=/dev/hda3 video=vesafb:ywrap,pmipal,1024x76824@85 splash=verbose,theme:emergence initrd (hd0,0)/fbsplash-emergence-1024x768 # Boot Gentoo Linux at 1280x1024 framebuffer resolution title Gentoo-2.6.10-r2, 1280x1024 root (hd0,0) kernel (hd0,0)/vmlinuz ro root=/dev/hda3 video=vesafb:ywrap,pmipal,1280x102424@85 splash=verbose,theme:emergence initrd (hd0,0)/fbsplash-emergence-1280x1024 # For installing GRUB into the hard disk title Install GRUB into the hard disk root (hd0,0) setup (hd0) 15 Stage 1 NPTL on Stage 3 Tarball 9.4.2 Installation - Embedding Grub onto the Hard Disk Start Grub from the command prompt and use the following commands to embed grub into the hard disk. Remember, when counting hard disks we like to start at 1, but Grub likes to start at 0, so /dev/hda1 corresponds to hard disk 0, partition 0 in Grub. # grub grub> root (hd0,0) grub> setup (hd0) grub> quit 9.4.3 Customization - Download a Cool Grub Splash Screen We’ll also download a cool Gentoo-specific splash screen for Grub. # wget http://www.schultz-net.dk/downloads/grub/gentoo.xpm.gz 9.5 Filesystem - Configure fstab This is a sample /etc/fstab file that reflects the disk partition scheme used earlier in this Installation Guide. Make changes as appropriate if your partition scheme is different. # <fs> /dev/hda1 /dev/hda3 /dev/hda2 /dev/cdroms/cdrom0 #/dev/fd0 <mountpoint> /boot / none /mnt/cdrom /mnt/floppy <type> reiserfs reiserfs swap iso9660 auto # NOTE: The next line is critical for boot! none /proc proc <opts> <dump/pass> noauto,notail 1 1 notail 0 1 sw 0 0 user,noauto,ro,exec 0 0 noauto 0 0 defaults 0 0 # glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for # POSIX shared memory (shm_open, shm_unlink). # (tmpfs is a dynamically expandable/shrinkable ramdisk, and will # use almost no memory if not populated with files) # Adding the following line to /etc/fstab should take care of this: none /dev/shm tmpfs nodev,nosuid 0 0 9.6 Set HD Paramaters at Boot Back in Section 4 we developed optimized operating parameters for our hard disk. Now that we’re in the chrooted environment of our newly designed Gentoo system, we need to make these configuration changes permanent. To do this, we’ll write the HD parameters to the /etc/conf.d/hdparm file: # cat /etc/conf.d/hdparm disc0_args="–a256A1c1d1m16u1" cdrom0_args="-d1c1u1" After editing the contents of /etc/conf.d/hdparm type the following command to add hdparm to the boot runlevel. This will make the changes to hdparm continue to remain active when the system is rebooted. # rc-update add hdparm boot 16 Stage 1 NPTL on Stage 3 Tarball 9.7 Set-Up User Accounts We must change the password of the root user in our newly installed system. Then we will add non-root users to the system. Substitute the username examples “bob” and “mary” with your own usernames. First, change the root password: # passwd New password: (Enter your new password) Re-enter password: (Re-enter your password) Now add users who will allowed to “su” their way to temporary root status. These users must be added to the “wheel” user group. # useradd -m -G users,wheel bob # passwd bob New password: (Enter bob's password) Re-enter password: (Re-enter bob's password) Now add non-root users to the system: # useradd -m -G users mary # passwd mary New password: (Enter mary's password) Re-enter password: (Re-enter mary's password) 9.8 Toggle NUMLOCK ON at Boot If you’d like the NUMLOCK key to be toggled ON at system boot, execute the following command. # rc-update add numlock default 9.9 Exit Chroot and Unmount Partitions Exit the chrooted environment and unmount all mounted partitions. exit cd ~/ umount /mnt/gentoo/proc /mnt/gentoo/boot /mnt/gentoo swapoff /dev/hda2 10. Reboot! And now, the moment you’ve been waiting for! # shutdown -r now 17 Stage 1 NPTL on Stage 3 Tarball When the system reboots, you will be welcomed with the following greeting. This is boatanchor.mydomain.com (Linux i586 2.6.10-gentoo-r2) HH:MM:SS boatanchor login: Have fun with your new Gentoo system! 11. If You Should Encounter Problems This Installation Guide was first published on the Documentation, Tips & Tricks section of the Gentoo Discussion Forums. Documentation, Tips & Tricks is not a support forum. For this reason I would like to ask that we limit the context of that thread to posts that discuss problems with this Installation Guide that need to be corrected, or to ideas about how to improve the Stage 1 on 3 installation procedure itself. At this time the Installation Guide has evolved to a fairly mature state, such that most problems that are likely to be encountered during an install are likely to be related to individual factors not attributable to the Installation Guide. It would seem fair if those who encountered problems with architecture specification, CFLAGS, etc. could post their requests for help in the appropriate support forums. (That way, once your personal support request is resolved, your problem will scroll off into oblivion instead of being preserved here forever, interspersed with this documentation.) 12. Another Essential Tool: Emerge Wrapper for System Updates This Installation Guide is focused on how to install Gentoo, but it specifically avoids the issue of how to maintain your Gentoo installation. Hielvc and MindEraser have developed a fabulous emerge wrapper for system updates that is highly recommended. Check out the following thread on the Gentoo Discussion Forums: http://forums.gentoo.org/viewtopic-t-282474.html 13. Acknowledgements This Installation Guide includes bits and pieces of information that have been collected from posts on the Gentoo Discussion Forums. It is a derivative work that is based upon the collective knowledge of a number of people. Special thanks go to ali3nx for his helpful Installation Guide on building a Gentoo Stage 1 system using NPTL. Special thanks also go to rac for sharing with us the great idea of building Stage 1 Gentoo installations using a Stage 3 tarball. Thanks to the following people who have contributed to my understanding of Gentoo and helped me solve hardware problems while I was learning my way around: hardcore, NeddySeagoon The following people’s comments on the Gentoo Forums on related threads have also contributed indirectly in the writing of this Installation Guide. Their names are listed in alphabetical order: heilvc, Hobbit-HK, irf2003, kimchi_sg, Oktane My sincere apologies if I’ve left anyone out 18 Stage 1 NPTL on Stage 3 Tarball 14. Corrections, Errors, Omissions Please let me know if there are any errors or omissions in this document by sending me a personal message through the Gentoo Forums. 19