HOWTO Advanced Install
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
THIS GUIDE IS OUT OF DATE AND WILL PROBABLY MAKE YOUR COMPUTER EXPLODE, PLEASE DON'T FOLLOW IT
[edit] TODO
- Take this section out before 'release'
- Perhaps use something other than a nonbreaking space to escape a # Update: changing all code to be contained within PRE tags
- Fix the requirement of PRE (see indocument comments) No longer an issue
- Clear up the networking section -- I'm not really sure what's going on (that isn't what mine looks like!)
- Clean up parts of the kernel config section a little
- Spellcheck (aughhh!)
[edit] Introduction
This guide is directed towards more advanced users, who are not installing for their first time. If you are a new user or are not comfortable with advanced topics, you should use the Gentoo Installation Handbook. This guide provides bugfixes and tweaks for installing from Stage1, using NPTL, as well as several other minor, but advanced installation enhancements. This guide does overlap with the Gentoo Installation Handbook in many places, simply because many of the same actions are required to create a functional system.
[edit] Preparation
[edit] Minimal install CD
Grab the latest Gentoo Minimal install CD: install-x86-minimal-2006.0.iso The mirror here is provided for convienence. A similar file can be downloaded from any of the mirrors listed on the Gentoo Linux Mirrors page.
You may be able to complete the installation from an alternative install method, but nothing is guaranteed. Your Mileage May Vary.
[edit] Using Screen
- This step is optional
Screen is a moderately complex program that emulates a terminal. The feature it is best known for is the ability to disconnect and reconnect to screen sessions, which very gracefully survive logoffs. Screen has many more useful features, which are beyond the scope of this guide. Please refer to Screen for more information.
[edit] Using irssi
- This step is optional
irssi is a console based IRC program. See irssi for further information.
[edit] Optimizing Harddisk and CDRom Transfer Modes
- This step is optional
There are often optimizations that can be made to the hard disk and cdrom that are not enabled by default. To enable all optimizations for hda:
| Code: Optimizing Transfer Modes for hda |
# hdparm -d1c1u1m16 /dev/hda |
hda is given as an example in this case. Use the same command for every harddisk you will use in the installation. To understand the specifics of this, please check the hdparm man page.
If you will be using the CDRom extensively during the install process, you can optimize its transfer rates as well.
| Code: Optimizing Transfer Modes for cdrom0 |
# hdparm -d1c1u1 /dev/cdroms/cdrom0 |
[edit] Networking
By default, the Gentoo LiveCD will attempt to detect an ethernet card and gain connection information via dhcp. This is usually successful. To test your connection:
| Code: Testing Network Connection |
# ifconfig # ping -c4 yahoo.com |
If the settings returned from ifconfig are satisfactory and ping is successfully returning replies, you can move onto the next step.
If you do not have a standard ethernet/dhcp setup, you will need to configure your connection manually. The gentoo installation guide has an extensive section on configuring a network. Follow this section of the guide and then return here once the network connection is successful. Gentoo Linux Installation Handbook:Configuring Your Network
Networking could be failing for any number of reasons such as the cable being unplugged or third party drivers not being included on the LiveCD. The wide range of networking problems cannot be addressed in this document nor in the Gentoo Handbook. If you require assistance, try searching this wiki visiting The Gentoo Linux Forums, or asking on the Gentoo IRC Channel.
[edit] Partitioning
If you are using this guide you should be familiar with "fdisk" or at least have heard of it. Partitioning your harddrive with "fdisk" is recommended but not strictly required. If you'd like to you could use another partitioner such as "cfdisk".
First, check your system for available disks.
| Code: Using fdisk to check for available disks |
# fdisk -l |
Example output:
| Code: fdisk -l example output |
Disk /dev/sda: 54.8 GB, 54896492544 bytes 255 heads, 63 sectors/track, 6674 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes |
If you do not understand the interface of "fdisk" you may consider using another, more friendly partitioner such as "cfdisk". Also this guide may be too advanced for your userlevel.
Disk partitioning is not a subject that can be dictated, since every configuration is different and every system is used differently. The following is just a recommended partitioning scheme which need not be strictly adhered to.
- Your boot partition should be the first partition on the primary harddrive (example: hda1). Set the size of this partition to approximately 100 megabytes.
- Make sure you have plenty of swap space: 512 or 1024 megabytes is a good size for a swap partition.
- Use the remaining amount for the root partition (/). Advanced users may consider adding extra partitions such as an extra partition for /home.
- Make sure the type for the swap partition is set to Linux Swap (type 82 in "fdisk").
- Make sure you use "w" to commit your changes to disk before you exit.
Now, "fdisk" your harddrive(s). Hda is used as an example; use the corresponding device to your computer's setup.
| Code: fdisk hda |
# fdisk /dev/hda |
[edit] Creating Filesystems
Like partitioning, filesystem choices are a commonly disputed matter. This guide recommends setting up your partitions as follows:
- /boot - ext2
- / - reiserfs
- swap - swap
A large amount of research and benchmarking can be done on the subject of filesystems. Advanced users may consider looking into various filesystem options on GNU/Linux to find the optimal system for their purposes.
These are the commands to format the partitions as per the recommendation given using example harddrive devices:
| Code: Formatting partitions |
# mke2fs /dev/hda1 # mkswap /dev/hda2 # mkreiserfs /dev/hda3 |
And, activate the swap right away:
| Code: Activating swap |
# swapon /dev/hda2 |
[edit] Mounting Filesystems
| Code: Mounting Filesystems |
# mount /dev/hda3 /mnt/gentoo # mkdir /mnt/gentoo/boot # mount /dev/hda1 /mnt/gentoo/boot |
If additional partitions are used, they should be mounted now as well.
[edit] Retrieving Stage 1
Get stage one and extract it. Again, the mirror provided is just an example.
| Code: Retrieving and Unpacking Stage 1 |
# cd /mnt/gentoo/ # wget http://mirror.datapipe.net/gentoo/releases/x86/2005.1-r1/stages/x86/stage1-x86-2005.1-r1.tar.bz2 # tar xjpvf stage1*.bz2 |
[edit] Selecting a Fast Mirror
- This step is optional
| Code: Setting a Fast Mirror |
# mirrorselect -a -s4 -o | grep 'GENTOO_MIRRORS=' >> /mnt/gentoo/etc/make.conf |
[edit] Configuring make.conf
Setting up /etc/make.conf is another very complex topic, which is beyond the scope of this guide. Please refer to the make.conf manpage for more information.
Modify make.conf to your needs:
| Code: Modifying Make.conf |
# nano -w /mnt/gentoo/etc/make.conf |
Make sure you set "nptl" in your USE flags, because it's one of the main reasons for performing the installation this way. In order to speed up the compilation process you can add "ccache" to your FEATURES list.
[edit] Mounting /proc
This is a step you have to do or things will break in the future:
| Code: Mounting /proc |
# mount -t proc none /mnt/gentoo/proc |
[edit] Mounting /dev
- This step is optional
If you have an off-board IDE card, you may run into trouble with Grub later - mounting /dev might help prevent this.
| Code: Mounting /dev |
# mount -o bind /dev /mnt/gentoo/dev |
[edit] Chrooting
The final preparation step: entering the new Gentoo environment!
| Code: Chrooting into the new Gentoo |
# cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf # chroot /mnt/gentoo /bin/bash # env-update && source /etc/profile |
[edit] Bootstrapping and System
[edit] Setting the Date and Time
Now is a good idea to make sure you have the correct time. Some packages, such as perl, are time sensitive.
| Code: Setting the date and time example |
date --help Usage: date [OPTION]... [+FORMAT] or: date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] Display the current time in the given FORMAT, or set the system date. n0id var # date 090316002004 Fri Sep 3 16:00:00 CDT 2004 |
[edit] Downloading the Portage Tree
| Code: Downloading the Portage Tree |
# emerge --sync |
This'll take a while.
[edit] Bootstrap, System, and rc-update
If you want to use the Compiler Cache (see FEATURES in your make.conf) - you should emerge it now by typing:
| Code: emerge ccache |
|
emerge --oneshot --nodeps ccache |
The Compiler Cache normally uses ~/.ccache as a workdir, but portage works in /var/tmp/ccache. In order to get the correct stats, you may want to set a symlink after removing the old directory:
| Code: Symlinking ccache directories |
|
rm -r /root/.ccache mkdir /var/tmp/ccache ln -s /var/tmp/ccache /root/.ccache |
For your convienence, a big oneliner to do it all: (note: 2.6 is now stable and linux26-headers has become linux-headers)
| Code: Bootstrap, System, rc-update oneliner |
env-update && source /etc/profile && emerge --oneshot --nodeps gcc-config && emerge linux-headers && cd /usr/portage && scripts/bootstrap.sh && emerge libperl && emerge perl && emerge system && emerge syslog-ng xinetd grub hotplug coldplug vixie-cron reiserfsprogs reiser4progs sysfsutils udev dhcpcd && emerge --nodeps acpid ntp && rc-update add syslog-ng default && rc-update add net.eth0 default && rc-update 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 && rc-update add ntpd default |
In some cases (depending on your use-flags?!) emerge of perl* is blocked by other packages. However, you should use ¸emerge -e system¸! Gentoo nowadays use udev natively, so emerge -e system merges udev. Furthermore udev ist blocking the colplug package. Dont merge it ;)
| Code: Bootstrap, System, rc-update oneliner II |
env-update && source /etc/profile && emerge --oneshot --nodeps gcc-config && emerge linux-headers && cd /usr/portage && scripts/bootstrap.sh && USE="-*" emerge libperl perl && emerge -e system && emerge syslog-ng xinetd grub hotplug vixie-cron reiserfsprogs reiser4progs sysfsutils udev dhcpcd && emerge --nodeps acpid ntp && rc-update add syslog-ng default && rc-update add net.eth0 default && rc-update 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 && rc-update add ntpd default |
Before you go pasting that into anything, check it over first - you may have different preferences (i.e. different filesystem requirements or you want a different logger/cron daemon). libperl is in there twice on purpose, it reportedly fails a couple of times.
When i run scripts/bootstrap.sh it failed to compile dev-perl/Locale-gettext. I solved that problem when i run "emerge --nodeps gdbm libperl perl"
http://forums.gentoo.org/viewtopic-p-3382945.html
make sure that emerge system installed the package net-tools (try running ifconfig).
If you thought emerge sync took a long time, then this is going to feel like eternity to you.
[edit] Using ntp to eliminate clock skew
| Code: Using NTP to get the time |
ntpdate -b -u pool.ntp.org |
[edit] Configuring the timezone
| Code: Setting the timezone |
# ls /usr/share/zoneinfo
# ln -sf /usr/share/zoneinfo/{your timezone} /etc/localtime
|
[edit] Configuring and Building the Kernel
First, grab the kernel sources.
This guide highly recommends the plain "vanilla" kernel sources.
(symlink use flag will setup the /usr/src/linux symbolic link)
| Code: Emerging the kernel sources |
# USE="symlink" emerge vanilla-sources |
Change directory to the kernel source location:
| Code: changing to /usr/src/linux |
# cd /usr/src/linux |
There are several ways to configure your kernel. The most popular is by issuing the make menuconfig command, which will provide you with a curses based menu system. Another is to copy the config file from an older kernel and then run make oldconfig, which will keep the old settings and prompt you about anything new. Finally, you can download a premade kernel config and then modify it you your own use, using make menuconfig.
| Code: make menuconfig |
# make menuconfig |
| Code: make oldconfig |
# cp /tmp/old-kernel-config ./.config # make oldconfig |
| Code: Modifying premade config |
# wget http://www.ali3nx.info/.config (website is dead) # make menuconfig |
Specifically, you should change the following things from the premade config:
- Processor type and features - mainly be concerned with your cpu type here
- ATA/ATAPI/MFM/RLL support for storage controllers
- Networking support - NIC Device drivers are your main concern Use Modules =]
- Character devices - agpgart and agp chipset type, dri driver ( if required)
- Note that if your using an nvidia videocard it's best to leave the character devices as-is
- Sound support ~>> Advanced Linux Sound Architecture ~~> Pci devices
- Set the correct driver module for your soundcard here. use a module as the alsa-utils package demands that modules be present for your system to use the startup script correctly
- USB support - Three primary items to be concerned with here...
- If you have usb2 add the EHCI module as <m> the output recieved from lspci is important here as you cannot have both ohci AND uhci both included. you must choose one or the other and add it as a module
- EHCI HCD (USB 2.0) support
- OHCI HCD support
- UHCI HCD (most Intel and VIA) support
Kernel configuration can be a tricky process. It helps a lot if you know your hardware beforehand. The commands lspci and lsmod can aid you in the kernel configuration stage. lspci will print out the info about all devices connected to your computer via PCI. As always, ask for help if you need it. For old-timers: don't set devfs in the kernel - we're using udev now.
Finally, compile the kernel and copy the image to /boot:
| Code: Compiling the Kernel |
# make && make modules_install # cp arch/i386/boot/bzImage /boot |
I would like to add that I recommend using a naming scheme for the files associated with the kernel. For example if you are using kernel 2.6.11.5 then do the following. You will of course need to have your grub.conf match the name you specify for your kernel file
| Code: Kernel naming Schema |
# cp arch/i386/boot/bzImage /boot/2.6.11.5-kernel # cp .config /boot/2.6.11.5-config # cp System.map /boot/2.6.11.5-system |
[edit] Setting /etc/conf.d/rc
Make sure you have the following settings in /etc/conf.d/rc:
RC_NET_STRICT_CHECKING="no"
RC_DEVICES="udev"
RC_DEVICE_TARBALL="no"
RC_NET_STRICT_CHECKING Usage:
| Values | Description |
|---|---|
| none | The net service is always considered up |
| no | This basically means that at least one net.* service besides net.lo must be up. This can be used by notebook users that have a WIFI and a static NIC, and only wants one up at any given time to have the net service seen as up. |
| lo | This is the same as the no option, but net.lo is also counted. This should be useful to people that do not care about any specific interface being up at boot. |
| yes | For this ALL network interfaces MUST be up for the net service to be considered up. |
| Code: Modifying /etc/conf.d/rc |
# nano -w /etc/conf.d/rc |
[edit] Setting up networking names
If this box is standalone or on your own LAN, these values don't matter too much, as long as they're unique - you can make up the domainname the same way you would make up your hostname. If this machine is going to be serving anything to the internet, then you should already know what these are. Finally, if you don't know what nis is, then you don't need it and shouldn't modify the respective line on /etc/conf.d/domainname for it.
| Code: Networking Names |
# nano /etc/conf.d/hostname # nano /etc/conf.d/domainname # rc-update add domainname default |
[edit] Modifying /etc/hosts
Before the days of DNS, this is how every IP was associated with a name over the internet. You can set up friendly names to other boxes on your lan or the internet in this file, but if you don't want to, you can leave the default.
| Code: Modifying /etc/hosts |
# nano -w /etc/hosts |
[edit] Setting up modules to autoload
If you decided to compile any drivers that you will be using on a daily basis as modules, you should add the module's name to the autoload file, so it will be automatically loaded upon boot.
| Code: Adding a module to the autoload file |
# echo foo >>/etc/modules.autoload.d/kernel-2.6 **substitute "foo" with your correct module name** **repeat until all important modules are added to file** |
[edit] Setting up networking
net.eth0 was added to the default runlevel in the big runlevel command back at the boostrap stage. If you have more than one ethernet device, do the following:
| Code: Adding initscripts for more ethernet devices |
# cd /etc/init.d # ln -s net.lo net.eth1 # rc-update add net.eth1 default |
You will also need to configure the settings for each ethernet device so the initscripts will know what to do. If you are using DHCP, it seems you're fine:
| Code: Contents of net configuration file |
# cat /etc/conf.d/net This blank configuration will automatically use DHCP for any net.* scripts in /etc/init.d. To create a more complete configuration, please review /etc/conf.d/net.example and save your configuration in /etc/conf.d/net (this file :]!). |
Huh? This wasn't true in my case and therefore just used the old setup. This obviously needs attention from someone else.
[edit] Configuring bootloader
This guide will provide a simple bootloader setup. The Gentoo Installation Guide has a more verbose section on Configuring a Bootloader. For a prettier setup, also see the Framebuffer, Bootsplash, and Grubslash guide.
You can modify grub.conf.example to your needs or you can use the very basic sample one provided.
| Code: Configuring Grub |
# mv /boot/grub/grub.conf.example /boot/grub/grub.conf # nano -w /boot/grub.conf **or** # nano -w /boot/grub.conf *type/paste the following, making changes if neccesary* title Gentoo root (hd0,0) kernel /bzImage |
Then, load grub into your harddrive's Master Boot Record.
| Code: Installing Grub |
# grub grub> root (hd0,0) grub> setup (hd0) grub> quit |
[edit] Setting up the fstab
The fstab tells the system what to mount at boot. Modify the default to correspond to your setup. If you installed exactly the same way as the defaults used in this guide, it should end up looking something like this (without comments removed):
| Code: /etc/fstab |
# nano -w /etc/fstab /dev/hda1 /boot reiserfs noauto,notail 1 1 /dev/hda3 / reiserfs notail 0 1 /dev/hda2 none swap sw 0 0 /dev/cdroms/cdrom0 /mnt/cdrom iso9660 user,noauto,ro,exec 0 0 none /proc proc defaults 0 0 none /dev/shm tmpfs nodev,nosuid 0 0 |
[edit] Setting up hdparm to be run at boot
- This step is optional
We can get hdparm to optimize our harddrives every time we boot.
Add the following lines to /etc/conf.d/hdparm and delete or comment out the others. Change the drive number(s) if nessisary.
| Code: hdparm config |
# nano -w /etc/conf.d/hdparm disc0_args="-d1c1u1m16" cdrom0_args="-d1c1u1" |
And add it to the boot runlevel:
| Code: Adding hdparm to boot |
# rc-update add hdparm boot |
But, why wouldn't you just use the keepsettings option??
[edit] Finishing up
[edit] Setting root's password
| Code: Setting root's password |
# passwd |
[edit] Adding a user
| Code: Adding a user |
# useradd myuser -m -k /etc/skel -g users -G audio,cron,wheel,portage,games -d /home/myuser -s /bin/bash |
[edit] Clean up
Exit the chroot and unmount everything.
| Code: Cleaning up |
#exit #exit #cd ~/ #umount /mnt/gentoo/proc #umount /mnt/gentoo/boot #umount /mnt/gentoo/dev #umount /mnt/gentoo #swapoff /dev/hda2 |
[edit] Reboot
| Code: Reboot |
# shutdown -r now |
[edit] Enjoy
Enjoy!
[edit] Credits and Comments
[edit] Credits
The original form of this document was based heavily off of this forums topic: http://forums.gentoo.org/viewtopic.php?t=189250
Thanks ali3n!
[edit] Comments
Leave a question or comment in the discussion section (click the discussion tab at the top of the screen).
