The Gentoo Linux alternative installation method HOWTO

Contents:

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. The second part of this short guide explains step-by-step how Gentoo can be installed from an existing Linux distribution. It is useful for people who already have Linux and want to try Gentoo out. If you have an installation method that you yourself find useful, or you have devised an amusing way of installing gentoo, please dont hesitate to write something up and send it to me.

2. Netboot install

Requirements 

The requirements for a netboot install are a host computer than can provide a tftp server and a computer that can netboot itself via either bios or a floppy drive used to boot GRUB or another network bootloader. A dhcp server might also be necessary. Of course, you will also need the latest build ISO, which can be found at http://www.ibiblio.org/gentoo/snapshots/build/

Overview 

In order to load images off the network, the first thing a netboot machine must do is obtain an IP address. There are multiple ways of obtaining an IP address, and any one of them will do. Personally, I prefer to use GRUB for everything, but if your computer supports booting from a network already then grub might not be necessary, even if it might be easier to just use GRUB's ifconfig command instead of setting up a bootp or dhcp server.

Once your computer has obtained an IP address, the next logical step is to find out what you are going to be booting and where it might be held. Once again, it would be easiest to do this with GRUB commands as opposed to setting up a bootp or dhcp server. You will also need to specify how to obtain an initrd and tell the kernel that it will be using this as it's root filesystem.

With your kernel loaded and root filesystem mounted, you may proceed with installation as normal. The build image could be loaded from a cd, or it can be downloaded from the network via tftp.

Using GRUB 

To use GRUB for network booting purposes, you must first have GRUB compiled with support for your network card. It doesn't matter if you install to floppy, or to the hard drive of the computer you wish to install Gentoo on. If your install target already has GRUB with network support installed, then you are one step ahead. GRUB can be downloaded from ftp://alpha.gnu.org/gnu/grub/

A configure example for enabling tulip support, the network card in my box:

Code listing 1: Manual GRUB installation

# ./configure --enable-tulip --prefix=/usr
# make && make install

If you are currently in Gentoo and wish to install GRUB using Gentoo tools, then you need to install step by step in order to configure in support for your network card. An example for using ebuild to install GRUB with tulip support:

Code listing 2: Installing and configuring GRUB on Gentoo Linux

# ebuild /usr/portage/sys-apps/grub/grub-0.91.ebuild clean fetch unpack
# cd /var/tmp/portage/grub-0.91/work/grub-0.91/
# ./configure --prefix=/usr --sbindir=/sbin --mandir=/usr/share/man \ 
> --infodir=/usr/share/info --enable-tulip
# make
# touch /var/tmp/portage/grub-0.91/.compiled
# cd /usr/portage/
# ebuild sys-apps/grub/grub-0.91.ebuild install merge

Now that we have the GRUB shell itself installed, we need to install to a boot sector. Although you could install GRUB to the boot sector of your install computer's hard drive, here we will assume that you are installing GRUB on a boot floppy. There are two ways of doing this. You can use the GRUB shell itself, or you can use a provided script called grub-install. It is preferable to use grub-install when installing GRUB to a floppy.

Code listing 3: grub-install example

# mkfs.ext2 /dev/fd0
# mount /dev/fd0 /mnt/floppy/
# grub-install --root-directory=/mnt/floppy/ '(fd0)'
# umount /mnt/floppy/

grub-install does not always work... and isn't always the best way to install GRUB. And since the GRUB shell works exactly like GRUB would when booted via the boot sector, it might be more desirable just to use the GRUB shell. Here is an example of how to use the GRUB shell to install GRUB to a floppy:

Code listing 4: Using the GRUB shell instead

# mkfs.ext2 /dev/fd0
# mount /dev/fd0 /mnt/floppy/
# mkdir -p /mnt/floppy/boot/grub/
# cp -v /usr/share/grub/i386-pc/* /mnt/floppy/boot/grub/
# grub
grub> root (fd0)
grub> setup (fd0)
grub> quit
# umount /mnt/floppy/

Now that we have a bootable GRUB floppy, we need to set up the host tftp server (I suggest netkit's tftp server) for loading our kernel and initrd. If you use inetd then you will need a line in your /etc/inetd.conf that looks like this:

Code listing 5: /etc/inetd.conf

tftp	dgram	udp	wait	nobody	/usr/sbin/tcpd	in.tftpd

To install the netkit tftp server under gentoo linux, emerge net-misc/netkit-tftp

Note: There is an ebuild for xinetd... if you prefer to use this than feel free to do so. However I do not use xinetd, and do not know how to set up tftp with it. If you use it and such, please send me info on how to get xinetd working and I will include them in this howto.

Now that we have our tftp server ready, we need a kernel and a root initrd to put in it. You can compile a custom kernel yourself, but make sure it has all the things necessary for running gentoo (like devfs) and for netbooting (like initrd support). The root initrd will be the rescue.gz included in the gentoo ISO.

Important: Mounting an ISO file without burning it to cd requires loopback filesystem support.

Code listing 6

# mkdir /tftpboot
# mount -o loop /path/to/build-ix86-1.0_rc6-r14.iso /mnt/cdrom/
# cp /mnt/cdrom/isolinux/kernel /mnt/cdrom/isolinux/rescue.gz /tftpboot
# chmod 644 /tftpboot/*
# umount /mnt/cdrom/

Boot the machine you want to install to with your incredibly usefull grub floppy. Once booted you need to specify a way for the machine to get its IP address, specify where to get a kernel and it's options, and where to get it's initrd.

Code listing 7

grub> ifconfig --address=192.168.0.10 --server=192.168.0.2
grub> root (nd)
grub> kernel /tftpboot/kernel devfs=nomount vga=normal load_ramdisk=1 
      prompt_ramdisk=0 ramdisk_size=18580 root=/dev/ram0 rw (all on one line)
grub> initrd /tftpboot/rescue.gz
grub> boot

Note: You can also use bootp and dhcp to configure your ip via grub. Use the bootp and dhcp commands.

Now that you have your machine booted, you can install as normal. Refer to the from source cd install howto.

3. Install from your 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. I will show you how to use the files in an ISO filesystem without writing them to a CDRom beforehand. A network connection would be prefferable 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 proto-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 8: List of filesystems

# 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) 
# 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!


Using parted

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 here

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.

Get tomsrtbt from Freshmeat , create a floppy as suggested in the Documentation that comes with it, take the floppy out and prepare it with

Code listing 9: Preparation of the disk with parted on it

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

Leave the floppy disk in the drive, 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 10: Building parted

# 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 when you are logged in just 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.

Installing gentoo

Now it is the time to allocate space for gentoo, that is partition your disk so as to use the newly-freed space with Gentoo. If you don't know how to use fdisk, try man fdisk that will give you a start. or maybe even search the net if the manual page was not enough. From this point on we will do Step 7 through 17 of the Gentoo installation guide If you finished that part, you are now ready to chroot into your new gentoo installation whenever you want and emerge applications. When you are fully ready, you can restart your system after grub/lilo is installed and enjoy the power of Gentoo.

Updated 10 Jul 2002
Travis Tilley
Author

Faust A. Tanasescu
Contributor

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 cant boot cds.

Support our development efforts by donating via credit card!

Purchase RAM using this link, and a percentage of your sale will go towards further Gentoo Linux development.

DDR Memory at Crucial.com

Why these guys? Because cvs.gentoo.org and inventor.gentoo.org use high-quality Crucial RAM. We know that it's good stuff because we rely on it ourselves.

Copyright 2001 Gentoo Technologies, Inc. Questions, Comments, Corrections? Email gentoo-dev@gentoo.org.