LinuxÒÁµéÔ°ÂÛ̳'s Archiver

takethat ·¢±íÓÚ 2002-12-22 16:08

gentoo°²×°Ö¸ÄÏ£¨EÎİ棩

1.About the Install

This new boot CD will boot from nearly any modern IDE CD-ROM drive, as well as many SCSI CD-ROM, assuming that your CD-ROM and BIOS both support booting. Included on the CD-ROM is Linux support for IDE (and PCI IDE) (built-in to the kernel) as well as support for all SCSI devices (available as modules). In addition, we provide modules for literally every kind of network card that Linux supports, as well as tools to allow you to configure your network and establish outbound ssh connections and download files.

To install from the build CD, you will need to have a 486+ processor and ideally at least 64 Megabytes of RAM. (Gentoo linux has been successfully built with 64MB of RAM + 64MB of swap space, but the build process is awfully slow under those conditions.) To begin the install process, first grab the livecd ISO images from [url]http://www.ibiblio.org/gentoo/releases/1.4_rc1/.[/url] The three stages make our life easy with Gentoo. The stage1 is for building the entire system from scratch. Stage2 is for building some of the system from scratch, and stage3 saves a lot of time because it is already optimized for you specific system. At the moment only the stage1 tarball is stored on the livecd, but you will be able to download a stage2 or stage3 tarball optimized for your system after booting the livecd.

If for some reason your install gets interrupted at some point, you can reboot and restart. For example, if you have partitioned, installed the stageX tarball, and are ready to chroot, you can restart the install if necessary. Just re-boot with the LiveCD, then mount your drives/partitions to /mnt as normal. Basically, you can do this at about any point during the install, just not before partitioning for obvious reasons. Warning: If you encounter a problem with any part of the install and wish to report it as a bug, report it to bugs.gentoo.org. If the bug needs to be moved upstream to the package maintainers (ie KDE) the developers will take care of that.


Now, let's quickly review the install process. We'll create partitions, create our filesystems, and extract either a stage1, stage2 or stage3 tarball. If we are using a stage1 or stage2 tarball, we will take the appropriate steps to get our systems to stage3. Once our systems are at stage3, we can configure them (tweaking config files, installing a bootloader, etc) and boot them and have a fully-functional Gentoo Linux system. Depending on what stage of the build process you're starting from, here's what's required for installation:

stage tarball requirements for installation
1 partition/filesystem setup, emerge sync, bootstrap, emerge system, emerge linux sources, final configuration
2 partition/filesystem setup, emerge sync, emerge system, emerge linux sources, final configuration
3 partition/filesystem setup, emerge sync, final configuration

2.Booting

Start by booting the livecd. You'll be greeted with a lot of text output followed by the normal Gentoo Linux boot sequence. Login as "root" (just hit <enter> for the password), and then use the passwd command to change the root password. (This root password is only for this installation session. The reason for changing the password is that you will have to connect to the net to complete the installation. Connecting to the internet with the default root password is a really bad idea!) You should have a root ("#") prompt on the current console, and can also open new consoles by typing alt-f2, alt-f3, etc and then hitting enter.

Next, you will be greeted with instructions for setting up your network, and optional PCI autodetection. The PCI autodetection process will automatically load the appropriate kernel modules for many popular PCI SCSI and ethernet devices. After this, you should have a root ("#") prompt on the current console, and can also open new consoles by typing Alt-F2, Alt-F3, etc and then hitting enter.

3.Load Kernel Modules

Hopefully you need only type pci-setup at the root prompt to autodetect the hardware on your system and to load the appropriate kernel modules.

If the PCI autodetection missed some of your hardware, you will have to load the appropriate modules manually. To view a list of all available network card modules, type ls /lib/modules/*/kernel/drivers/net/*. To load a particular module, type:

Code listing 3.1: PCI Modules Configuration

# modprobe pcnet32
(replace pcnet32 with your NIC module)
                       


Now, if you want to be able to access any SCSI hardware that wasn't detected during the PCI autodetection process, you'll need to load the appropriate modules from /lib/modules, again using modprobe:

Code listing 3.2: Loading SCSI Modules

# modprobe aic7xxx
# modprobe sd_mod
                       


aic7xxx supports your SCSI controller and sd_mod supports SCSI hard disks. Note: Support for a SCSI CD-ROMs in build-in in the kernel.



If you are using hardware RAID, you need to load the ATA-RAID modules for your RAID controller.

Code listing 3.3: Loading RAID Modules

   
# insmod ataraid   
# insmod pdcraid            
      (Promise Raid Controller)   
# insmod hptraid            
      (Highpoint Raid Controller)   
                       


The Gentoo LiveCD should have enabled DMA on your disks, but if it did not, hdparm can be used to set DMA on your drives.

Code listing 3.4: Setting DMA

Replace hdX with your disk device.
# hdparm -d 1 /dev/hdX Enables DMA
# hdparm -X66 /dev/hdX Enables Ultra-DMA


4.Loading PCMCIA Kernel Modules

If you have a PCMCIA network card, you will need to do some additional trickery.

Warning: To avoid problems with cardmgr, you must run it before you enter the chroot portion of the install.

Code listing 4.1: Loading PCMCIA Modules

# insmod pcmcia_core
# insmod i82365
# insmod ds
# cardmgr -f
                       


As cardmgr detects which hardware is present, your speaker should emit a few reassuring beeps, and your PCMCIA network card should hum to life. You can of course insert the PCMCIA card after loading cardmgr too, if that's preferable. (Technically, you need not run cardmgr if you know exactly which module your PCMCIA card requires. But if you don't, loading all PCMCIA modules and see which sticks won't work, as all PCMCIA modules load obligingly and hang around for a PCMCIA card to drop by. cardmgr will also unload the module(s) for any card when you remove it).

takethat ·¢±íÓÚ 2002-12-22 16:10

5.Configuring Networking

PPPoE configuration

Assuming you need PPPoE to connect to the internet, the livecd (any version) has made things easy for you by including rp-pppoe. Use the provided adsl-setup script to configure your connection. You will be prompted for the ethernet device that is connected to your adsl modem, your username and password, the IPs of your DNS servers, and if you need a basic firewall or not.

Code listing 5.1: Configuring PPPoE

#  adsl-setup
#  adsl-start
                       


If something goes wrong, double-check that you correctly typed your username and password by looking at /etc/ppp/pap-secrets or /etc/ppp/chap-secrets, and make sure you are using the right ethernet device.

Automatic Network Configuration  

The Gentoo Linux install lets you configure a working network, allowing you to use ssh, scp or wget as needed before even beginning the installation process. Even if you don't need to do these things now, you should go ahead and set up networking now. Once networking is up, Portage will be able to use your configured network once you are inside the chroot environment (required for installing Gentoo Linux). The simplest way to set up networking is to run our new net-setup script.

Code listing 5.2: Net-Setup Script

# net-setup eth0
               


Of course, if you prefer, you may still set up networking manually.

Manual DHCP Configuration

Network configuration is simple with DHCP; If your ISP is not using DHCP, skip down to the static configuration section below.

Code listing 5.3: Network configuration with DHCP

# dhcpcd eth0
               

Note: Some ISPs require you to provide a hostname. To do that, add a -h myhostname flag to the dhcpcd command line above.


If you receive dhcpConfig warnings, don't panic; the errors are most likely cosmetic. Skip down to Network testing below.

Manual Static Configuration

We need to setup just enough networking so that we can download sources for the system build, as well as the required localhost interface. Type in the following commands, replacing $IFACE with your network interface (typically eth0), $IPNUM with your IP address, $BCAST with your broadcast address, and $NMASK with your network mask. For the route command, replace $GTWAY with your default gateway.

Code listing 5.4: Static IP Network Configuration

# ifconfig $IFACE $IPNUM broadcast $BCAST netmask $NMASK
# /sbin/route add -net default gw $GTWAY netmask 0.0.0.0 metric 1
               


Now it's time to create the /etc/resolv.conf file so that name resolution (finding Web/FTP sites by name, rather than just by IP address) will work.

Here's a template to follow for creating your /etc/resolv.conf file:

Code listing 5.5: /etc/resolv.conf template

domain mydomain.com
nameserver 10.0.0.1
nameserver 10.0.0.2
               


Replace 10.0.0.1 and 10.0.0.2 with the IP addresses of your primary and secondary DNS servers respectively.

Proxy Configuration

If you are behind a proxy, it is necessary to configure your proxy before you continue. We will export some variables to set up the proxy accordingly.

Code listing 5.6: Setting a Proxy

# export http_proxy="machine.company.com:1234"
# export ftp_proxy="$http_proxy"
# export RSYNC_PROXY="$http_proxy"
               


Network Testing

Now that your network has been configured, the /sbin/ifconfig -a command should show that your network card is working (look for UP and RUNNING in the output).

Code listing 5.7: /sbin/ifconfig for a working network card

eth0      Link encap:Ethernet  HWaddr 00:50:BA:8F:61:7A
          inet addr:192.168.0.2  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::50:ba8f:617a/10 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1498792 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1284980 errors:0 dropped:0 overruns:0 carrier:0
          collisions:1984 txqueuelen:100
          RX bytes:485691215 (463.1 Mb)  TX bytes:123951388 (118.2 Mb)
          Interrupt:11
               


You may want to also try pinging your ISP's DNS server (found in /etc/resolv.conf), and a website of choice, just to make sure that your packets are reaching the net, DNS name resolution is working correctly, etc.

Code listing 5.8: Further Network Testing

# ping [url]www.some_website.com[/url]
               


Networking is go!

Networking should now be configured and useable. You should be able to use the included ssh, scp and wget commands to connect to other machines on your LAN or the Internet.

takethat ·¢±íÓÚ 2002-12-22 16:11

6.Partition Configuration

Now that the kernel can see the network card and disk controllers, it's time to set up disk partitions for Gentoo Linux.

Here's a quick overview of the standard Gentoo Linux partition layout. We're going to create at least three partitions: a swap partition, a root partition (to hold the bulk of Gentoo Linux), and a special boot partition. The boot partition is designed to hold the GRUB or LILO boot loader information as well as your Linux kernel(s). The boot partition gives us a safe place to store everything related to booting Linux. During normal day-to-day Gentoo Linux use, your boot partition should remain unmounted. This prevents your kernel from being made unavailable to GRUB (due to filesystem corruption) in the event of a system crash, preventing the chicken-and-egg problem where GRUB can't read your kernel (since your filesystem isn't consistent) but you can't bring your filesystem back to a consistent state (since you can't boot!)

Now, on to filesystem types. Right now, you have four filesystem options: XFS, ext2, ext3 (journaling) and ReiserFS. ext2 is the tried and true Linux filesystem but doesn't have metadata journaling. ext3 is the new version of ext2 with both metadata journaling and ordered data writes, effectively providing data journaling as well. ReiserFS is a B*-tree based filesystem that has very good small file performance, and greatly outperforms both ext2 and ext3 when dealing with small files (files less than 4k), often by a factor of 10x-15x. ReiserFS also scales extremely well and has metadata journaling. As of kernel 2.4.18+, ReiserFS is finally rock-solid and highly recommended. XFS is a filesystem with metadata journaling that is fully supported under Gentoo Linux's xfs-sources kernel, but be warned that it is highly unstable at this time.

If you're looking for the most standard filesystem, use ext2. If you're looking for the most rugged journalled filesystem, use ext3. If you're looking for a high-performance filesystem with journaling support, use ReiserFS; both ext3 and ReiserFS are mature and refined. Please be careful with XFS; this filesystem has a tendency to fry lots of data if the system crashes or you lose power. Originally, it seemed like a promising filesystem but it now appears that this tendency to lose data is a major achilles' heel. Here are our basic recommended filesystem sizes and types:

Partition Size Type example device
boot partition, containing kernel(s) and boot information 100 Megabytes ext2/3 highly recommended (easiest); if ReiserFS then mount with -o notail  /dev/hda1
swap partition (no longer a 128 Megabyte limit) >=2*Amount of RAM in this system is recommended but no longer (as of kernel 2.4.10) required Linux swap /dev/hda2
root partition, containing main filesystem (/usr, /home, etc) >=1.5 Gigabytes ReiserFS, ext3 recommended; ext2 ok /dev/hda3

Before creating your partitions, it is a very good idea to initialize the beginning of your HD using dd. Doing this will ensure that you have no issues with mounting previously fat32 partitions, like /boot for example. To do this you would do:

Code listing 6.1: Initializing first 1024 Sectors of HD

# dd if=/dev/zero of=/dev/hdaBOOT bs=1024 count=1024
BOOT is the partition that holds your /boot.
                       


At this point, create your partitions using fdisk. Note that your partitions should be of type 82 if swap and 83 for regular filesystems (whether ReiserFS or ext2/3).

Note: cfdisk is included on the install CD, and it is *considerably* easier to use than fdisk. Just type cfdisk to run it. By default cfdisk work with /dev/hda. If /dev/hda is not hard disk you want to partition, give the right value to cfdisk as a parameter. For example: cfdisk /dev/hde

Note: Changes to the partitions don't reflect on-the-fly, so please reboot after using fdisk or cfdisk.

Note: If you are using RAID your partitions will be a little different. You will have the partitions like this: /dev/ataraid/discX/partY X is the arrays you have made, so if you only have made 1 array, then it will be disc0.Y is the partition number as in /dev/hdaY


Once you've created your partitions, it's time to initialize the filesystems that will be used to house our data. Initialize swap as follows:

Code listing 6.2: Initializing Swap

# mkswap /dev/hda2
                       


You can use the mke2fs command to create ext2 filesystems.

Code listing 6.3: Creating an ext2 Filesystem

# mke2fs /dev/hda1
                       


To create an XFS filesystem, use the mkfs.xfs command.

Code listing 6.4: Creating a XFS Filesystem

# mkfs.xfs /dev/hda3
                       

Note: You may want to add a couple of additional flags to the mkfs.xfs command: -d agcount=3 -l size=32m. The -d agcount=3 command will lower the number of allocation groups. XFS will insist on using at least 1 allocation group per 4 GB of your partition, so, for example, if you hava a 20 GB partition you will need a minimum agcount of 5. The -l size=32m command increases the journal size to 32 Mb, increasing performance.

Warning: If you are installing an XFS partition over a previous ReiserFS partition, later attempts to mount may fail without an explicit mount -t xfs. The solution is to zero out the partition before creating the XFS filesystem: dd if=/dev/zero of=/dev/hdx bs=1k.


If you'd like to use ext3, you can create ext3 filesystems using mke2fs -j.

Code listing 6.5: Creating an ext3 Filesystem

# mke2fs -j /dev/hda3
                       


To create ReiserFS filesystems, use the mkreiserfs command.

Code listing 6.6: Creating a ReiserFS Filesystem

# mkreiserfs /dev/hda3
                       

Note: You can find out more about using ext3 under Linux 2.4 at [url]http://www.zip.com.au/~akpm/linux/ext3/ext3-usage.html.[/url]


7.Mount Partitions

Now, we'll activate our new swap, since we may need the additional virtual memory that provides later:

Code listing 7.1: Activating Swap

# swapon /dev/hda2
                       


Next, we'll create the /mnt/gentoo and /mnt/gentoo/boot mountpoints, and we'll mount our filesystems to these mountpoints.

Code listing 7.2: Creating Mount Points

# mkdir /mnt/gentoo
# mount /dev/hda3 /mnt/gentoo
# mkdir /mnt/gentoo/boot
# mount /dev/hda1 /mnt/gentoo/boot
                       


If you are setting up Gentoo Linux with a separate /usr or /var, these would get mounted to /mnt/gentoo/usr and /mnt/gentoo/var, respectively.

Important: If your boot partition (the one holding the kernel) is ReiserFS, be sure to mount it with the -o notail option so GRUB gets properly installed. Make sure that notail ends up in your new /etc/fstab boot partition entry, too. We'll get to that in a bit.

Important: If you are having problems mounting your boot partition with ext2, try using mount /dev/hXX /mnt/gentoo/boot -t ext2


8.Obtaining the Desired 'stage-x' Tarball

If you want to start from a stage1 tarball, then you're already set to go; you can find the stage1 tarball in /cdroot/nocompress. On the other hand, if you would prefer to start from a stage2 or stage3 tarball that has been optimized for your architecture you can download it (into /mnt/gentoo would be the simplest) from one of the Gentoo mirror sites.

Code listing 8.1: Downloading Required Stages

# cd /mnt/gentoo
Use lynx to get the URL for your tarball
# lynx [url]http://www.ibiblio.org/pub/Linux/distributions/gentoo/releases/1.4_rc1/x86/[/url]
# wget insert required stage tarball here.

takethat ·¢±íÓÚ 2002-12-22 16:12

9.Unpacking the Stage Tarballs

Now it's time to extract the compressed stage tarball of your choice to /mnt/gentoo. Then, we'll chroot over to the new Gentoo Linux build installation.

Important: Be sure to use the p option with tar. Forgetting to do this will cause certain files to contain incorrect permissions.


If you are using the "from scratch, build everything" install method, you will want to use the stage1-ix86-1.4_beta.tbz2 image. If you're using one of our bigger CDs, you'll also have a choice of a stage2 and stage3 image. These images allow you to save time at the expense of configurability (we've already chosen compiler optimizations and default USE variables for you.)

Code listing 9.1: Unpacking the Stages

# cd /mnt/gentoo
# tar -xvjpf /path/to/stage?-*.tbz2
# mount -o bind /proc /mnt/gentoo/proc
# cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
                       

Code listing 9.2: Entering the chroot Environment

# chroot /mnt/gentoo /bin/bash
# env-update
Regenerating /etc/ld.so.cache...
# source /etc/profile
                       


After you execute these commands, you'll be "inside" your new Gentoo Linux environment.

10.Getting the Current Portage Tree using Rsync

Now, you'll need to run emerge sync. This will make sure that you have the most current copy of the Portage tree.

Code listing 10.1: Updating Using Rsync

# emerge sync
                       


The Portage tree will be downloaded and stored in /usr/portage; it's about 90Mb in size without tarballs.

11.Setting Gentoo optimizations (make.conf)

Now that you have a working copy of the Portage tree, people using stage1 to install will need to bootstrap their Gentoo Linux system as follows. First edit the file /etc/make.conf. In this file, you should set your USE flags, which specify optional functionality that you would like to be built into packages; generally, the defaults (an empty or unset USE variable) are fine. More information on USE flags can be found here.

You also should set appropriate CHOST, CFLAGS and CXXFLAGS settings for the kind of system that you are creating (commented examples can be found further down in the file.) Your best friend is man gcc to figure out what additional CFLAGS and CXXFLAGS are available. Search for 'Optimization'.

If necessary, you can also set proxy information here if you are behind a firewall.

Code listing 11.1: Setting make.conf Options

# nano -w /etc/make.conf (Adjust these settings)
                       

Note: People who need to substantially tweak the build process should take a look at the /etc/make.globals file. This file comprises gentoo defaults and should never be touched. If the defaults do not suffice, then new values should be put in /etc/make.conf, as entries in make.conf override the entries in make.globals. If you're interested in tweaking USE settings, look in /etc/make.profile/make.defaults. If you want to turn off any USE settings found here, add an appropriate USE="-foo" in /etc/make.conf (to turn off the foo USE setting.)


12.Starting from Stage1

The stage1 tarball is for ultimate tweakage. If you have picked this tarball, you are most likely looking to have an uber-optimized system. Have fun, because optimization is what Gentoo Linux is all about!

Now, it's time to start the "bootstrap" process. This process takes about two hours on my 1200Mhz AMD Athlon system. During this time, the extracted build image will be prepped for compiling the rest of the system. The GNU compiler suite will be built, as well as the GNU C library. These are time consuming builds and make up the bulk of the bootstrap process.

Code listing 12.1: Bootstrapping

# cd /usr/portage
# scripts/bootstrap.sh
                       


The "bootstrap" process will now begin.

Note: Portage by default uses /var/tmp during package building, often using several hundred megabytes of temporary storage. If you would like to change where Portage stores these temporary files, set a new PORTAGE_TMPDIR before starting the bootstrap process, as follows:

Code listing 12.2: Changing Portage's Storage Path

# export PORTAGE_TMPDIR="/otherdir/tmp"
                       


bootstrap.sh will build binutils, gcc, gettext, and glibc, rebuilding binutils, gcc, and gettext after glibc. Needless to say, this process takes a while. Have a nice nap. Once this process completes, your system will be equivalent to a "stage2" system.

13.Starting from Stage2

The stage2 tarball already has the bootstrapping done for you. All that you have to do is install the rest of the system.

Note: If you haven't done so, please edit /etc/make.conf to your flavor.

Code listing 13.1: Installing the Rest of the System

# export CONFIG_PROTECT=""
# emerge -p system
        [lists the packages to be installed]
# emerge system
                       

Note: The export CONFIG_PROTECT="" line ensures that any new scripts installed to /etc will overwrite the old scripts (stored in sys-apps/baselayout), bypassing Portage's new config file management support. Type emerge --help config for more details.


It's going to take a while to finish building the entire base system. Your reward is that it will be thoroughly optimized for your system. The drawback is that you have to find a way to keep yourself occupied for some time to come. The author suggests "Star Wars - Super Bombad Racing" for the PS2. When this process completes, your system will be the equivalent of a stage3 system.

14.Starting from Stage3

The stage3 tarball is already configured for your system. There is not much to do for this stage, but it is a very good idea to update your system to the newest available packages.

Note: If you have not already edited /etc/make.conf to fit your specifications, now would be a good time to do so.

Code listing 14.1: Getting up-to-date

        # emerge sync
        # emerge -up world
        lists [packages] to be installed
        # emerge -u world
       


15.Final Steps: Timezone

At this point, you should have system that's ready for final configuration. We'll start the configuration process by setting the timezone. By setting the timezone before building the kernel we ensure that users get reasonable uname -a output.

Look for your timezone (or GMT if you using Greenwich Mean Time) in /usr/share/zoneinfo. Then, make a symbolic link by typing:

Code listing 15.1: Creating a symbolic link for timezome

# ln -sf /usr/share/zoneinfo/path/to/timezonefile /etc/localtime
                       


You might also want to check /etc/rc.conf to make sure your timezone settings are correct.

takethat ·¢±íÓÚ 2002-12-22 16:13

16.Final steps: kernel and system logger

Note: If you haven't done so, please edit /etc/make.conf to your flavor.


You now need to merge Linux source ebuilds. Here are the ones we currently offer:

ebuild description
gentoo-sources  Our own performance and functionality-enhanced kernel based on -ac.
xfs-sources  A snapshot of the SGI XFS CVS Linux source tree; this is the kernel to run if you want bleeding edge(cvs) xfs support.
openmosix-sources  A stock Linux kernel source tree patched with support for the GPL openMosix load-balancing/clustering technology
usermode-sources  A stock Linux kernel source tree patched with support for User-Mode Linux. ("Linux inside Linux" technology)
vanilla-sources  A stock Linux kernel source tree, just like you'd get from kernel.org
Warning: Please note that gentoo-sources is heavily patched and may not be stable. Using vanilla-sources might be a better idea if you encounter numerous problems. If you are using gentoo-sources beware of grsecurity, especially with X. It is best to disable grsecurityunless you are absolutely sure that you need it.


Choose one and then merge as follows:

Code listing 16.1: Emerging Kernel Sources

# emerge sys-kernel/gentoo-sources
                       


Once you have a Linux kernel source tree available, it's time to compile your own custom kernel.

Code listing 16.2: Compiling the Linux Kernel

# cd /usr/src/linux
# make menuconfig
# make dep && make clean bzImage modules modules_install
# mv /boot/bzImage /boot/bzImage.orig
[if bzImage already exists]
# cp /usr/src/linux/arch/i386/boot/bzImage /boot
                       

Warning: For your kernel to function properly, there are several options that you will need to ensure are in the kernel proper -- that is, they should be enabled and not compiled as modules. You will need to enable the "Code maturity level options --> Prompt for development and/or incomplete code/drivers" option to see several of these selections. Under the "File systems" section, be sure to enable the "Device File System" (note that you don't need to enable the "/dev/pts file system support" option). You'll also need to enable the "Virtual Memory Filesystem". Be sure to enable "ReiserFS" if you have any ReiserFS partitions; the same goes for "Ext3". If you're using XFS, enable the "SGI XFS filesystem support" option. It's always a good idea to leave ext2 enabled whether you are using it or not. Also, most people using IDE hard drives will want to enable the "USE DMA by default" option; otherwise, your IDE drives may perform very poorly. Of course, remember to enable "IDE disk" support as well -- otherwise your kernel won't be able to see your IDE disks.


If you are using hardware RAID you will need to enable a couple more options in the kernel: For Highpoint RAID controllers select hpt366 chipset support, support for IDE RAID controllers and Highpoint 370 software RAID.For Promise RAID controllers select PROMISE PDC202{46|62|65|67|68|69|70} support, support for IDE RAID controllers and Support Promise software RAID (Fasttrak(tm))

If you use PPPoE to connect to Internet, you will need the following options in the kernel (built-in or as preferably as modules) : "PPP (point-to-point protocol) support", "PPP support for async serial ports", "PPP support for sync tty ports". The two compression options won't harm but are not definitely needed, neither does the "PPP over Ethernet" option, that might only be used by rp-pppoe when configured to do kernel mode PPPoE.

If you have an IDE cd burner, then you need to enable SCSI emulation in the kernel. Turn on "ATA/IDE/MFM/RLL support" ---> "IDE, ATA and ATAPI Block devices" ---> "SCSI emulation support" (I usually make it a module), then under "SCSI support" enable "SCSI support", "SCSI CD-ROM support" and "SCSI generic support" (again, I usually compile them as modules). If you also choose to use modules, then echo -e "ide-scsi\nsg\nsr_mod" >> /etc/modules.autoload to have them automatically added at boot time.

Note: For those who prefer it, it is now possible to install Gentoo Linux with a 2.2 kernel. Such stability will come at a price: you will lose many of the nifty features that are new to the 2.4 series kernels (such as XFS and tmpfs filesystems, iptables, and more), although the 2.2 kernel sources can be patched with Reiserfs and devfs support. Gentoo linux bootscripts require either tmpfs or ramdisk support in the kernel, so 2.2 kernel users need to make sure that ramdisk support is compiled in (ie, not a module). It is vital that a gentoo=notmpfs flag be added to the kernel line in /boot/grub/grub.conf for the 2.2 kernel so that a ramdisk is mounted for the bootscripts instead of tmpfs. If you choose not to use devfs, then gentoo=notmpfs,nodevfs should be used instead.


Your new custom kernel (and modules) are now installed. Now you need to choose a system logger that you would like to install. We offer sysklogd, which is the traditional set of system logging daemons. We also have msyslog and syslog-ng as well as metalog. Power users seem to gravitate away from sysklogd (not very good performance) and towards the newer alternatives. If in doubt, you may want to try metalog, since it seems to be quite popular. To merge your logger of choice, type one of the next four lines:

Code listing 16.3: Emerging System Logger of Choice

# emerge app-admin/sysklogd
# rc-update add sysklogd default
or
# emerge app-admin/syslog-ng
# rc-update add syslog-ng default
or
# emerge app-admin/metalog
# rc-update add metalog default
or
# emerge app-admin/msyslog
# rc-update add msyslog default
                       

Warning: In the case of syslog-ng you need to create /etc/syslog-ng/syslog-ng.conf. See /etc/syslog-ng for a sample configuration file.

Important: Metalog flushes output to the disk in blocks, so messages aren't immediately recorded into the system logs. If you are trying to debug a daemon, this performance-enhancing behavior is less than helpful. When your Gentoo Linux system is up and running, you can send metalog a USR1 signal to temporarily turn off this message buffering (meaning that tail -f /var/log/everything/current will now work in real time, as expected), and a USR2 signal to turn buffering back on again.


Now, you may optionally choose a cron package that you'd like to use. Right now, we offer dcron, fcron and vcron. If you don't know which one to choose, you might as well grab vcron. They can be installed as follows:

Code listing 16.4: Choosing a CRON Daemon

# emerge sys-apps/dcron
# crontab /etc/crontab
or
# emerge sys-apps/fcron
# crontab /etc/crontab
or
# emerge sys-apps/vcron
You do not need to run crontab /etc/crontab if using vcron.
Don't forget to add your *cron to the proper init level.
# rc-update add *cron default
                       


For more information how how cron works under Gentoo Linux, see this announcement.

For more information on starting programs and daemons at startup, see the rc-script guide.

17.Final steps: Install Additional Packages

If you need rp-pppoe to connect to the net, be aware that at this point it has not been installed. It would be the good time to do it.

Code listing 17.1: Installing rp-pppoe

# emerge rp-pppoe
                       

Note: Please note that the rp-pppoe is built but not configured. You will have to do it again using adsl-setup when you boot into your Gentoo system for the first time.


You may need to install some additional packages in the Portage tree if you are using any optional features like XFS, ReiserFS or LVM. If you're using XFS, you should emerge the xfsprogs ebuild:

Code listing 17.2: Emerging Filesystem Tools

# emerge sys-apps/xfsprogs
If you'd like to use ReiserFS, you should emerge the ReiserFS tools:
#  emerge sys-apps/reiserfsprogs
If you're using LVM, you should emerge the lvm-user package:
# emerge --usepkg sys-apps/lvm-user
                       


If you're a laptop user and wish to use your PCMCIA slots on your first real reboot, you'll want to make sure you install the pcmcia-cs package.

Code listing 17.3: Emerging PCMCIA-cs

# emerge sys-apps/pcmcia-cs
                       

Warning: You will have to re-emerge pcmcia-cs after installation to get PCMCIA to work.


18.Final steps: /etc/fstab

Your Gentoo Linux system is almost ready for use. All we need to do now is configure a few important system files and install the GRUB boot loader. The first file we need to configure is /etc/fstab. Remember that you should use the notail option for your boot partition if you chose to create a ReiserFS filesystem on it. Remember to specify ext2, ext3 or reiserfs filesystem types as appropriate.

Use something like the /etc/fstab listed below, but of course be sure to replace "BOOT", "ROOT" and "SWAP" with the actual block devices you are using (such as hda1, etc.)

Code listing 18.1: Editing fstab


# /etc/fstab: static file system information.
#
# noatime turns of atimes for increased performance (atimes normally aren't
# needed; notail increases performance of ReiserFS (at the expense of storage
# efficiency).  It's safe to drop the noatime options if you want and to
# switch between notail and tail freely.

# <fs>           <mountpoint>   <type>   <opts>          <dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.

/dev/BOOT           /boot       ext2         noauto,noatime         1 2
/dev/ROOT           /           ext3         noatime         0 1
/dev/SWAP           none        swap         sw              0 0
/dev/cdroms/cdrom0  /mnt/cdrom  iso9660         noauto,ro       0 0
proc                /proc       proc         defaults        0 0
                       

Warning: Please notice that /boot is NOT mounted at boottime. This is to protect the data in /boot from corruption. If you need to access /boot, please mount it!

takethat ·¢±íÓÚ 2002-12-22 16:15

19.Final steps: Root Password

Before you forget, set the root password by typing:

Code listing 19.1: Setting the root Password

# passwd
                               
20.Final steps: /etc/hostname

Edit this file so that it contains your fully-qualified domain name on a single line, i.e. mymachine.mydomain.com.

Code listing 20.1: Configuring Hostname

# echo mymachine.mydomain.com > /etc/hostname
                       


21.Final steps: /etc/hosts

This file contains a list of ip addresses and their associated hostnames. It's used by the system to resolve the IP addresses of any hostnames that may not be in your nameservers. Here's a template for this file:

Code listing 21.1: Hosts Template

127.0.0.1      localhost
# the next line contains your IP for your local LAN, and your associated machine name
192.168.1.1    mymachine.mydomain.com        mymachine
                       

Note: If you are on a DHCP network, it might be helpful to set localhost to your machine's actual hostname. This will help GNOME and many other programs in name resolution.


22.Final Network Configuration

Add the names of any modules that are necessary for the proper functioning of your system to /etc/modules.autoload file (you can also add any options you need to the same line.) When Gentoo Linux boots, these modules will be automatically loaded. Of particular importance is your ethernet card module, if you happened to compile it as a module:

Code listing 22.1: /etc/modules.autoload

This is assuming that you are using a 3com card. Check /lib/modules/`uname -r`/kernel/drivers/net for your
card.
3c59x
                       


Edit the /etc/conf.d/net script to get your network configured for your first boot:

Code listing 22.2: Boottime Network Configuration

# nano -w /etc/conf.d/net
# rc-update add net.eth0 default
                       


If you have multiple network cards you need to create additional net.ethx scripts for each one (x = 1, 2, ...):

Code listing 22.3: Multiple Network Interfaces

# cd /etc/init.d
# cp net.eth0 net.ethx
# rc-update add net.ethx default
                       


If you have a PCMCIA card installed, have a quick look into /etc/init.d/pcmcia to verify that things seem all right for your setup, then add this line to the top of /etc/init.d/ethx:

Code listing 22.4: PCMCIA depend in /etc/init.d/net.ethx

depend() {
        need pcmcia
}
                       


This makes sure that the PCMCIA drivers are autoloaded whenever your network is loaded.

23.Final steps: Configure Basic Settings (including the international keymap setting)

Code listing 23.1: Basic Configuration

# nano -w /etc/rc.conf
                       


Follow the directions in the file to configure the basic settings. All users will want to make sure that CLOCK is set to his/her liking. International keyboard users will want to set the KEYMAP variable (browse /usr/share/keymaps to see the various possibilities).

24.Final steps: Configure GRUB

The most critical part of understanding GRUB is getting comfortable with how GRUB refers to hard drives and partitions. Your Linux partition /dev/hda1 is called (hd0,0) under GRUB. Notice the parenthesis around the hd0,0 - they are required. Hard drives count from zero rather than "a", and partitions start at zero rather than one. Be aware too that with the hd devices, only harddrives are counted, not atapi-ide devices such as cdrom players, burners, and that the same construct can be used with scsi drives. (Normally they get higher numbers than ide drives except when the bios is configured to boot from scsi devices.) Assuming you have a harddrive on /dev/hda, a cdrom player on /dev/hdb, a burner on /dev/hdc and a second hardrive on /dev/hdd, for example, and no scsi harddrive /dev/hdd7 gets translated to (hd1,6). It might sound tricky, and tricky it is indeed, but as we will see, grub offers a tab completion mechanism that comes handy for those of you having a lot of harddrives and partitions and who are a little lost in the grub numbering scheme. Having gotten the feel for that, it's time to install GRUB.

The easiest way to install GRUB is to simply type grub at your chrooted shell prompt:

Code listing 24.1: Installing GRUB

# grub
                       

Important: If you are using hardware RAID this part will not work at this time. Skip to the section on making your grub.conf. After that we will complete the grub setup for RAID controllers


You'll be presented with the grub> grub command-line prompt. Now, you need to type in the right commands to install the GRUB boot record onto your hard drive. In my example configuration, I want to install the GRUB boot record on my hard drive's MBR (master boot record), so that the first thing I see when I turn on the computer is the GRUB prompt. In my case, the commands I want to type are:

Code listing 24.2: GRUB Commands

grub> root (hd0,0)
grub> setup (hd0)
grub> quit
                       


Here's how the two commands work. The first root ( ) command tells GRUB the location of your boot partition (in our example, /dev/hda1 or (hd0,0) in GRUB terminology. Then, the second setup ( ) command tells GRUB where to install the boot record - it will be configured to look for its special files at the root ( ) location that you specified. In my case, I want the boot record on the MBR of the hard drive, so I simply specify /dev/hda (also known as (hd0)). If I were using another boot loader and wanted to set up GRUB as a secondary boot-loader, I could install GRUB to the boot record of a particular partition. In that case, I'd specify a particular partition rather than the entire disk. Once the GRUB boot record has been successfully installed, you can type quit to quit GRUB. Note: The tab completion mechanism of grub can be used from within grub, assuming you wrote root ( and that you hit the TAB key, you would be prompted with a list of the available devices (not only harddrives), hitting the TAB key having written root (hd, grub would print the available harddrives and hitting the TAB key after writing root (hd0, would make grub print the list of partitions on the first harddrive. Checking the syntax of the grub location with completion should really help to make the right choice.

Gentoo Linux is now installed, but we need to create the /boot/grub/grub.conf file so that we get a nice GRUB boot menu when the system reboots. Here's how to do it.

Important: To ensure backwards compatibility with GRUB, make sure to make a link from grub.conf to menu.lst. You can do this by doing ln -s /boot/grub/grub.conf /boot/grub/menu.lst .


Now, create the grub.conf file (nano -w /boot/grub/grub.conf), and add the following to it:

Code listing 24.3: Grub.conf for GRUB

default 0
timeout 30
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title=My example Gentoo Linux
root (hd0,0)
kernel /boot/bzImage root=/dev/hda3

#Below is for setup using hardware RAID
title=My Gentoo Linux on RAID
root (hd0,0)
kernel /boot/bzImage root=/dev/ataraid/discX/partY

# Below needed only for people who dual-boot
title=Windows NT Workstation
root (hd0,5)
chainloader +1
                       

Note: (hd0,0) should be written without any spaces inside the parentheses.

Important: If you set up scsi emulation for an IDE cd burner earlier, then to get it to actually work you need to add an "hdx=ide-scsi" fragment to the kernel line in grub.conf (where "hdx" should be the device for your cd burner).


After saving this file, Gentoo Linux installation is complete. Selecting the first option will tell GRUB to boot Gentoo Linux without a fuss. The second part of the grub.conf file is optional, and shows you how to use GRUB to boot a bootable Windows partition.

Note: Above, (hd0,0) should point to your "boot" partition (/dev/hda1 in our example config) and /dev/hda3 should point to your root filesystem. (hd0,5) contains the NT boot loader.

Note: The path to the kernel image is relative to the boot partition. If for example you have separated boot partition (hd0,0) and root partition (hd0,1), all paths in the grub.conf file above will become /bzImage.


If you need to pass any additional options to the kernel, simply add them to the end of the kernel command. We're already passing one option (root=/dev/hda3), but you can pass others as well. In particular, you can turn off devfs by default (not recommended unless you know what you're doing) by adding the gentoo=nodevfs option to the kernel command.

Note: Unlike in earlier versions of Gentoo Linux, you no longer have to add devfs=mount to the end of the kernel line to enable devfs. In rc6 devfs is enabled by default.

takethat ·¢±íÓÚ 2002-12-22 16:16

25.Final steps: Configure LILO

While GRUB may be the new alternative for most people, it is not always the most stable. LILO, the LInuxLOader, is the tried and true workhorse of Linux bootloaders. If you want stability and semi-ease of configure, give LILO a try.

The first step is to emerge LILO:

Code listing 25.1: Emerging LILO

# emerge lilo
       


Now it is time to configure LILO. I will give you a small lilo.conf to use, and I will explain the different parts of the file.

Code listing 25.2: Example lilo.conf

boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
message=/boot/message
lba32
default=linux

image=/boot/vmlinuz-2.4.20
        label=linux
        initrd=/boot/initrd-2.4.20.img
        read-only
        root=/dev/hda5
       
#For dual booting windows/other OS
other=/dev/hda1
        label=dos

       


boot=/dev/hda tells LILO to install itself on the first hard disk on the first IDE controller.
map=/boot/map states the map file. In normal use, this should not be modified.
install=/boot/boot.b tells LILO to install the specified file as the new boot sector. In normal use, this should not be altered. If the install line is missing, LILO will assume a default of /boot/boot.b as the file to be used.
The existence of prompt tells LILO to show you whatever is referenced in the message line. While it is not recommended that you remove the prompt line, if you do remove it, you can still get a prompt by holding down the [Shift] key while your machine starts to boot.
timeout=50 sets the amount of time that LILO will wait for user input before proceeding with booting the default line entry. This is measured in tenths of a second, with 50 as the default.
message=/boot/message refers to the screen that LILO displays to let you select the operating system or kernel to boot.
lba32 describes the hard disk geometry to LILO. Another common entry here is linear. You should not change this line unless you are very aware of what you are doing. Otherwise, you could put your system in an unbootable state.
default=linux refers to the default operating system for LILO to boot from the options listed below this line. The name linux refers to the label line below in each of the boot options.
image=/boot/vmlinuz-2.4.20 specifies the linux kernel to boot with this particular boot option.
label=linux names the operating system option in the LILO screen. In this case, it is also the name referred to by the default line.
initrd=/boot/initrd-2.4.20.img refers to the initial ram disk image that is used at boot time to actually initialize and start the devices that makes booting the kernel possible. The initial ram disk is a collection of machine-specific drivers necessary to operate a SCSI card, hard drive, or any other device needed to load the kernel. You should never try to share initial ram disks between machines.
read-only specifies that the root partition (see the root line below) is read-only and cannot be altered during the boot process.
root=/dev/hda5 tells LILO what disk partition to use as the root partition. Note: Thanks to Redhat.com for this information.


After you have edited your lilo.conf file, it is time to run LILO to load the information into the MBR:

Code listing 25.3: Running LILO

# /sbin/lilo
       


LILO is configured, and now your machine is ready to boot into Gentoo Linux!

26.Final steps: Bootdisks

GRUB Bootdisks

It is always a good idea to make a bootdisk the first time you install any Linux distribution. This is a security blanket, and generally not a bad thing to do. If you are using hardware RAID, you must make a GRUB boot disk. With hardware RAID if you try to install grub from your chrooted shell it will fail. So we will make a GRUB boot disk, and when you reboot the first time we will install GRUB to the MBR. Make your bootdisk like this:

Code listing 26.1: Creating a GRUB Bootdisk

# mke2fs /dev/fd0
# mount /dev/fd0 /mnt/floppy
# mkdir -p /mnt/floppy/boot/grub
# cp /usr/share/grub/i386-pc/stage1 /mnt/floppy/boot/grub/
# cp /usr/share/grub/i386-pc/stage2 /mnt/floppy/boot/grub/

# grub

grub> root (fd0)
grub> setup (fd0)
grub> quit
                       


LILO Bootdisks

If you are using LILO, it is also a good idea to make a bootdisk:

Code listing 26.2: Making a LILO Bootdisk

# dd if=/boot/your_kernel of=/dev/fd0
This will only work if your kernel is smaller than 1.4MB
               


27.Installation Complete!

Now, Gentoo Linux is installed. The only remaining step is to exit the chrooted shell, udpate necessary configuration files, safely unmount your partitions and reboot the system:

Code listing 27.1: Rebooting the System

# etc-update
# exit
// This exits the chrooted shell; you can also type ^D
# cd /
# umount /mnt/gentoo/boot
# umount /mnt/gentoo/proc
# umount /mnt/gentoo
# reboot
                       

Note: After rebooting, it is a good idea to run the update-modules command to create the /etc/modules.conf file. Instead of modifying this file directly, you should generally make changes to the files in /etc/modules.d.

Important: Remember if you are running hardware RAID, you must use the bootdisk for the first reboot. then go back and install grub the way everyone else did the first time. You are done, congratulations


If you have any questions or would like to get involved with Gentoo Linux development, consider joining our gentoo-user and gentoo-dev mailing lists (there's a "click to subscribe" link on our main page). We also have a handy Desktop configuration guide that will help you to continue configuring your new Gentoo Linux system, and a useful Portage user guide to help familiarize you with Portage basics. You can find the rest of the Gentoo Documentation here. If you have any other questions involving installation or anything for that matter, please check the Gentoo Linux FAQ. Enjoy and welcome to Gentoo Linux!

28.Gentoo-Stats

The Gentoo Linux usage statistics program was started as an attempt to give the developers a way to find out about their user base. It collects information about Gentoo Linux usage to help us in set priorities our development. Installing it is completely optional, and it would be greatly appreciated if you decide to use it. Compiled statistics can be viewed at [url]http://stats.gentoo.org/.[/url]

The gentoo-stats server will assign a unique ID to your system. This ID is used to make sure that each system is counted only once. The ID will not be used to individually identify your system, nor will it be mached against an IP address or other personal information. Every precaution has been taken to assure your privacy in the development of this system. The following are the things that we are monitoring right now through our "gentoo-stats" program:

installed packages and their version numbers
CPU information: speed (MHz), vendor name, model name, CPU flags (like "mmx" or "3dnow")
memory information (total available physical RAM, total available swap space)
PCI cards and network controller chips
the Gentoo Linux profile your machine is using (that is, where the /etc/make.profile link is pointing to).
We are aware that disclosure of sensitive information is a threat to most Gentoo Linux users (just as it is to the developers).

Unless you modify the gentoo-stats program, it will never transmit sensitive information such as your passwords, configuration data, shoe size...
Transmission of your e-mail addresses is optional and turned off by default.
The IP address your data transmission originates from will never be logged in such a way that we can identify you. There are no "IP address/system ID" pairs.
The installation is easy - just run the following commands:

Code listing 28.1: Installing gentoo-stats

# emerge gentoo-stats   // Installs gentoo-stats
# gentoo-stats --new    // Obtains a new system ID
               


The second command above will request a new system ID and enter it into /etc/gentoo-stats/gentoo-stats.conf automatically. You can view this file to see additional configuration options.

After that, the program should be run on a regular schedule (gentoo-stats does not have to be run as root). Add this line to your crontab:

Code listing 28.2: Updating gentoo-stats with cron

          0 0 * * 0,4 /usr/sbin/gentoo-stats --update > /dev/null
        


The gentoo-stats program is a simple perl script which can be viewed with your favortive pager or editor: /usr/sbin/gentoo-stats.

takethat ·¢±íÓÚ 2002-12-22 16:18

Õâ¸ö°æ±¾ÊÇ×îºÃµÄ£¬ÊÇ´Ó¹Ù·½ÍøÕ¾ÉÏÃæÕÒµ½µÄ¡£²»ÒªÅÂEÎÄ£¬¸úÖøËü¾Í¿ÉÒÔ×°ÉÏ¡£¶øÇÒ»¹ÓнéÉÜgrub and liloµÄÓ÷¨¡£:D

jcnet ·¢±íÓÚ 2003-1-2 13:08

ÀÏÐÖ°ÑÍøÖ·Ò²Ò»²¢Ìù³öÀ´£¿

AIKO_sex ·¢±íÓÚ 2003-1-2 15:27

ż·¢ÏÖlivecdÀïÒ²ÓÐ

°¢Ì© ·¢±íÓÚ 2003-1-13 00:19

È«ÊÇEÎİ¡£¬»èÁË

takethat ·¢±íÓÚ 2003-1-13 19:17

ÆäʵһµãÒ²²»ÄÑ.:D

Ò³: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.