Gentoo/x86 Installation Tips & Tricks
1. Introduction
Preliminary
This document contains various tips and tricks for the Gentoo/x86 installation.
Most of them are discussed in a dense way - they are meant as an addendum to the
installation instructions and not as a replacement.
Contents
Advanced Installations
Simplifying the Installation
Fixing Errors/Issues
2. Advanced Installations
Software RAID
Note:
If you are not known to software raid, please read the Software-RAID-HOWTO.
|
Once you are booted from the LiveCD, load the appropriate RAID modules. For
instance, if you plan on using RAID-1:
Code Listing 2.1: Loading the RAID-1 module |
# modprobe raid1
|
When you partition your disks, make sure that your partitions use fd
(Linux raid autodetect) as Partition Type instead of 83 (Linux native).
You can alter the partition type using the t command in fdisk.
After partitioning, create the /etc/mdadm.conf file (yes, indeed,
on the LiveCD environment) using mdadm, an advanced tool for RAID
management. For instance, to have your boot, swap and root partition
mirrored (RAID-1) covering /dev/sda and /dev/sdb,
you can use:
Code Listing 2.2: mdadm command example |
# mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
# mdadm --create --verbose /dev/md1 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2
# mdadm --create --verbose /dev/md2 --level=1 --raid-devices=2 /dev/sda3 /dev/sdb3
|
The Linux Software RAID driver will start creating the metadevices. You can see
its progress in /proc/mdstat. Wait until the metadevices are
completely finished before proceeding.
From now onwards, use /dev/md0 for the boot partition,
/dev/md1 for the swap partition and /dev/md2 for the
root partition.
After mounting /dev/md2 on /mnt/gentoo, don't forget
to copy over /etc/mdadm.conf to /mnt/gentoo/etc.
When you're configuring your kernel, make sure you have the appropriate RAID
support in your kernel and not as module.
When installing extra tools, emerge mdadm as well. Note that this
isn't available on all LiveCDs so you might not be able to install Gentoo on a
Software RAID when using a networkless installation!
When configuring your bootloader, make sure it gets installed in the MBR of
both disks if you use mirroring.
ATA RAID using 2.4 kernels
Make sure you boot your LiveCD using the doataraid option. Once booted,
check the contents of /dev/ataraid. It should contain various
disc* directories for each harddisk available in the ATA RAID. An
entire disk is displayed as disc while partitions are
part*.
Write down the various /dev/ataraid/disc*/* device files that you
use to install Gentoo on. You will need to substitute the /dev/hda
examples in the installation with this path.
Before chrooting, bind-mount the /dev structure in the new
environment:
Code Listing 2.3: Bind-mounting /dev |
# mount -o bind /dev /mnt/gentoo/dev
|
When configuring your kernel, make sure you enable support for your ATA RAID
chipset and options. For instance, a popular ATA RAID system is a Promise
FastTrack built-in RAID in which case you definitely need Promise
FastTrack Options built in into your kernel.
When configuring GRUB, you first have to create a GRUB bootdisk. This is not as
hard as you think. First install GRUB as you would, but when you come to the
part where GRUB is getting installed in the MBR, follow the following
instructions:
Code Listing 2.4: Creating a GRUB bootdisk |
# cd /boot/grub
# dd if=stage1 of=/dev/fd0 bs=512 count=1
# dd if=stage2 of=/dev/fd0 bs=512 seek=1
|
You still need to write your grub.conf file. This is no different
from the installation instructions, just make sure that your root= points
to the ATA RAID device.
After finishing the installation, boot with your GRUB bootdisk. You will be
greeted by a GRUB prompt. Now configure GRUB to boot from the ATA RAID device:
Code Listing 2.5: Installing GRUB on the ATA RAID |
grub> root (hd0,x)
grub> setup (hd0)
grub> quit
|
Now reboot (with the GRUB bootfloppy removed).
LILO users can safely use the instructions mentioned in the installation
instructions.
Using the LiveCD kernel
If you don't want to compile a kernel yourself you can use the kernel from the
LiveCD and copy it to your system. When you come to the point that you're asked
to compile a kernel, go to another terminal (press Alt-F2) and log in with the
root password you've supplied at the beginning of the installation.
Copy over the kernel and modules to your Gentoo system:
Code Listing 2.6: Copying over the LiveCD kernel |
cdimage ~# cp /mnt/cdrom/isolinux/${KN} /mnt/cdrom/isolinux/${KN}.gz /mnt/gentoo/boot
cdimage ~# mkdir -p /mnt/gentoo/lib/modules
cdiamge ~# cp -Rp /lib/modules/`uname -r` /mnt/gentoo/lib/modules
|
Make sure you emerge hotplug and have it added to the boot runlevel. To
have all modules that are currently running (from the LiveCD) loaded during
bootup of your Gentoo system, run the following command from within the chrooted
environment:
Code Listing 2.7: Adding all running modules to the modules.conf file |
# cat /proc/modules | cut -d ' ' -f 1 >> \
/etc/modules.autoload.d/kernel-`uname -r | cut -d . -f -2`
# modules-update
|
3. Simplifying the Installation
Leaving your Terminal
Many people want to leave their system when it's compiling. In certain cases
this is rather difficult as the installation is done in a public environment
where you cannot trust everyone. If this is the case, you want to be able to
perform the compilation in the background and log out from all terminals.
There are several possible solutions for this. The first one is to use
screen. After booting the LiveCD, set your root password and start a
screen session:
Note:
Not all LiveCDs provide screen. If this is the case, you will have to use one of
the other methods described in this section.
|
Code Listing 3.1: Starting a screen session |
# screen -S gentoo
|
Once inside the screen session you can perform the entire installation. When you
want to leave your terminal, press Ctrl-a, d (that is, control and a at
the same time, then followed by a d) to detach your screen session. You
can now safely log out of your system.
To regain access to your terminal, log in as root again and attach to
the running screen session:
Code Listing 3.2: Attaching to a screen session |
# screen -x gentoo
|
If you can't use screen, there is still a way to leave your terminal. Follow the
installation instructions, but when you come to the point where a long-term
compilation would be started (for instance the ./scripts/bootstrap.sh
step), use nohup which allows for a process to continue even when you log
out. Don't forget the trailing "&", otherwise the process won't be placed in
the background! Remember where you are (the pwd command will show you
that) as you will need to know this later on.
Code Listing 3.3: Using nohup |
# pwd
/usr/portage
# nohup ./scripts/bootstrap.sh &
|
Now exit the chrooted environment (exit) and the LiveCD session. Your
compilation will continue in the background.
When you want to check the compilation, log in as root (on the LiveCD) and
chroot back into your environment and go to the directory where you left off:
Code Listing 3.4: Chrooting back |
# chroot /mnt/gentoo /bin/bash
# env-update && source /etc/profile
# cd /usr/portage
|
Now use the less command on the nohup.out file that is
situated inside that directory. The compilation will append its output to that
file, so if you want to follow the compilation progress, run less
nohup.out and press F to follow the changes. When the compilation is
finished, you can continue with the next step of the installation instructions.
If you ever get tired of following the changes, press Ctrl-C followed by
a q. This won't stop the compilation process, only the less
process.
4. Fixing Errors/Issues
Extensive Testing of your Disks
If you think your disk needs to be thoroughly checked for consistency (bad
sectors and such), you can use the -c option while placing the ext2 or
ext3 filesystem on it (using mke2fs). This will perform a read-test and
will mark all bad blocks as such. If you are really paranoid, use -c -c
to perform an extensive read/write test.
Code Listing 4.1: Checking for disk consistency |
# mke2fs -j -c /dev/hda3
|
Recovering from a malfunctioning installation
If for some reason your Gentoo installation fails, you don't have to redo the
installation all over again. Instead, you can safely "go" to the point where you
think you made a mistake (or where you think the instructions are flawed) and
try a different approach.
First of all you need to chroot back into your Gentoo Linux environment. Follow
the instructions again, but ignore the partitioning steps as your partitions are
already created and even populated. You can therefore immediately mount those
partitions at /mnt/gentoo. You should also ignore the steps about
stage extraction and modifying make.conf - you don't want to
overwrite your files do you?
Once chrooted inside your Gentoo Linux environment, immediately go to the step
where you think you should try a different approach. Don't redo all the steps
like bootstrapping and such unless that is the place where you think things
went wrong.
For instance, if you believe that you have a wrongly configured
grub.conf, you can immediately fire up your editor to update
/boot/grub/grub.conf.
Once you have tried a different approach for your situation, you should consider
how much of the subsequent steps you need to perform again. If the subsequent
steps are depending on your change, you will need to redo those.
For instance,
-
if you have changed a variable inside make.conf you will need
to do all subsequent compiling since those depend on the settings inside
make.conf
-
if you have altered /boot/grub/grub.conf you can immediately
exit the chrooted environment and reboot as no subsequent steps are
depending on grub.conf
-
if you have recompiled your kernel you only need to make sure that your
bootloader configuration points to the correct kernel image (double-check
that you mounted your /boot!), then you can exit the chrooted
environment and reboot
-
if you have altered /etc/fstab you can exit the chrooted
environment and reboot
As you can see, for most recovery operations you can immediately reboot. Only in
certain cases will you need to redo the subsequent installation steps.
The contents of this document are licensed under the Creative Commons - Attribution / Share Alike license.
|