Gentoo Logo
Gentoo Logo Side

The Gentoo Linux alternative installation method HOWTO

Content:

1. About this document

If the standard boot-from-CD install method doesn't work for you (or you just don't like it), help is now here. This document serves to provide a repository of alternative Gentoo Linux installation techniques to those who need them. Or, if you prefer, it serves as a place to put your wacky installation methods. If you have an installation method that you yourself find useful, or you have devised an amusing way of installing Gentoo, please don't hesitate to write something up and send it to me.

2. Booting the LiveCD with Smart BootManager

Download Smart BootManager available from http://btmgr.sourceforge.net/download.html. Linux source or binary format and windows .exe versions are available as well as many language packs. However, at this time, the preferred method would be to use the binary format, as the source will not compile with newer versions of NASM.

Either compile the package from source or just grab the binary. There are several options that can be utilized while creating your boot floppy, as seen below.

Code Listing 2.1: Smart BootManager Options

sbminst [-t theme] [-d drv] [-b backup_file] [-u backup_file]

   -t theme     select the theme to be used, in which the theme could be:
                   us = English theme       de = German theme 
                  hu = Hungarian theme     zh = Chinese theme 
                  ru = Russian theme       cz = Czech theme
                  es = Spanish theme       fr = French theme 
                   pt = Portuguese theme 

                 
  -d drv       set the drive that you want to install Smart BootManager on;
                for Linux:
                  /dev/fd0 is the first floppy driver, 
                  /dev/hda is the first IDE harddisk driver.
                   /dev/sda is the first SCSI harddisk driver.
                for DOS:
                   0   is the first floppy drive
                   128 is the first hard drive;

   -c             disable CD-ROM booting feature;

   -b backup_file backup the data that will be overwritten for
                  future uninstallation;

   -u backup_file uninstall Smart BootManager, should be used alone;

   -y             do not ask any question or warning.

Code Listing 2.2: Using sbminst to build the boot floppy

# sbminst -t us  -d /dev/fd0

Note: Replace fd0 with your respective floppy device name if yours is different.

Now simply place the floppy in the floppy drive of the computer you'd like to boot the LiveCD on, as well as placing the LiveCD in the CD-ROM and boot the computer.

You'll be greeted with the Smart BootManager dialog. Select your CD-ROM and press ENTER to boot the LiveCD. Once booted proceed with the standard installation instructions.

Further information on Smart BootManager may be found at http://btmgr.sourceforge.net/

3. Knoppix Installation

Booting from the Knoppix LiveCD is a way to have a fully functional linux system while you're compiling Gentoo. Tux Racer will help you pass the time while you wait for bootstrap.

Boot from the Knoppix CD. It generally does a really good job of hardware detection. Although, you may have to add some boot options.

By default Knoppix boots into a KDE 3.0 desktop. The first thing I did was open a konsole and typed sudo passwd root. This lets you set the root password for Knoppix.

Next, I su to root and typed usermod -d /root -m root. This sets user roots home directory to /root (the Gentoo way) from /home/root (the Knoppix way). If you do not do this, then you will receive errors when emerging about "/home/root: not found" or something to that effect.

I then typed exit and then su back into root. This loads the change that was made with the usermod command. Now create the /mnt/gentoo mountpoint using mkdir:

Code Listing 3.1: Creating the /mnt/gentoo mountpoint

# mkdir /mnt/gentoo

At this point, you can pick up with the standard install documentation at part 4. However, when you're asked to mount the proc system, issue the following command instead:

Code Listing 3.2: Bind-mounting the proc pseudo filesystem

# mount -o bind /proc /mnt/gentoo/proc

4. Installing from Stage 1 without network access

Burn a LiveCD iso.

Get the latest portage snapshot from http://distro.ibiblio.org/pub/linux/distributions/gentoo/snapshots/ (or your favorite mirror). Either place this tarball on an existing partition on the computer your are installing to, or burn it to a CD.

Follow all instructions of the Gentoo Installation Handbook up to chroot /mnt/gentoo in Chapter 6. If you only have one CD-ROM remember to use the docache option while booting so you can unmount the LiveCD and mount your portage snapshot CD.

Open a new console (Alt-F2), we will continue with the Install Doc up to running the bootstrap.sh script.

Warning: Older realeases of the livecd required you to change the password using the passwd command, before logging in manually.

Go back to the first console (Alt-F1, without chroot) and mount a second CD on /mnt/gentoo/mnt/cdrom2. Copy the portage tarball from cdrom2 and unpack it to /mnt/gentoo/usr/portage.

Code Listing 4.1: Mount the snapshot cd

# umount /mnt/cdrom
# mkdir /mnt/gentoo/mnt/cdrom2
# mount /dev/cdroms/cdrom0 /mnt/gentoo/mnt/cdrom2
# cp /mnt/gentoo/mnt/cdrom2/portage-$date.tar.bz2 /mnt/gentoo/usr/portage
# cd /mnt/gentoo/usr/portage
# tar xvjpf portage-$date.tar.bz2

Switch back to the F2 console. Now if you try to run bootstrap.sh it will fail because it won't be able to download any files. We will fetch these files somewhere else and put them in /usr/portage/distfiles (on F2 console).

You need a list of Stage1 packages: glibc, baselayout, texinfo, gettext, zlib, binutils, gcc, ncurses plus their dependencies.

Note: Note that you need the versions of each package synced with your portage tree.

Code Listing 4.2: Getting the download listing

(Don't forget the 2 in front of the >)
# emerge -fp glibc baselayout texinfo gettext zlib binutils gcc ncurses 2> stage1.list
# mount -t vfat /dev/fd0 /mnt/floppy
# cp /mnt/gentoo/stage1.list /mnt/floppy
# umount /mnt/floppy

Take the floppy to the computer that has fast access. If you take a look at the stage1.list file, you'll see that it provides you with several URLs to download. Sadly, it lists several possible URLs for each package as well, which isn't what you want. Strip all but one of the URLs first:

Code Listing 4.3: Stripping URLs

(This script is depending on the output format given by emerge which
 might change in the future without further notice - use with caution!)
# cut -f 1 -d ' ' stage1.list > stage1.download

Now use wget to fetch all the listed sources:

Code Listing 4.4: Use wget to grab your source packages

# wget -N -i stage1.download

Once you have obtained all the files, take them to the computer and copy them to /mnt/gentoo/usr/portage/distfiles. You will then be able to run bootstrap.sh. Repeat this same wget fetch and place procedure for stage2 and 3.

5. Diskless install using PXE boot

Requirements 

You will need a network card on the diskless client that uses the PXE protocol to boot, like many 3com cards. You will also need a BIOS that supports booting from PXE.

Server base setup 

Create directories: The first thing to do is to create the directories where your diskless system will be stored. Create a directory called /diskless which houses a directory for each diskless client. For the rest of this howto we'll be working on the client 'eta'.

Code Listing 5.1: directory setup

# mkdir /diskless
# mkdir /diskless/eta
# mkdir /diskless/eta/boot

DHCP and TFTP setup: The client will get boot informations using DHCP and download all the required files using TFTP. Just emerge DHCP and configure it for your basic needs. Then, add the following on /etc/dhcp/dhcpd.conf.

Note: This provide a static IP address for the client and the path of a PXE boot image, here pxegrub. You have to replace the MAC address of the Ethernet card of the client and the directory where you will put the client files with the one you use.

Code Listing 5.2: dhcp.conf

option option-150 code 150 = text ;
host eta {
hardware ethernet 00:00:00:00:00:00;
fixed-address ip.add.re.ss;
option option-150 "/eta/boot/grub.lst";
filename "/eta/boot/pxegrub";
}

For TFTP, emerge app-admin/tftp-hpa. In /etc/conf.d/in.tftpd, put the following :

Code Listing 5.3: in.tftpd

INTFTPD_PATH="/diskless"
INTFTPD_USER="nobody"
INTFTPD_OPTS="-u ${INTFTPD_USER} -l -vvvvvv -p -c -s ${INTFTPD_PATH}"

Setup GRUB: To provide PXE booting I use GRUB. You have to compile it by yourself to enable the PXE image compilation ... but that's quite easy. First, get the latest version of the GRUB source code (emerge -f grub will place the tarball in /usr/portage/distfiles). Copy the tarball to /diskless and then build it to make the pxe capable binary. Once the binary is built, copy it to the diskless client's boot directory. Then edit it's grub.lst config file.

Code Listing 5.4: grub setup

# tar zxvf grub-0.92.tar.gz
# cd grub-0.92
# ./configure --help
// In the options you will see a list of supported network interface drivers. 
// Select the driver compatible with your card. Herein referenced a $nic
# ./configure --enable-diskless --enable-$nic
# make
# cd stage2
# cp pxegrub /diskless/eta/boot/pxegrub
# nano -w /diskless/eta/boot/grub.lst

Code Listing 5.5: grub.lst

default 0
timeout 30

title=Diskless Gentoo
root (nd)
kernel /eta/bzImage ip=dhcp root=/dev/nfs nfsroot=ip.add.re.ss:/diskless/eta

// For the nfsroot option, the IP address is the one of the server and 
// the directory is the one where your diskless client files are located (on the server).

Setup NFS: NFS is quite easy to configure. The only thing you have to do is to add a line on the /etc/exports config file :

Code Listing 5.6: /etc/exports

# nano -w /etc/exports
# /etc/exports: NFS file systems being exported.  See exports(5).
/diskless/eta eta(rw,sync,no_root_squash)

Update your hosts: One important thing to do now is to modify your /etc/hosts file to fit your needs.

Code Listing 5.7: /etc/hosts

127.0.0.1 localhost

192.168.1.10 eta.example.com eta
192.168.1.20 sigma.example.com sigma

Creating the system on the server 

You might want to reboot the server with a Gentoo LiveCD, although you can very well continue immediately if you know how to proceed with the Gentoo Installation Instructions from an existing installation. Follow the standard install procedure as explained in the Gentoo Install Howto BUT with the following differences: When you mount the file system, do the following (where hdaX is the partition where you created the /diskless directory). You do not need to mount any other partitions as all of the files will reside in the /diskless/eta directory.

Code Listing 5.8: mounting the filesystem

# mount /dev/hda3 /mnt/gentoo

Stage tarballs and chroot: This example uses a stage3 tarball. Mount /proc to your diskless directory and chroot into it to continue with the install. Then follow the installation manual until kernel configuration.

Warning: Be very careful where you extract your stage tarball. You don't want to end up extracting over your existing installation.

Code Listing 5.9: extracting the stage tarball

# cd /mnt/gentoo/diskless/eta/
# tar -xvjpf  /mnt/cdrom/gentoo/stage3-*.tar.bz2
# mount -t proc /proc /mnt/gentoo/diskless/eta/proc
# cp /etc/resolv.conf /mnt/gentoo/diskless/eta/etc/resolv.conf
# chroot /mnt/gentoo/diskless/eta/ /bin/bash
# env-update
# source /etc/profile

Kernel configuration: When you do the make menuconfig of your kernel configuration, don't forget to enable the following options with the others recommended into the install howto.

Code Listing 5.10: menuconfig options

- Your network card device support
(In the kernel, *not* as a module!)

- Under "Networking options" :

[*] TCP/IP networking
[*] IP: kernel level autoconfiguration
[*] IP: DHCP support
[*] IP: BOOTP support


- Under "File systems --> Network File Systems" :

<*> NFS file system support
[*] Provide NFSv3 client support
[*] Root file system on NFS

Next configure your diskless client's /etc/fstab.

Code Listing 5.11: /etc/fstab

# nano -w /etc/fstab
/dev/cdroms/cdrom0 /mnt/cdrom iso9660 noauto,ro 0 0
proc /proc proc defaults 0 0
tmpfs /dev/shm tmpfs nodev,nosuid,noexec 0 0

You also need to prevent the client to run a filesystem check:

Code Listing 5.12: Preventing the client to run a filesystem check

# touch /fastboot
# echo "touch /fastboot" >> /etc/conf.d/local.start

Bootloader. Don't install another bootloader because we already have one - pxegrub. Simply finish the install and restart the server. Start the services you'll need to boot the new client: DHCP, TFTPD, and NFS.

Code Listing 5.13: Starting services

# /etc/init.d/dhcp start
# /etc/init.d/tftpd start
# /etc/init.d/nfs start

Booting the new client 

For the new client to boot properly, you'll need to configure the bios and the network card to use PXE as the first boot method - before CD-ROM or floppy. For help with this consult your hardware manuals or manufacturers website. The network card should get an IP address using DHCP and download the GRUB PXE image using TFTP. Then, you should see a nice black and white GRUB bootmenu where you will select the kernel to boot and press Enter. If everything is ok the kernel should boot, mount the root filesystem using NFS and provide you with a login prompt. Enjoy.

6. Installing Gentoo from an existing Linux distribution

Requirements 

In order to install Gentoo from your existing Linux distribution you need to have chroot command installed, and have a copy of the Gentoo installation tarball or ISO you want to install. A network connection would be preferable if you want more than what's supplied in your tarball. (by the way, a tarball is just a file ending in .tbz or .tar.gz). The author used RedHat Linux 7.3 as the "host" operating system, but it is not very important. Let's get started!

Overview 

We will first allocate a partition to Gentoo by resizing our existing Linux partition, mount the partition, untar the tarball that is mounted, chroot inside the psuedo-system and start building. Once the bootstrap process is done, we will do some final configuration on the system so as to make sure it boots, then we are ready to reboot and use Gentoo.

How should we make space for Gentoo? 

The root partition is the filesystem mounted under /. A quick run of mount on my system shows what I am talking about. We well also use df (disk free) to see how much space I have left and how I will be resizing. Note that it is not mandatory to resize your root partition! You could be resizing anything else supported by our resizer, but let's talk about that later.

Code Listing 6.1: Filesystem information

# mount
/dev/hdb2 on / type ext3 (rw)
none on /proc type proc (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
none on /dev/shm type tmpfs (rw,nodev,nosuid,noexec)
# df -h 
Filesystem           Size Used Avail Use% Mounted on 
/dev/hdb2            4.0G 1.9G  2.4G  82% /
none		      38M    0    38M   0% /dev/shm 

As we can see, the partition mounted as / named /dev/hdb2 has 2.4 gigabytes free. In my case, I think I will resize it as to leave 400Megs free of space, therefore allocating 2 gigabytes for Gentoo. Not bad, I could have quite some stuff installed. However, think that even one gigabyte is enough for most users. So let's partition this thing!

Building parted to resize partition 

Parted is an utility supplied by the GNU foundation, an old and respectable huge project whose software you are using in this very moment. There is one tool, however, that is extremely useful for us at the moment. It's called parted, partition editor and we can get it from http://www.gnu.org/software/parted/

Note: There are other tools for doing resize of partitions as well, but author is unsure/uninterested whether PartitionMagic(tm) or other software of the kind do the job. It's the reader's job to check them out

Look up on that page the type of filesystem you want to resize and see if parted can do it. If not, you're out of luck, you will have to destroy some partition to make space for Gentoo, and reinstall back. Go ahead by downloading the software, install it. Here we have a problem. We want to resize our Linux root partition, therefore we must boot from a floppy disk a minimal linux system and use previously-compiled parted copied to a diskette in order to resize /. However, if you can unmount the partition while still in Linux you are lucky, you don't need to do what follows. Just compile parted and run it on an unmounted partition you chose to resize. Here's how I did it for my system.

Important: Make sure that the operations you want to do on your partition are supported by parted!

Get tomsrtbt boot/root disk (free of charge) from http://freshmeat.net/tomsrtbt , create a floppy as suggested in the Documentation that accompanies the software package and insert a new floppy in the drive for the next step.

Note: Note again that Linux is synonym of "There's one more way to do it". Your objective is to run parted on an unmounted partition so it can do its work. You might use some other boot/root diskset other than tomsrtbt. You might not even need to do this step at all, that is only umount the filesystem you want to repartition in your Linux session and run parted on it.

Code Listing 6.2: Utility disk creation

# mkfs.minix /dev/fd0
480 inodes
1440 blocks
Firstdatazone=19 (19)
Zonesize=1024
Maxsize=268966912

We will now proceed with the build of parted. If it's not already downloaded and untarred, do so now and cd into the corresponding directory. Now run the following set of commands to build the utility and copy it to your floppy disk.

Code Listing 6.3: Building the utility floppy

#  mkdir /floppy; mount -t minix /dev/fd0 /floppy && 
export CFLAGS="-O3 -pipe -fomit-frame-pointer -static" && ./configure 
&& make && cp parted/parted /floppy && umount /floppy 

Congratulations, you are ready to reboot and resize your partition. Do this only after taking a quick look at the parted documentation on the GNU website. The resize should take under 30 minutes for the largest hard-drives, be patient. Reboot your system with the tomsrtbt boot disk (just pop it inside), and once you are logged in, switch the disk in the drive with your utility disk we have created above and type mount /dev/fd0 /floppy to have parted under /floppy. There you go. Run parted and you will be able to resize your partition. Once this lenghty process done, we are ready to have the real fun, by installing Gentoo. Reboot back into your old Linux system for now. Drive you wish to operate on is the drive containing the partition we want to resize. For example, if we want to resize /dev/hda3, the drive is /dev/hda

Code Listing 6.4: Commands to run once logged into tomsrtbt system

# mount /dev/fd0 /floppy 
# cd /floppy; ./parted [drive you wish to operate on]
(parted)  print 
Disk geometry for /dev/hdb: 0.000-9787.148 megabytes
Disk label type: msdos
Minor    Start       End     Type      Filesystem  Flags
1          0.031   2953.125  primary   ntfs        
3       2953.125   3133.265  primary   linux-swap  
2       3133.266   5633.085  primary   ext3        
4       5633.086   9787.148  extended              
5       5633.117   6633.210  logical               
6       6633.242   9787.148  logical   ext3        
(parted)  help resize 
  resize MINOR START END        resize filesystem on partition MINOR

        MINOR is the partition number used by Linux.  On msdos disk labels, the
        primary partitions number from 1-4, and logical partitions are 5
        onwards.
        START and END are in megabytes
(parted)  resize 2 3133.266 4000.000 

Important: Be patient! The computer is working! Just look at the hardware LED on your case to see that it is really working. This should take between 2 and 30 minutes.

Once you have resized, boot back into your old linux as described. Then go to The Gentoo Handbook: Preparing the Disks and follow the instructions. When chrooting, use the following command to flush your environment:

Code Listing 6.5: Flushing the environment during chroot

# env -i HOME=$HOME TERM=$TERM chroot /mnt/gentoo /bin/bash
# /usr/sbin/env-update
# source /etc/profile

Enjoy!


The contents of this document are licensed under the Creative Commons - Attribution / Share Alike license.
Print
line
Updated October 25, 2004
line
Gerald Normandin Jr.
Contributor

Travis Tilley
Contributor

Oleg Raisky
Contributor

Alex Garbutt
Contributor

Alexandre Georges
Contributor

Magnus Backanda
Contributor

Faust A. Tanasescu
Contributor

Daniel Ahlberg
Contributor

Sven Vermeulen
Editor

Ken Nowack
Reviewer

Tiemo Kieft
Editor

Benny Chuang
Editor

line
Summary:  This HOWTO is meant to be a repository of alternative Gentoo installation methods, for those with special installation needs such as lack of a cdrom or a computer that can't boot cds.
line
The Gentoo Linux Store
line
Copyright 2001-2004 Gentoo Foundation, Inc. Questions, Comments, Corrections? Email [email protected].