<?xml version='1.0' encoding="UTF-8"?>
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/altinstall.xml,v 1.84 2011/12/26 15:22:40 swift Exp $ -->

<guide>
<title>The Gentoo Linux alternative installation method HOWTO</title>

<author title="Contributor">
  <mail link="gerrynjr@gentoo.org">Gerald Normandin Jr.</mail>
</author>
<author title="Contributor">
  <mail link="lordviram@rebelpacket.net">Travis Tilley</mail>
</author>
<author title="Contributor">
  <mail link="volontir@yahoo.com">Oleg Raisky</mail>
</author>
<author title="Contributor">
  <mail link="luminousit@hotmail.com">Alex Garbutt</mail>
</author>
<author title="Contributor">
  <mail link="alex@openvs.com">Alexandre Georges</mail>
</author>
<author title="Contributor">
  <mail link="vargen@b0d.org">Magnus Backanda</mail>
</author>
<author title="Contributor">
  <mail link="davoid@gentoo.org">Faust A. Tanasescu</mail>
</author>
<author title="Contributor">
  <mail link="aliz@gentoo.org">Daniel Ahlberg</mail>
</author>
<author title="Editor">
  <mail link="swift@gentoo.org">Sven Vermeulen</mail>
</author>
<author title="Reviewer">
  Ken Nowack <!-- antifa@gentoo.org seems out -->
</author>
<author title="Editor">
  <mail link="blubber@gentoo.org">Tiemo Kieft</mail>
</author>
<author title="Editor">
  <mail link="bennyc@gentoo.org">Benny Chuang</mail>
</author>
<author title="Editor">
  <mail link="smithj@gentoo.org">Jonathan Smith</mail>
</author>
<author title="Editor">
  <mail link="nightmorph"/>
</author>

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

<!-- The content of this document is licensed under the CC-BY-SA license -->
<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
<license/>

<version>9</version>
<date>2011-12-26</date>

<chapter>
<title>About this document</title>
<section>
<body>

<p>
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 post it on <uri link="http://bugs.gentoo.org">Bugzilla</uri>.
</p>

</body>
</section>
</chapter>

<chapter>
<title>Booting the Install CD with Smart BootManager</title>
<section>
<body>

<p>
Download Smart BootManager available from
<uri>http://btmgr.sourceforge.net/download.html</uri>.
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.
</p>

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

<pre caption="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.
</pre>

<pre caption="Using sbminst to build the boot floppy">
# <i>sbminst -t us  -d /dev/fd0</i>
</pre>

<note>
Replace <path>fd0</path> with your respective floppy device name if yours is
different.
</note>

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

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

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

</body>
</section>
</chapter>

<chapter>
<title>Installation from non-Gentoo LiveCDs</title>
<section>
<title>Introduction</title>
<body>

<impo>
The Gentoo developers cannot support you if something goes wrong with a
non-Gentoo LiveCD, as there's no way to fix, troubleshoot, or document every
quirk of every LiveCD out there. Only Gentoo LiveCDs are officially supported.
If you run into problems with alternative installation media, please visit the
<uri link="http://forums.gentoo.org">Gentoo Forums</uri> for community help.
</impo>

<p>
It is possible to boot some other LiveCD besides the Gentoo-provided CDs. This
will give you a functional environment to use while you're compiling and
installing Gentoo. The instructions provided here should work in principle with
just about any other LiveCD.
</p>

<p>
There are too many LiveCDs out there to <uri
link="http://distrowatch.com/search.php">list</uri>, but you might try <uri
link="http://www.knoppix.org/">Knoppix</uri>. It provides a full graphical
desktop, with office applications, web browsers, and games to keep you busy.
Knoppix is only available for x86 users, so depending on your needs you may need
to find a different LiveCD.
</p>

<warn>
Be aware that if you save anything in your LiveCD's home directory while waiting
for your Gentoo system to install, it will not be available when you reboot
into Gentoo. Be sure to save important files on the hard disk or on some other
computer!
</warn>

</body>
</section>
<section>
<title>Installation instructions</title>
<body>

<p>
Boot from your LiveCD. Open a terminal and run <c>su -</c> so you can change your
password. This lets you set the root password for the CD. You can now configure
<c>sshd</c> for remote login, if you need to install Gentoo remotely. Next,
you'll need to create the <path>/mnt/gentoo</path> mountpoint.
</p>

<pre caption="Creating the /mnt/gentoo mountpoint">
# <i>mkdir /mnt/gentoo</i>
</pre>

<p>
At this point, you can pick up with the standard install documentation at <uri
link="/doc/en/handbook/handbook-x86.xml?part=1&amp;chap=4">part 4</uri>.
However, when you are asked to mount the proc system, issue the following
command instead:
</p>

<pre caption="Bind-mounting the proc pseudo filesystem">
# <i>mount -o bind /proc /mnt/gentoo/proc</i>
</pre>

<p>
When you're ready to unpack the stage tarball in <uri
link="/doc/en/handbook/handbook-x86.xml?part=1&amp;chap=5#doc_chap2_sect2">part
5</uri>, you will need to use a different <c>tar</c> command to ensure that
proper group IDs are enforced on the unpacked stage:
</p>

<pre caption="Unpacking the stage tarball">
# <i>tar --numeric-owner -xvjpf stage3-*.tar.bz2</i>
</pre>

<p>
Once you're ready to chroot into your unpacked stage in <uri
link="/doc/en/handbook/handbook-x86.xml?part=1&amp;chap=6#doc_chap1">part
6</uri>, you will need to use a different chroot command sequence. This ensures
that your environment variables are properly setup.
</p>

<pre caption="Chrooting into the new environment">
<comment>(Some LiveCDs use a funny environment setup, hence the -i option for
cleaning it up to a reasonable state.)</comment>
# <i>chroot /mnt/gentoo /bin/env -i TERM=$TERM /bin/bash</i>
# <i>env-update</i>
# <i>source /etc/profile</i>
# <i>export PS1="(chroot) $PS1"</i>
</pre>

<p>
Finally, know that some Portage FEATURES may not work in your LiveCD. Especially
watch out for <c>userpriv</c> and <c>usersandbox</c>. If you find yourself
getting errors, it might be wise to disable some or all of the optional
FEATURES.
</p>

<!--
  Commenting out due to #78716. If it needs to be restated again, note
  that some will require to bind-mount it, others don't, and that you have
  a 50-50 chance of winning the gold strike.


<p>
You will also need to bind-mount the device tree to resolve permission issues
with various device files.
</p>

< ! - -
  If this doesn't seem to work, #71901 mentions the following command:
    mount -o remount,rw,nosuid /dev/hd* /mnt/hd*
  before all. Looks weird to me, but if this doesn't work, we might want to try
  that.
- - >

<pre caption="Bind-mounting the device tree">
# <i>mount -o bind /dev /mnt/gentoo/dev</i>
</pre>
-->

</body>
</section>
</chapter>

<chapter>
<title>Diskless install using PXE boot</title>
<section>
<title>Requirements</title>
<body>

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

</body>
</section>
<section>
<title>Server base setup</title>
<body>

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

<pre caption="Directory setup">
# <i>mkdir /diskless</i>
# <i>mkdir /diskless/eta</i>
# <i>mkdir /diskless/eta/boot</i>
</pre>

<p>
DHCP and TFTP setup: The client will get boot informations using DHCP and
download all the required files using TFTP.
</p>

<p>
For dhcpd, just run <c>emerge dhcp</c> (or any other DHCP server of your
choice). Make sure that the correct interface is selected in
<path>/etc/conf.d/dhcpd</path>, and configure it for your basic needs. Then, add
the following on <path>/etc/dhcp/dhcpd.conf</path>.
</p>

<note>
This provides a static IP address for the client and the path of a PXE boot
image, here <path>pxegrub</path>. 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.
</note>

<pre caption="dhcpd.conf">
option option-150 code 150 = text ;
ddns-update-style none ;
host eta {
hardware ethernet 00:00:00:00:00:00;
fixed-address <i>ip.add.re.ss</i>;
option option-150 "/eta/boot/grub.lst";
filename "/eta/boot/pxegrub";
}
</pre>

<p>
Next you'll need to configure your interface in <path>/etc/conf.d/net</path> so
that it doesn't get cleared at bootup. See
<path>/usr/share/doc/openrc-*/net.example.bz2</path> for more information.
</p>

<pre caption="/etc/conf.d/net">
<comment>(Replace eth0 with the correct interface)</comment>
config_eth0=( "noop" )
</pre>

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

<pre caption="in.tftpd">
INTFTPD_PATH="/diskless"
INTFTPD_USER="nobody"
INTFTPD_OPTS="-u ${INTFTPD_USER} -l -vvvvvv -p -c -s ${INTFTPD_PATH}"
</pre>

<p>
Setup GRUB: To provide PXE booting I use GRUB with the <c>netboot</c> USE flag
enabled. Once GRUB is compiled, copy the PXE image to the diskless client's
boot directory. Then edit its <path>grub.lst</path> config file.
</p>

<pre caption="Grub setup">
# <i>echo "sys-boot/grub netboot" &gt;&gt; /etc/portage/package.use</i>
# <i>emerge -av grub</i>
# <i>cp /usr/lib/grub/pxegrub /diskless/eta/boot/pxegrub</i>
# <i>nano -w /diskless/eta/boot/grub.lst</i>
</pre>

<pre caption="grub.lst">
default 0
timeout 30

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

<comment># 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).</comment>
</pre>

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

<pre caption="/etc/exports">
# <i>nano -w /etc/exports</i>
# /etc/exports: NFS file systems being exported.  See exports(5).
/diskless/eta eta(rw,sync,no_root_squash)
</pre>

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

<pre caption="/etc/hosts">
127.0.0.1 localhost

192.168.1.10 eta.example.com eta
192.168.1.20 sigma.example.com sigma
</pre>

</body>
</section>
<section>
<title>Creating the system on the server</title>
<body>

<p>
You might want to reboot the server with a Gentoo Install CD, 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 <uri link="/doc/en/handbook/">Gentoo
Handbook</uri> BUT with the following differences:
When you mount the file system, do the following (where <path>sdaX</path> is
the partition where you created the <path>/diskless</path> directory). You do
not need to mount any other partitions as all of the files will reside in the
<path>/diskless/eta</path> directory.
</p>

<pre caption="Mounting the filesystem">
#<i> mount /dev/sdaX /mnt/gentoo</i>
</pre>

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

<warn>
Be very careful where you extract your stage tarball. You don't want to end up
extracting over your existing installation.
</warn>

<pre caption="Extracting the stage tarball">
# <i>cd /mnt/gentoo/diskless/eta/</i>
# <i>tar -xvjpf  /mnt/cdrom/gentoo/stage3-*.tar.bz2</i>
# <i>mount -t proc /proc /mnt/gentoo/diskless/eta/proc</i>
# <i>cp /etc/resolv.conf /mnt/gentoo/diskless/eta/etc/resolv.conf</i>
# <i>chroot /mnt/gentoo/diskless/eta/ /bin/bash</i>
# <i>env-update</i>
# <i>source /etc/profile</i>
</pre>

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

<pre caption="menuconfig options">
- Your network card device support
<comment>(In the kernel, *not* as a module!)</comment>

- Under "Networking options" :

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


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

&lt;*&gt; NFS file system support
[*] Provide NFSv3 client support
[*] Root file system on NFS
</pre>

<p>
Save the kernel in your chrooted <path>/</path> (not in <path>/boot</path>)
according to the pxegrub setting defined earlier. Next configure your
diskless client's <path>/etc/fstab</path>.
</p>

<pre caption="/etc/fstab">
# <i>nano -w /etc/fstab</i>
/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
</pre>

<p>
You also need to prevent the client to run a filesystem check:
</p>

<pre caption="Preventing the client to run a filesystem check">
# <i>touch /fastboot</i>
# <i>echo "touch /fastboot" &gt;&gt; /etc/conf.d/local.start</i>
</pre>

<p>
Install <c>nfs-utils</c> since your client will heavily depend on it:
</p>

<pre caption="Installing nfs-utils">
# <i>emerge nfs-utils</i>
</pre>

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

<pre caption="Starting services">
# <i>/etc/init.d/dhcp start</i>
# <i>/etc/init.d/in.tftpd start</i>
# <i>/etc/init.d/nfs start</i>
</pre>

</body>
</section>
<section>
<title>Booting the new client</title>
<body>

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

</body>
</section>
</chapter>

<chapter>
<title>Installing Gentoo from an existing Linux distribution</title>
<section>
<title>Requirements</title>
<body>

<p>
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!
</p>

</body>
</section>
<section>
<title>Overview</title>
<body>

<p>
We will first allocate a partition to Gentoo by resizing our existing Linux
partition, mount the partition, untar the tarball to the partition that is
mounted, chroot inside the pseudo-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.
</p>

</body>
</section>
<section>
<title>How should we make space for Gentoo?</title>
<body>

<p>
The root partition is the filesystem mounted under <path>/</path>. A quick run
of <c>mount</c> on my system shows what I am talking about. We well also use
<c>df</c> (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.
</p>

<pre caption="Filesystem information">
# <i>mount</i>
/dev/sdb2 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)
# <i>df -h </i>
Filesystem           Size Used Avail Use% Mounted on
/dev/sdb2            4.0G 1.9G  2.4G  82% /
none                  38M    0   38M   0% /dev/shm
</pre>

<p>
As we can see, the partition mounted as <path>/</path> named
<path>/dev/sdb2</path> 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, I think
that even one gigabyte is enough for most users. So let's partition this thing!
</p>

</body>
</section>
<section>
<title>Building parted to resize partition</title>
<body>

<p>
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
<uri>http://www.gnu.org/software/parted/</uri>
</p>

<note>
There are other tools for doing resize of partitions as well, but the 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
</note>

<p>
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 <path>/</path>.  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.
</p>

<impo>
Make sure that the operations you want to do on your partition are supported by
parted!
</impo>

<p>
Get the mininux boot/root disk (a 2.4-powered mini Linux distribution on a
floppy - free of charge) from <uri>http://mininux.free.fr/uk/</uri>, 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.
</p>

<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 boot/root diskset other than mininux. You might not even
need to do this step at all, ie. you might only have umount the filesystem you
want to repartition in your Linux session and run parted on it.
</note>

<pre caption="Utility disk creation">
# <i>mkfs.minix /dev/fd0</i>
480 inodes
1440 blocks
Firstdatazone=19 (19)
Zonesize=1024
Maxsize=268966912
</pre>

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

<pre caption="Building the utility floppy">
# <i> mkdir /floppy; mount -t minix /dev/fd0 /floppy &amp;&amp;
export CFLAGS="-O3 -pipe -fomit-frame-pointer -static" &amp;&amp; ./configure
&amp;&amp; make &amp;&amp; cp parted/parted /floppy &amp;&amp; umount /floppy </i>
</pre>

<p>
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 mininux 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 <c>mount /dev/fd0 /floppy</c> to have parted
under <path>/floppy</path>.  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.
The drive you wish to operate on is the drive containing the partition we want
to resize. For example, if we want to resize /dev/sda3, the drive is /dev/sda.
</p>

<pre caption="Commands to run once logged into mininux system">
# <i>mount /dev/fd0 /floppy </i>
# <i>cd /floppy; ./parted [drive you wish to operate on]</i>
(parted) <i> print </i>
Disk geometry for /dev/sdb: 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) <i> help resize </i>
  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) <i> resize 2 3133.266 4000.000 </i>
</pre>

<impo>
Be patient! The computer is working! Just look at the harddrive LED on your case
to see that it is really working. This should take between 2 and 30 minutes.
</impo>

<p>
Once you have resized, boot back into your old linux as described. Then go to
<uri link="/doc/en/handbook/handbook-x86.xml?part=1&amp;chap=4">The Gentoo
Handbook: Preparing the Disks</uri> and follow the instructions. When
chrooting, use the following command to flush your environment:
</p>

<pre caption="Flushing the environment during chroot">
# <i>env -i HOME=$HOME TERM=$TERM chroot /mnt/gentoo /bin/bash</i>
# <i>/usr/sbin/env-update</i>
# <i>source /etc/profile</i>
</pre>

<p>
Enjoy!
</p>

</body>
</section>
</chapter>
</guide>
