The Gentoo Linux alternative installation method HOWTO Travis Tilley Faust A. Tanasescu Daniel Ahlberg Sven Vermeulen 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. 0.3 10 May 2003 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 dont hesitate to write something up and send it to me.

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://distro.ibiblio.org/pub/linux/distributions/gentoo/releases/

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:

# ./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:

# 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.

# 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:

# 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:

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

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

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.

Mounting an ISO file without burning it to cd requires loopback filesystem support.
# mkdir /tftpboot
# mount -o loop /path/to/gentoo-ix86-1.1a.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.

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=24000 root=/dev/ram0 rw (all on one line)
grub> initrd /tftpboot/rescue.gz
grub> boot
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.

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 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.

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

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/

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.

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 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.
# 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.
#  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 youwish 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

# 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 
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 http://www.gentoo.org/doc/en/gentoo-x86-install.xml and follow steps 6 through 17. Don't forget to create the /mnt/gentoo directory before proceeding with step 7. In step 8 you have to download the requested stage-tarball as we're not working from a LiveCD. Enjoy!