Difference between pages "Funtoo Linux Installation" and "Funtoo:Metro"

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
 
(remove wrong branch)
 
Line 1: Line 1:
<div class="container"><div class="row"><div class="col-sm-12 col-md-9">
[[Metro]] is the build system for [[Funtoo Linux]] and [[Gentoo Linux]] stages. It automates the bootstrapping process.
== Introduction ==


This document was written to help you install Funtoo Linux as concisely as possible, with a minimum number of distracting options regarding system configuration.  
This tutorial will take you through installing, setting up and running [[Metro]].


These docs assume you have a "PC compatible" computer system with a standard PC BIOS. Many new computers support UEFI for booting, which is a new firmware interface that frequently replaces the older MBR-based BIOS. If you have a system with UEFI, you will want to use this documentation along with the [[UEFI Install Guide]], which will augment these instructions and explain how to get your system to boot. You may need to change your PC BIOS settings to enable or disable UEFI booting. The [[UEFI Install Guide]] has more information on this, and steps on how to determine if your system supports UEFI.
= Preface =


We also offer a [[ZFS Install Guide]], which augment the instructions on this page for those who want to install Funtoo Linux on ZFS.  If you are installing Funtoo Linux on [[Funtoo Linux Installation on ARM|ARM]] architecture, please see [[Funtoo Linux Installation on ARM]] for notable differences regarding ARM support. An experimental Funtoo Linux build also exists for [[Funtoo Linux Installation on SPARC|SPARC]] platforms. See [[Funtoo Linux Installation on SPARC]].
== How Metro Works ==


If you've had previous experience installing Gentoo Linux then a lot of steps will be familiar, but you should still read through as there are a few differences.
You may be wondering how [[Metro]] creates its first stage tarball. As you may have guessed, [[Metro]] cannot create a stage tarball out of thin air. To build a new stage tarball, [[Metro]] must use an existing, older stage tarball called a &quot;seed&quot; stage. This &quot;seed&quot; stage typically is used as the ''build environment'' for creating the stage we want.


== Installation Overview ==
[[Metro]] can use two kinds of seed stages. Traditionally, [[Metro]] has used a stage3 as a seed stage. This stage3 is then used to build a new stage1, which in turn is used to build a new stage2, and then a new stage3. This is generally the most reliable way to build [[Gentoo Linux]] or [[Funtoo Linux]], so it's the recommended approach.
{{fancyimportant|'''After switching metro builds to Funtoo profile, Gentoo stages are no longer provided'''!}}


This is a basic overview of the Funtoo installation process:
== Seeds and Build Isolation ==


# [[#Live CD|Download and boot the live CD of your choice]].
Another important concept to mention here is something called ''build isolation''. Because [[Metro]] creates an isolated build environment, and the build environment is explicitly defined using existing, tangible entities -- a seed stage and a portage snapshot -- you will get consistent, repeatable results. In other words, the same seed stage, portage snapshot and build instructions will generate an essentially identical result, even if you perform the build a month later on someone else's workstation.
# [[#Prepare Hard Disk|Prepare your disk]].
# [[#Creating filesystems|Create]] and [[#Mounting filesystems|mount]] filesystems.
# [[#Installing the Stage 3 tarball|Install the Funtoo stage tarball]] of your choice.
# [[#Chroot into Funtoo|Chroot into your new system]].
# [[#Downloading the Portage tree|Download the Portage tree]].
# [[#Configuring your system|Configure your system]] and [[#Configuring your network|network]].
# [[#Configuring and installing the Linux kernel|Install a kernel]].
# [[#Installing a Bootloader|Install a bootloader]].
# [[#Finishing Steps|Complete final steps]].
# [[#Restart your system|Reboot and enjoy]].


=== Live CD ===
== Local Build ==  


Funtoo doesn't provide an "official" Funtoo Live CD, but there are plenty of good ones out there to choose from. A great choice is the Gentoo-based [http://www.sysresccd.org/ System Rescue CD] as it contains lots of tools and utilities and supports both 32-bit and 64-bit systems.
Say you wanted to build a new <tt>pentium4</tt> stage3 tarball. The recommended method of doing this would be to grab an existing <tt>pentium4</tt> stage3 tarball to use as your seed stage. [[Metro]] will be told to use this existing <tt>pentium4</tt> stage3 to build a new stage1 for the same <tt>pentium4</tt>. For this process, the generic <tt>pentium4</tt> stage3 would provide the ''build environment'' for creating our new stage1. Then, the new stage1 would serve as the build environment for creating the new <tt>pentium4</tt> stage2. And the new <tt>pentium4</tt> stage2 would serve as the build environment for creating the new <tt>pentium4</tt> stage3.


It is also possible to install Funtoo Linux using many other Linux-based live CDs. Generally, any modern bootable Linux live CD or live USB media will work. See [[Requirements|requirements]] for an overview of what the Live Media must provide to allow a problem-free install of Funtoo Linux.
In the [[Metro]] terminology this is called a '''local build''', which means a stage3 of a given architecture is used to seed a brand new build of the same architecture. Incidentally this will be the first exercise we are going to perform in this tutorial.


To begin a Funtoo Linux installation, download System Rescue CD from:
A week later, you may want to build a brand new <tt>pentium4</tt> stage3 tarball. Rather than starting from the original <tt>pentium4</tt> stage3 again, you'd probably configure [[Metro]] to use the most-recently-built <tt>pentium4</tt> stage3 as the seed. [[Metro]] has built-in functionality to make this easy, allowing it to easily find and track the most recent stage3 seed available.


{{MirrorList}}
== Remote Build ==


Or, use your preferred live media. Insert it into your disc drive, and boot from it. If using an older version of System Rescue CD, '''be sure to select the <code>rescue64</code> kernel at the boot menu if you are installing a 64-bit system'''. By default, System Rescue CD used to boot in 32-bit mode though the latest version attempts to automatically detect 64-bit processors.
[[Metro]] can also perform '''remote build''', where a stage3 of a different, but binary compatible, architecture is used as a seed to build a different architecture stage3. Consequentiality the second exercise we are going to perform in this tutorial will be to build a <tt>core2 32bit</tt> stage3 tarball from the <tt>pentium4</tt> stage3 tarball we have just built.


=== Prepare Hard Disk ===
TODO: add caveats about what archs can be seeded and what can be not (maybe a table?)
==== Partitions ====


Funtoo Linux fully supports traditional MBR partitions, as well as newer GPT/GUID partition formats. See below to determine which partitioning scheme to use:
== Tailored Build ==


===== MBR Partitions =====
Last, it's also worthy noting that both in <tt>local</tt> and <tt>remote builds</tt>, [[Metro]] can be configured to add and/or remove individual packages to the final tarball.
Let's say you can't live without <tt>app-misc/screen</tt>, at the end of this tutorial, we will show how to have your tailored stage3 to include it.


* '''Recommended if your system disk is <=2TB in size'''
== Installing Metro ==
* Legacy, DOS partitioning scheme
* Only 4 primary partitions per disk; after that, you must use "logical" partitions
* Does not support 2 TB+ disks for booting
* Compatible with certain problematic systems (such as the HP ProBook 4520)
* Dual-boot with Windows for BIOS systems (Windows handle GPT only on true EFI systems, whatever version it is)
* Multiple boot loader options, e.g. GRUB 2, GRUB Legacy, lilo


{{fancynote|Due to the fact that it is more widely supported on PC hardware, it is best to use MBR partitions if possible.}}
'''The recommended and supported method''' is to use the Git repository of [[Metro]]. First, ensure you remove the {{Package|dev-util/metro}} package if you had installed it:
 
===== GPT Partitions =====
 
* '''Recommended if your disk is >2TB in size'''
* Newer format for Linux systems
* Supports 2 TB+ hard drives for booting
* Supports hundreds of partitions per disk of any size
* Requires legacy BIOS boot partition (~32 MB) to be created if system does not use EFI
* Requires bootloader with support for GPT such as GRUB 2, EXTLINUX, or a patched version of GRUB Legacy
 
{{fancyimportant|If you have a system disk that is 2TB or greater and want to use the space beyond 2TB, you ''must'' partition using the GPT/GUID format. Otherwise, MBR is recommended as the most reliable boot method.}}
 
===== Filesystem Resources =====
 
Advanced users may be interested in the following topics:
 
* [[GUID Booting Guide]]
* [[LVM Install Guide]]
* [[Rootfs over encrypted lvm]]
* [[Rootfs over encrypted lvm over raid-1 on GPT]]
* '''NEW!''' '''[[ZFS Install Guide]] (Also contains instructions for Rootfs over Encrypted ZFS!)'''
 
===== Partitioning Recommendations =====
 
Below are our partitioning recommendations in table form. For MBR-based partitions, use the MBR Block Device and MBR code columns with <code>fdisk</code>. For GPT-based partitions, use the GPT Block Device and GPT Code columns with <code>gdisk</code>:
 
{{TableStart}}
<tr class="active"><th>Partition</th>
<th>Size</th>
<th>MBR Block Device (<code>fdisk</code>)</th>
<th>GPT Block Device (<code>gdisk</code>)</th>
<th>Filesystem</th>
<th>MBR Code</th>
<th>GPT Code</th>
</tr><tr>
<td><code>/boot</code></td>
<td>512 MB</td>
<td><code>/dev/sda1</code></td>
<td><code>/dev/sda1</code></td>
<td>ext2</td>
<td>83</td>
<td>8300</td>
</tr><tr>
<td>GRUB boot loader partition</td>
<td>1 MB</td>
<td>''not required for MBR''</td>
<td><code>/dev/sda2</code></td>
<td>For GPT/GUID only, skip for MBR - no filesystem.</td>
<td>''N/A''</td>
<td>EF02</td>
</tr><tr>
<td>swap</td>
<td>2x RAM for low-memory systems and production servers; otherwise 2GB.</td>
<td><code>/dev/sda2</code></td>
<td><code>/dev/sda3</code></td>
<td>swap (default)</td>
<td>82</td>
<td>8200</td>
</tr><tr>
<td><code>/</code> (root)</td>
<td>Rest of the disk, minimum of 10GB.  Note: to compile the <code>debian-sources</code> kernel, as described later on this page, requires a minimum of 14GB free space in <code>/tmp</code>; consider a minimum of 20GB in this case.</td>
<td><code>/dev/sda3</code></td>
<td><code>/dev/sda4</code></td>
<td>XFS recommended, alternatively ext4</td>
<td>83</td>
<td>8300</td>
</tr><tr>
<td><code>/home</code> (optional) </td>
<td>User storage and media. Typically most of the disk.</td>
<td><code>/dev/sda4</code> (if created)</td>
<td><code>/dev/sda5</code> (if created)</td>
<td>XFS recommended, alternatively ext4</td>
<td>83</td>
<td>8300</td>
</tr><tr>
<td>LVM (optional)</td>
<td>If you want to create an LVM volume.</td>
<td><code>/dev/sda4</code> (PV, if created)</td>
<td><code>/dev/sda5</code> (PV, if created)</td>
<td>LVM PV</td>
<td>8E</td>
<td>8E00</td>
</tr>{{TableEnd}}
 
===== '''Partitioning Using fdisk (MBR)''' =====
 
{{fancyimportant|If you need to create a GPT partition table, see [[Partitioning using gdisk]].}}
 
{{fancynote|These install instructions assume you are installing Funtoo Linux to an hard disk using Master Boot Record partition tables (MBR). If you are installing Funtoo Linux on a machine where another OS is installed, there is an existing Linux distribution on your system that you want to keep or any other scenario (such as differing swap size requirements), then you will need to adapt these instructions to suit your needs.}}
 
<code>fdisk</code> is the tool used to create an MBR partition table. MBR is well-supported on PCs and is recommended if your system disk is 2TB or smaller.
 
====== Preparation ======
 
First, it's a good idea to make sure that you've found the correct hard disk to partition. Try this command and verify that <code>/dev/sda</code> is the disk that you want to partition:


<console>
<console>
# ##i##fdisk -l /dev/sda
# ##i##emerge -aC dev-util/metro
 
Disk /dev/sda: 640.1 GB, 640135028736 bytes, 1250263728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
 
 
#        Start          End    Size  Type            Name
1        2048  1250263694  596.2G  Linux filesyste Linux filesystem
</console>
</console>


Now, it's recommended that you erase any existing MBR or GPT partition tables on the disk, which could confuse the system's BIOS at boot time. We do this using <code>sgdisk</code>:
Then ensure that {{Package|dev-vcs/git}} and {{Package|dev-python/boto}} are installed on your system:
{{fancywarning|This will make any existing partitions inaccessible! You are '''strongly''' cautioned and advised to backup any critical data before proceeding.}}


<console>
<console>
# ##i##sgdisk --zap-all /dev/sda
# ##i##emerge dev-vcs/git
 
# ##i##emerge dev-python/boto
Creating new GPT entries.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
</console>
</console>


This output is also nothing to worry about, as the command still succeded:
Next, clone the master git repository as follows:


<console>
<console>
***************************************************************
# ##i##install -d /root/git
Found invalid GPT and valid MBR; converting MBR to GPT format
# ##i##cd /root/git
in memory.  
# ##i##git clone git://github.com/funtoo/metro.git
***************************************************************
# ##i##ln -s /root/git/metro /usr/lib/metro
# ##i##ln -s /root/git/metro/metro /usr/bin/metro
</console>
</console>


====== Partitioning ======
You will now have a directory called <tt>/root/git/metro</tt> that contains all the [[Metro]] source code.
Installation complete!


Now we will use <code>fdisk</code> to create the MBR partition table and partitions:
= Configuring Metro =


<console>
[[User:Drobbins|Daniel Robbins]] maintains [[Metro]], so it comes pre-configured to successfully build both [[Gentoo Linux]] and [[Funtoo Linux]] releases. Before reading farther, you might want to customize some basic settings like the number of concurrent jobs to fit your hardware's capabilities or the directory to use for produced stage archives. This is accomplished by editing <tt>/root/git/metro/etc/metro.conf</tt> which is the [[Metro]]'s master configuration file. The <tt>[path/mirror]</tt> section defines where [[Metro]] will look for things it needs and also dump things it creates. As initially configured, [[Metro]] is set up to build [[Funtoo Linux]] and [[Gentoo Linux]] stage tarballs and place them in the <tt>/home/mirror/funtoo</tt> directory:
# ##i##fdisk /dev/sda
</console>


Within <code>fdisk</code>, follow these steps:
<pre>
# Mirror Paths - where to find required files and where to put created files


'''Empty the partition table''':
[section path/mirror]


<console>
: /home/mirror/funtoo
Command (m for help): ##i##o ↵
</pre>
</console>
 
'''Create Partition 1''' (boot):


<console>
If you want to change the location of your mirror on disk, then edit the <tt>/home/mirror/funtoo</tt> line (which defines the path/mirror variable) to point to another directory.
Command (m for help): ##i##n ↵
Partition type (default p): ##i##↵
Partition number (1-4, default 1): ##i##↵
First sector: ##i##↵
Last sector: ##i##+128M ↵
</console>


'''Create Partition 2''' (swap):
For the purpose of the following steps, set an environment variable:


<console>
<console>
Command (m for help): ##i##n ↵
# ##i##export METRO_MIRROR=/home/mirror/funtoo
Partition type (default p): ##i##↵
</console>  
Partition number (2-4, default 2): ##i##↵
First sector: ##i##↵
Last sector: ##i##+2G ↵
Command (m for help): ##i##t ↵
Partition number (1,2, default 2): ##i## ↵
Hex code (type L to list all codes): ##i##82 ↵
</console>


'''Create the root partition:'''
Of course, set the environment variable to whatever location you used in the configuration file.


<console>
== Arch and Subarch ==
Command (m for help): ##i##n ↵
Partition type (default p): ##i##↵
Partition number (3,4, default 3): ##i##↵
First sector: ##i##↵
Last sector: ##i##↵
</console>
 
'''Verify the partition table:'''
 
<console>
Command (m for help): ##i##p
 
Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x82abc9a6
 
Device    Boot    Start      End    Blocks  Id System
/dev/sda1          2048    264191    131072  83 Linux
/dev/sda2        264192  4458495  2097152  82 Linux swap / Solaris
/dev/sda3        4458496 625142447 310341976  83 Linux
</console>
 
'''Write the parition table to disk:'''
 
<console>
Command (m for help): ##i##w
</console>
 
Your new MBR partition table will now be written to your system disk.
 
==== Creating filesystems ====
 
Before your newly-created partitions can be used, the block devices need to be initialized with filesystem ''metadata''. This process is known as ''creating a filesystem'' on the block devices. After filesystems are created on the block devices, they can be mounted and used to store files.
 
You will not create a filesystem on your swap partition, but will initialize it using the <code>mkswap</code> command so that it can be used as disk-based virtual memory. Then we'll run the <code>swapon</code> command to make your newly-initialized swap space active within the live CD environment, in case it is needed during the rest of the install process.
 
Note that we will not create a filesystem on the GRUB boot loader partition, as GRUB writes binary data directly to that partition when the boot loader is installed, which we'll do later.
 
You can see the commands you will need to type below. Like the rest of this document, it assumes that you are using a GPT partitioning scheme. If you are using MBR, your root filesystem will likely be created on <code>/dev/sda3</code> instead and you will need to adjust the target block devices. If you are following our recommendations, then simply do this:
 
'''We generally recommend XFS for root filesystems, although ext4 is also a good choice.''' This tutorial assumes the use of XFS. If you want to use ext4, then be sure that your <code>/etc/fstab</code> file reflects this.
 
{{fancywarning|1=
When deploying an OpenVZ host, please use ext4 exclusively. The Parallels development team tests extensively with ext4, and modern versions of <code>openvz-rhel6-stable</code> are '''not''' compatible with XFS, and you may experience kernel bugs.
}}
 
'''To use ext4 as your root filesystem:'''


In the following example we are creating a pentium4 stage 3 compiled for x86-32bit binary compatibility. Pentium4 is a subarch of the x86-32bit architecture. Once you have metro installed you may find a full list of each subarch in your <tt>/usr/lib/metro/subarch</tt> directory each subarch will have the file extension .spec
Example:
<console>
<console>
# ##i##mke2fs -t ext2 /dev/sda1
###i## ls /usr/lib/metro/subarch/
# ##i##mkfs.ext4 /dev/sda3
amd64-k10.spec        athlon-tbird.spec  generic_32.spec      native_32.spec  pentium-mmx.spec
# ##i##mkswap /dev/sda2
amd64-k8_32.spec      athlon-xp.spec    generic_64.spec      native_64.spec  pentium-m.spec
# ##i##swapon /dev/sda2
amd64-k8.spec          atom_32.spec      generic_sparcv9.spec  niagara2.spec    pentiumpro.spec
amd64-k8+sse3_32.spec  atom_64.spec      geode.spec            niagara.spec    pentium.spec
amd64-k8+sse3.spec    btver1_64.spec    i486.spec            nocona.spec      prescott.spec
armv7a.spec            btver1.spec        i686.spec            opteron_64.spec  ultrasparc3.spec
athlon-4.spec          core2_32.spec      k6-2.spec            pentium2.spec    ultrasparc.spec
athlon-mp.spec        core2_64.spec      k6-3.spec            pentium3.spec    xen-pentium4+sse3_64.spec
athlon.spec            corei7.spec        k6.spec              pentium4.spec    xen-pentium4+sse3.spec
</console>
</console>
{{Fancynote|For an example list of Architectures, take a look at the directory listing on the [http://ftp.osuosl.org/pub/funtoo/funtoo-current/ Funtoo-Current Mirror].}}


'''To use XFS as your root filesystem:'''
= First stages build (local build) =


<console>
To get this all started, we need to bootstrap the process by downloading an initial seed stage3 to use for building and place it in its proper location in <tt>/home/mirror/funtoo</tt>, so that [[Metro]] can find it. We will also need to create some special &quot;control&quot; files in <tt>/home/mirror/funtoo</tt>, which will allow [[Metro]] to understand how it is supposed to proceed.
# ##i##mke2fs -t ext2 /dev/sda1
# ##i##mkfs.xfs /dev/sda3
# ##i##mkswap /dev/sda2
# ##i##swapon /dev/sda2
</console>


==== Mounting filesystems ====
== Step 0: Optional Quick Copy of Portage Tree ==


Mount the newly-created filesystems as follows, creating <code>/mnt/funtoo</code> as the installation mount point:
There is a quick step you can perform to avoid having Metro re-clone the entire Portage tree. Perform this as root:


<console>
<console>
# ##i##mkdir /mnt/funtoo
# ##i##install -d /var/tmp/metro/cache/cloned-repositories
# ##i##mount /dev/sda3 /mnt/funtoo
# ##i##cat /root/git/metro/etc/builds/funtoo-current/build.conf  | grep name
# ##i##mkdir /mnt/funtoo/boot
# ##i##name: ports-2012
# ##i##mount /dev/sda1 /mnt/funtoo/boot
# ##i##cp -a /usr/portage /var/tmp/metro/cache/cloned-repositories/ports-2012
# ##i##cd /usr/portage; git checkout funtoo.org
</console>
</console>


Optionally, if you have a separate filesystem for <code>/home</code> or anything else:
== Step 1: Set up pentium4 repository (local build) ==
 
<console>
# ##i##mkdir /mnt/funtoo/home
# ##i##mount /dev/sda4 /mnt/funtoo/home
</console>
 
If you have <code>/tmp</code> or <code>/var/tmp</code> on a separate filesystem, be sure to change the permissions of the mount point to be globally-writeable after mounting, as follows:
 
<console>
# ##i##chmod 1777 /mnt/funtoo/tmp
</console>
 
=== Installing the Stage 3 tarball ===
After creating filesystems, the next step is downloading the initial Stage 3 tarball. The Stage 3 is a pre-compiled system used as a starting point to install Funtoo Linux. Load one of the following URLs in another browser window:
 
{{MirrorList}}
 
Now, let's navigate the directories on the mirrors to find the appropriate build of Funtoo Linux for you.
 
==== Stable or Current? ====
Funtoo Linux has a "stable" build and a "current" build. Most people use the "current" build of Funtoo Linux, and it's generally recommended that you do too. You will find "current' builds in the main <code>/funtoo-current</code> directory on our mirrors, and "stable" builds in <code>/funtoo-stable</code>.
<br />If you want to read more about this, have a look at [[Funtoo_Linux#What_are_the_differences_between_.27stable.27.2C_.27current.27_and_.27experimental.27_.3F|Differences between stable, current and experimental]].
 
==== 32 or 64-bit? ====
There are three different types of Funtoo Linux that you can install. If you are installing on an older 32-bit system (if you don't know, then you probably are not) then you want to grab a stage3 tarball from the <code>x86-32bit</code> sub-directory. Most likely, you'll want to grab a 64-bit build from the <code>x86-64bit</code> sub-directory.
 
==== Your SubArch ====
Inside <code>/funtoo-current/x86-64bit/</code> on one of our mirrors, you'll see a bunch of directories for various ''subarches'' of Funtoo Linux.
 
Subarches are builds of Funtoo Linux that are designed to run on a particular type of CPU, to offer the best possible performance. They take advantage of the instruction sets available for each CPU.
 
For example, the <code>corei7</code> and <code>corei7-pure64</code> sub-arches require an Intel Core i7 processor to run (this includes Xeon x3400+ series, or other Nehalem-based CPUs such as Xeon x5500/x5600 series.)
 
If you are using an AMD-based CPU, download a stage3 from <code>generic_64</code>, <code>amd64-k8</code> or <code>amd64-k10</code>.
 
If you are using an Intel-based CPU, download a stage3 from <code>generic_64</code>, <code>atom_64</code>, <code>core2_64</code> or <code>corei7</code>.
 
===== Pure64 Builds =====
Inside <code>/funtoo-current/</code>, you may notice a sub-directory named <code>pure64</code>. These builds are recommended for server systems, and they do not offer any 32-bit compatibility, which is generally not needed on server systems. If you are setting up a desktop or workstation system, it's recommended that you avoid these builds as you will need 32-bit compatibility to run several binary desktop-oriented applications such as Skype. But for servers, pure64 is recommended.
 
==== Setting the Date ====
 
{{fancyimportant|If your system's date and time are too far off (typically by months or years,) then it may prevent Portage from properly downloading source tarballs. This is because some of our sources are downloaded via HTTPS, which use SSL certificates and are marked with an activation and expiration date.}}


Now is a good time to verify the date and time are correctly set to UTC. Use the <code>date</code> command to verify the date and time:
Assuming we're following the basic steps outlined in the previous section, and building an unstable funtoo (<tt>funtoo-current</tt>) build for the <tt>pentium4</tt>, using a generic <tt>pentium4</tt> stage3 as a seed stage, then here the first set of steps we'd perform:


<console>
<console>
# ##i##date
# ##i##install -d "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"
Fri Jul 15 19:47:18 UTC 2011
# ##i##cd "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"
# ##i##install -d 2011-12-13
# ##i##cd 2011-12-13
# ##i##wget -c http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-32bit/pentium4/2011-12-13/stage3-pentium4-funtoo-current-2011-12-13.tar.xz
# ##i##cd ..
# ##i##install -d .control/version
# ##i##echo &quot;2011-12-13&quot; &gt; .control/version/stage3
# ##i##install -d .control/strategy
# ##i##echo &quot;local&quot; &gt; .control/strategy/build
# ##i##echo &quot;stage3&quot; &gt; .control/strategy/seed
</console>
</console>


If the date and/or time need to be corrected, do so using <code>date MMDDhhmmYYYY</code>, keeping in mind <code>hhmm</code> are in 24-hour format. The example below changes the date and time to "July 16th, 2011 @ 8:00PM" UTC:
OK, let's review the steps above. First, we create the directory <tt>"${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"</tt>, which is where Metro will expect to find unstable <tt>funtoo-current</tt> pentium4 builds -- it is configured to look here by default. Then we create a specially-named directory to house our seed x86 stage3. Again, by default, Metro expects the directory to be named this way. We enter this directory, and download our seed x86 stage3 from funtoo.org. Note that the <tt>2010-12-24</tt> version stamp matches. Make sure that your directory name matches the stage3 name too. Everything has been set up to match Metro's default filesystem layout.
 
<console>
# ##i##date 071620002011
Fri Jul 16 20:00:00 UTC 2011
</console>


==== Download the Stage3 ====
Next, we go back to the <tt>"${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"</tt> directory, and inside it, we create a <tt>.control</tt> directory. This directory and its subdirectories contain special files that Metro references to determine certain aspects of its behavior. The <tt>.control/version/stage3</tt> file is used by Metro to track the most recently-built stage3 for this particular build and subarch. Metro will automatically update this file with a new version stamp after it successfully builds a new stage3. But because Metro didn't actually ''build'' this stage3, we need to set up the <tt>.control/version/stage3</tt> file manually. This will allow Metro to find our downloaded stage3 when we set up our pentium4 build to use it as a seed. Also note that Metro will create a similar <tt>.control/version/stage1</tt> file after it successfully builds an pentium4 funtoo-current stage1.
Once you are in your Funtoo Linux root filesystem, use <code>wget</code> to download the Stage 3 tarball you have chosen to use as the basis for your new Funtoo Linux system. It should be saved to the <code>/mnt/funtoo</code> directory as follows:


<console># ##i##cd /mnt/funtoo
We also set up <tt>.control/strategy/build</tt> and <tt>.control/strategy/seed</tt> files with values of <tt>local</tt> and <tt>stage3</tt> respectively. These files define the building strategy Metro will use when we build pentium4 funtoo-current stages. With a build strategy of <tt>local</tt>, Metro will source its seed stage from funtoo-current pentium4, the current directory. And with a seed strategy of <tt>stage3</tt>, Metro will use a stage3 as a seed, and use this seed to build a new stage1, stage2 and stage3.
# ##i##wget http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-64bit/generic_64/stage3-latest.tar.xz
</console>


== Step 2: Building the pentium4 stages ==


Note that 64-bit systems can run 32-bit or 64-bit stages, but 32-bit systems can only run 32-bit stages. Make sure that you select a Stage 3 build that is appropriate for your CPU. If you are not certain, it is a safe bet to choose the <code>generic_64</code> or <code>generic_32</code> stage. Consult the [[Download]] page for more information.
Incidentally, if all you wanted to do at this point was to build a new pentium4 funtoo-current stage1/2/3 (plus openvz and vserver templates). You would begin the process by typing:


Once the stage is downloaded, extract the contents with the following command, substituting in the actual name of your stage 3 tarball:
<console>
<console>
# ##i##tar xpf stage3-latest.tar.xz
# ##i##cd /root/git/metro
# ##i##scripts/ezbuild.sh funtoo-current pentium4
</console>
</console>


{{fancyimportant|It is very important to use <code>tar's</code> "<code>'''p'''</code>" option when extracting the Stage 3 tarball - it tells <code>tar</code> to ''preserve'' any permissions and ownership that exist within the archive. Without this option, your Funtoo Linux filesystem permissions will be incorrect.}}
If you have a slow machine, it could take several hours to be completed because several "heavy" components like gcc or glibc have to be recompiled in each stage. Once a stage has been successfully completed, it is placed in the <tt>"${METRO_MIRROR}/funtoo-current/x32-bit/pentium4/YYYY-MM-DD"</tt> subdirectory, where <tt>YYYY-MM-DD</tt> is today's date at the time the <tt>ezbuild.sh</tt> script was started or the date you put on the ezscript.sh command line.


=== Chroot into Funtoo ===
== Step 3: The next build ==
Before chrooting into your new system, there's a few things that need to be done first. You will need to mount /proc and /dev inside your new system. Use the following commands:
<console>
# ##i##cd /mnt/funtoo
# ##i##mount -t proc none proc
# ##i##mount --rbind /sys sys
# ##i##mount --rbind /dev dev
</console>
 
You'll also want to copy over <code>resolv.conf</code> in order to have proper DNS name resolution from inside the chroot:
<console>
# ##i##cp /etc/resolv.conf etc
</console>


Now you can chroot into your new system. Use <code>env</code> before <code>chroot</code> to ensure that no environment variables from the installation media are used by your new system:
At this point, you now have a new pentium4 stage3. If you'd like, you can reconfigure Metro to use the most recently-built pentium4 stage3 as a seed for any pentium4 builds. To do this, simply type:


<console>
<console> # ##i##echo &quot;local&quot; &gt; /home/mirror/funtoo/funtoo-current/x86-32bit/pentium4/.control/strategy/build</console>
# ##i##env -i HOME=/root TERM=$TERM chroot . bash -l
Now, Metro will use the most recentpentium4 stage3 as a seed. The <tt>.control/remote</tt> files you created will be ignored by Metro, since it's no longer going to perform a remote build.
</console>


{{fancynote|Users of live CDs with 64-bit kernels: Some software may use <code>uname -r</code> to check whether the system is 32 or 64-bit. You may want append linux32 to the chroot command as a workaround, but it's generally not needed.}}
= Building for another binary compatible architecture (remote build) =
{{fancyimportant|If you receive the error "<code>chroot: failed to run command `/bin/bash': Exec format error</code>", it is probably because you are running a 32-bit kernel and trying to execute 64-bit code. SystemRescueCd boots with a 32-bit kernel by default.}}


It's also a good idea to change the default command prompt while inside the chroot. This will avoid confusion if you have to change terminals. Use this command:
As written above, [[Metro]] is able to perform '''remote build''' building different architecture stage3 from a binary compatible seeding stage3 (e.g. using a pentium4 stage3 to seed a <tt>Intel Core2 32bits</tt> stage3).
<console>
# ##i##export PS1="(chroot) $PS1"
</console>


Congratulations! You are now chrooted inside a Funtoo Linux system. Now it's time to get Funtoo Linux properly configured so that Funtoo Linux will boot successfully when your system is restarted.
In the Metro terminology this is called a '''remote build''' (a stage 3 of a different, but binary compatible, architecture is used as a seed).
What's not compatible? You can't use a <tt>Sparc</tt> architecture to generate an <tt>x86</tt> or <tt>ARM</tt> based stage and vice-versa. If you use a 32bit stage then you don't want to seed a 64bit build from it. Be sure that you are using a stage from the same architecture that you are trying to seed. Check [http://ftp.osuosl.org/pub/funtoo/funtoo-current/ Funtoo-current FTP Mirror] for a stage that is from the same Architecture that you will be building.


=== Downloading the Portage tree ===
== Step 1: Set up Core_2 32bit repository ==


{{fancynote|For an alternative way to do this, see [[Installing Portage From Snapshot]].}}
In this example, we're going to use this pentium4 funtoo-current stage3 to seed a new Core_2 32bit funtoo-current build. To get that done, we need to set up the pentium4 build directory as follows:
Now it's time to install a copy of the Portage repository, which contains package scripts (ebuilds) that tell portage how to build and install thousands of different software packages. To create the Portage repository, simply run <code>emerge --sync</code> from within the chroot. This will automatically clone the portage tree from [https://github.com/funtoo/ports-2012 GitHub]:


<console>
<console>
(chroot) # ##i##emerge --sync
# ##i## cd "${METRO_MIRROR}/funtoo-current/x86-32bit"
# ##i##install -d core2_32
# ##i##cd core2_32
# ##i##install -d .control/strategy
# ##i##echo &quot;remote&quot; &gt; .control/strategy/build
# ##i##echo &quot;stage3&quot; &gt; .control/strategy/seed
# ##i##install -d .control/remote
# ##i##echo &quot;funtoo-current&quot; &gt; .control/remote/build
# ##i##echo &quot;pentium4&quot; &gt; .control/remote/subarch
</console>
</console>


{{fancyimportant|1=
The steps we follow are similar to those we performed for a ''local build'' to set up our pentium4 directory for local build. However, note the differences. We didn't download a stage, because we are going to use the pentium4 stage to build a new Core_2 32bit stage. We also didn't create the <tt>.control/version/stage{1,3}</tt> files because Metro will create them for us after it successfully builds a new stage1 and stage3. We are still using a <tt>stage3</tt> seed strategy, but we've set the build strategy to <tt>remote</tt>, which means that we're going to use a seed stage that's not from this particular subdirectory. Where are we going to get it from? The <tt>.control/remote</tt> directory contains this information, and lets Metro know that it should look for its seed stage3 in the <tt>"${METRO_MIRROR}/home/mirror/funtoo/funtoo-current/x86-32bit/pentium4"</tt> directory. Which one will it grab? You guessed it -- the most recently built ''stage3'' (since our seed strategy was set to <tt>stage3</tt>) that has the version stamp of <tt>2010-12-24</tt>, as recorded in <tt>"${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4/.control/version/stage3"</tt>. Now you can see how all those control files come together to direct Metro to do the right thing.
If you receive the error with initial <code>emerge --sync</code> due to git protocol restrictions, change <code>SYNC</code> variable in <code>/etc/make.conf</code>:
<pre>
SYNC="https://github.com/funtoo/ports-2012.git"
</pre>
}}
 
=== Configuring your system ===
As is expected from a Linux distribution, Funtoo Linux has its share of configuration files. The one file you are absolutely required to edit in order to ensure that Funtoo Linux boots successfully is <code>/etc/fstab</code>. The others are optional. Here are a list of files that you should consider editing:
{{TableStart}}
<tr class="active"><th>File</th>
<th>Do I need to change it?</th>
<th>Description</th>
</tr><tr  class="danger">
<td><code>/etc/fstab</code></td>
<td>'''YES - required'''</td>
<td>Mount points for all filesystems to be used at boot time. This file must reflect your disk partition setup. We'll guide you through modifying this file below.</td>
</tr><tr>
<td><code>/etc/localtime</code></td>
<td>''Maybe - recommended''</td>
<td>Your timezone, which will default to UTC if not set. This should be a symbolic link to something located under /usr/share/zoneinfo (e.g. /usr/share/zoneinfo/America/Montreal) </td>
</tr><tr>
<td><code>/etc/make.conf</code> (symlink) - also known as:<br/><code>/etc/portage/make.conf</code></td>
<td>''Maybe - recommended''</td>
<td>Parameters used by gcc (compiler), portage, and make. It's a good idea to set MAKEOPTS. This is covered later in this document.</td>
</tr><tr>
<td><code>/etc/conf.d/hostname</code></td>
<td>''Maybe - recommended''</td>
<td>Used to set system hostname. Set the <code>hostname</code> variable to the fully-qualified (with dots, ie. <code>foo.funtoo.org</code>) name if you have one. Otherwise, set to the local system hostname (without dots, ie. <code>foo</code>). Defaults to <code>localhost</code> if not set.</td>
</tr><tr>
<td><code>/etc/hosts</code></td>
<td>''No''</td>
<td> You no longer need to manually set the hostname in this file. This file is automatically generated by <code>/etc/init.d/hostname</code>.</td>
</tr><tr>
<td><code>/etc/conf.d/keymaps</code></td>
<td>Optional</td>
<td>Keyboard mapping configuration file (for console pseudo-terminals). Set if you have a non-US keyboard. See [[Funtoo Linux Localization]].</td>
</tr><tr>
<td><code>/etc/conf.d/hwclock</code></td>
<td>Optional</td>
<td>How the time of the battery-backed hardware clock of the system is interpreted (UTC or local time). Linux uses the battery-backed hardware clock to initialize the system clock when the system is booted.</td>
</tr><tr>
<td><code>/etc/conf.d/modules</code></td>
<td>Optional</td>
<td>Kernel modules to load automatically at system startup. Typically not required. See [[Additional Kernel Resources]] for more info.</td>
</tr><tr>
<td><code>/etc/conf.d/consolefont</code></td>
<td>Optional</td>
<td>Allows you to specify the default console font. To apply this font, enable the consolefont service by running rc-update add consolefont.</td>
</tr><tr>
<td><code>profiles</code></td>
<td>Optional</td>
<td>Some useful portage settings that may help speed up intial configuration.</td>
</tr>
{{TableEnd}}


If you're installing an English version of Funtoo Linux, you're in luck as most of the configuration files can be used as-is. If you're installing for another locale, don't worry. We will walk you through the necessary configuration steps on the [[Funtoo Linux Localization]] page, and if needed, there's always plenty of friendly, helpful support. (See [[#Community portal|Community]])
== Step 2: Building the Core_2 32bit stages ==


Let's go ahead and see what we have to do. Use <code>nano -w <name_of_file></code> to edit files -- the "<code>-w</code>" disables word-wrapping, which is handy when editing configuration files. You can copy and paste from the examples.
Now, you could start building your new Core_2 32bit stage1/2/3 (plus openvz and vserver templates) by typing the following:
 
{{fancywarning|It's important to edit your <code>/etc/fstab</code> file before you reboot! You will need to modify both the "fs" and "type" columns to match the settings for your partitions and filesystems that you created with <code>gdisk</code> or <code>fdisk</code>. Skipping this step may prevent Funtoo Linux from booting successfully.}}
 
==== /etc/fstab ====
 
<code>/etc/fstab</code> is used by the <code>mount</code> command which is ran when your system boots. Statements of this file inform <code>mount</code> about partitions to be mounted and how they are mounted. In order for the system to boot properly, you must edit <code>/etc/fstab</code> and ensure that it reflects the partition configuration you used earlier:


<console>
<console>
(chroot) # ##i##nano -w /etc/fstab
# ##i##/root/git/metro/scripts/ezbuild.sh funtoo-current core2_32
</console>
</console>


You can use arrow keys to move around and hit Control-X to exit. If you want to save your changes, type "<code>Y</code>" when asked if you want to save the modified buffer, or hit Control-O before closing <code>nano</code>. Otherwise your changes will be discarded.
In that case, the produced stages are placed in the <tt>"${METRO_MIRROR}/funtoo-current/x32-bit/core2_32/YYYY-MM-DD"</tt> subdirectory.


<pre>
== Step 3: The Next Build ==
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
#
# See the manpage fstab(5) for more information.
#
# <fs>     <mountpoint>  <type>  <opts>        <dump/pass>


/dev/sda1    /boot        ext2    noauto,noatime 1 2
At this point, you now have a new Core_2 32bit stage3. If you'd like, you can reconfigure Metro to use the most recently-built Core_2 32bit stage3 as a seed for any new Core_2 32bit builds.
/dev/sda2    none          swap    sw            0 0
/dev/sda3    /            ext4    noatime        0 1
#/dev/cdrom  /mnt/cdrom    auto    noauto,ro      0 0
</pre>


==== /etc/localtime ====
In the Metro terminology this is called a '''local build''' (a stage 3 of a a given architecture is used to seed a brand new build of the same architecture).


<code>/etc/localtime</code> is used to specify the timezone that your machine is in, and defaults to UTC. If you would like your Funtoo Linux system to use local time, you should replace <code>/etc/localtime</code> with a symbolic link to the timezone that you wish to use.
To do this, simply type:


<console>
<console>
(chroot) # ##i##ln -sf /usr/share/zoneinfo/MST7MDT /etc/localtime
# ##i##echo &quot;local&quot; &gt; /home/mirror/funtoo/funtoo-current/x86-32bit/core2_32/.control/strategy/build
</console>
</console>


The above sets the timezone to Mountain Standard Time (with daylight savings). Type <code>ls /usr/share/zoneinfo</code> to see what timezones are available. There are also sub-directories containing timezones described by location.
Now, Metro will use the most recent Core_2 32bit stage3 as a seed. The <tt>.control/remote</tt> files you created will be ignored by Metro, since it's no longer going to perform a remote build.
 
==== /etc/make.conf ====


MAKEOPTS can be used to define how many parallel compilations should occur when you compile a package, which can speed up compilation significantly. A rule of thumb is the number of CPUs (or CPU threads) in your system plus one. If for example you have a dual core processor without [[wikipedia:Hyper-threading|hyper-threading]], then you would set MAKEOPTS to 3:
= Build your own tailored stage3 =


Metro can be easily configured for building custom stage3 by including additional packages. Notice that including packages with heavy dependencies such as gnome, kde, xorg-server is not recommended (not tested so far). Well tested packages are <tt>app-misc/mc</tt>, <tt>app-misc/screen</tt>, <tt>sys-process/htop</tt>, <tt>sys-apps/dstat</tt>. An example for funtoo-current stage. Edit the following configuration file <tt>/root/git/metro/etc/builds/funtoo-current/build.conf</tt>:
<pre>
<pre>
MAKEOPTS="-j3"
[collect ../../fslayouts/funtoo/layout.conf]
</pre>
 
If you are unsure about how many processors/threads you have then use nproc to help you.
<console>
(chroot) # ##i##nproc
16
</console>
 
Set MAKEOPTS to this number plus one:
 
<pre>
MAKEOPTS="-j17"
</pre>
 
USE flags define what functionality is enabled when packages are built. It is not recommended to add a lot of them during installation; you should wait until you have a working, bootable system before changing your USE flags. A USE flag prefixed with a minus ("<code>-</code>") sign tells Portage not to use the flag when compiling.  A Funtoo guide to USE flags will be available in the future. For now, you can find out more information about USE flags in the [http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=2&chap=2 Gentoo Handbook].
 
LINGUAS tells Portage which local language to compile the system and applications in (those who use LINGUAS variable like OpenOffice). It is not usually necessary to set this if you use English. If you want another language such as French (fr) or German (de), set LINGUAS appropriately:
 
<pre>
LINGUAS="fr"
</pre>
 
==== /etc/conf.d/hwclock ====
If you dual-boot with Windows, you'll need to edit this file and change the value of '''clock''' from '''UTC''' to '''local''', because Windows will set your hardware clock to local time every time you boot Windows. Otherwise you normally wouldn't need to edit this file.
<console>
(chroot) # ##i##nano -w /etc/conf.d/hwclock
</console>
 
==== Localization ====


By default, Funtoo Linux is configured with Unicode (UTF-8) enabled, and for the US English locale and keyboard. If you would like to configure your system to use a non-English locale or keyboard, see [[Funtoo Linux Localization]].
[section local]


=== Introducing Portage ===
author: Daniel Robbins <drobbins@funtoo.org>


Portage, the Funtoo Linux package manager has a command called <code>emerge</code> which is used to build and install packages from source. It also takes care of installing all of the package's dependencies. You call emerge like this:
[section target]


<console>
build: funtoo-current
(chroot) # ##i##emerge packagename
compression: xz
</console>


When you install a package by specifying its name in the command-line, Portage records its name in the <code>/var/lib/portage/world</code> file. It does so because it assumes that, since you have installed it by name, you want to consider it part of your system and want to keep the package updated in the future. This is a handy feature, since when packages are being added to the <code>world</code> set, we can update our entire system by typing:
[section portage]


<console>
stable: ~
(chroot) # ##i##emerge --sync
MAKEOPTS: -j12
(chroot) # ##i##emerge -auDN @world
FEATURES: mini-manifest
</console>
SYNC: $[snapshot/source/remote]
USE:
profile: default/linux/$[target/arch:zap]/2008.0


This is the "official" way to update your Funtoo Linux system. Above, we first update our Portage tree using git to grab the latest ebuilds (scripts), and then run an emerge command to update the <code>world</code> set of packages. The options specified tell <code>emerge</code> to:
[section emerge]


* '''<code>a</code>''' - show us what will be emerged, and '''ask''' us if we want to proceed
options: --jobs=4 --load-average=3 --keep-going=n
* '''<code>u</code>''' - ''update'' the packages we specify -- don't emerge them again if they are already emerged.
packages: [
* '''<code>D</code>''' - Consider the entire dependency tree of packages when looking for updates. In other words, do a '''deep''' update.
dev-vcs/git
* '''<code>N</code>''' - Update any packages that have changed ('''new''') USE settings.
net-misc/dhcpcd
sys-fs/reiserfsprogs
net-misc/bridge-utils
sys-devel/bc
sys-apps/pciutils
app-portage/gentoolkit
        app-misc/mc
        app-misc/screen
        sys-process/htop
        sys-apps/dstat
           
]


You should also consider passing <code>--with-bdeps=y</code> when emerging @world, at least once in a while. This will update build dependencies as well.
[section snapshot]
 
Of course, sometimes we want to install a package but not add it to the <code>world</code> file. This is often done because you only want the package installed temproarily or because you know the package in question is a dependnecy of another package. If this behavior is desired, you call emerge like this:
 
<console>
(chroot) # ##i##emerge -1 packagename
</console>
 
Advanced users may be interested in the [[Emerge]] wiki page.
 
==== Updating World ====
 
Now is actually a very good time to update the entire system and it can be a good idea to do so prior to first boot.
 
<console>
(chroot) # ##i##emerge --sync
(chroot) # ##i##emerge -auDN @world
</console>
 
{{fancyimportant|1=
Make sure you read any post emerge messages and follow their instructions. This is especially true if you have upgraded perl or python.}}
 
=== Configuring and installing the Linux kernel ===
 
Now it's time to build and install a Linux kernel, which is the heart of any Funtoo Linux system. The kernel is loaded by the boot loader, and interfaces directly with your system's hardware, and allows regular (userspace) programs to run.
 
A kernel must be configured properly for your system's hardware, so that it supports your hard drives, file systems, network cards, and so on. More experienced Linux users can choose to install kernel sources and configure and install their own kernel. If you don't know how to do this, we provide ebuilds that will automatically build a "univeral" kernel, modules and initramfs for booting your system that supports all hardware. This is an extremely simple way of building a kernel that will get your system booted.
 
What is our goal? To build a kernel that will recognize all the hardware in your system necessary for booting, so that you will be greeted by a friendly login prompt after installation is complete. These instructions will guide you through the process of installing a kernel the "easy" way -- without requiring user configuration, by using a "universal" kernel.
 
==== Package Sets ====
 
Before we install a kernel, we're going to cover a feature of Portage called package sets. Portage, the package manager/ports system for Funtoo Linux, will keep track of system packages as well as packages you have installed by calling <code>emerge</code> directly. These packages that are part of the base system are considered part of the "system" package set, while packages that you have installed by typing them on the command line (such as "gnome" in <code>emerge gnome</code>) will be added to the "world" package set. This provides an easy way to update your entire system.
 
However, sometimes it's nice to be able to update the kernel all by itself, or leave a kernel update out of your regular whole system update. To do this, we will create a new package set called "kernel".
 
==== Kernel Package Set ====
 
To create the kernel package set, perform the following steps:
 
<console>
(chroot) # ##i##mkdir /etc/portage/sets
(chroot) # ##i##echo sys-kernel/debian-sources > /etc/portage/sets/kernel
</console>
 
Now, we'll want to set a USE variable to tell <code>debian-sources</code> to build a "universal" kernel and initramfs for us, to take the guess-work out of getting Funtoo Linux booted. To do this, we're going to set the <code>binary</code> USE variable for <code>debian-sources</code>, as follows:
 
<console>
(chroot) # ##i##echo "sys-kernel/debian-sources binary" >> /etc/portage/package.use
</console>
 
If USE variables are new to you, you'll be getting a lot more familiar with them as you use Funtoo Linux. At their essence, they are "switches" that you can set to configure options that can be built in to various packages. They're used to customize your Funtoo Linux system to meet your exact needs. We added support for a <code>binary</code> USE flag to the <code>debian-sources</code> ebuilds, as well as a few other of our kernel ebuilds, to make it easier for new users to get Funtoo Linux up and running.
 
Now, when we just want to update our system's packages, we'll type <code>emerge -auDN @world</code>, and it will update our world set, leaving out the kernel. Likewise, when we just want to update our kernel, we'll type <code>emerge -au @kernel</code>, and it will update our kernel, leaving out the world set.
 
==== Building the Kernel ====
 
{{Fancynote|1=
See [[Funtoo Linux Kernels]] for a full list of kernels supported in Funtoo Linux. We recommend <code>debian-sources</code> for new users.}}
 
{{fancyimportant|1=
<code>debian-sources</code> with <code>binary</code> USE flag requires at least 14GB free in <code>/var/tmp</code> and takes around 1 hour to build on a Intel Core i7 Processor.}}
 
Let's emerge our kernel:
 
<console>
(chroot) # ##i##emerge @kernel
</console>
 
Note that while use of the <code>binary</code> USE flag makes installing a working kernel extremely simple, it is one part of Funtoo Linux that takes a ''very'' long time to build from source, because it is building a kernel that supports ''all'' hardware that Linux supports! So, get the build started, and then let your machine compile. Slower machines can take up to several hours to build the kernel, and you'll want to make sure that you've set <code>MAKEOPTS</code> in <code>/etc/make.conf</code> to the number of processing cores/threads (plus one) in your system before starting to build it as quickly as possible -- see the [[#/etc/make.conf|/etc/make.conf section]] if you forgot to do this.
 
{{fancynote|NVIDIA card users: the <code>binary</code> USE flag installs the Nouveau drivers which cannot be loaded at the same time as the proprietary drivers, and cannot be unloaded at runtime because of KMS. You need to blacklist it under <code>/etc/modprobe.d/</code>.}}
 
{{fancynote|For an overview of other kernel options for Funtoo Linux, see [[Funtoo Linux Kernels]]. There may be modules that the Debian kernel doesn't include, a situation where [http://www.funtoo.org/wiki/Funtoo_Linux_Kernels#Using_Debian-Sources_with_Genkernel genkernel] would be useful. Also be sure to see [[:Category:Hardware Compatibility|hardware compatibility]] information.}}
 
Once <code>emerge</code> completes, you'll have a brand new kernel and initramfs installed to <code>/boot</code>, plus kernel headers installed in <code>/usr/src/linux</code>, and you'll be ready to configure the boot loader to load these to boot your Funtoo Linux system.
 
=== Installing a Bootloader ===
 
{{fancynote|An alternate boot loader called extlinux can be used instead of GRUB if you desire. See the [[Extlinux|extlinux Guide]] for information on how to do this.}}
 
==== Installing Grub ====
 
The boot loader is responsible for loading the kernel from disk when your computer boots. For new installations, GRUB 2 and Funtoo's boot-update tool should be used as a boot loader. GRUB supports both GPT/GUID and legacy MBR partitioning schemes.
 
To use this recommended boot method, first emerge <code>boot-update</code>. This will also cause <code>grub-2</code> to be merged, since it is a dependency of <code>boot-update</code>. (You may need to adjust <code>GRUB_PLATFORMS</code> if you are on a UEFI system. See [[UEFI Install Guide]]).
 
<console>
(chroot) # ##i##emerge boot-update
</console>
 
Then, edit <code>/etc/boot.conf</code> and specify "<code>Funtoo Linux genkernel</code>" as the <code>default</code> setting at the top of the file, replacing <code>"Funtoo Linux"</code>.
 
<code>/etc/boot.conf</code> should now look like this:
 
<pre>
boot {
        generate grub
        default "Funtoo Linux genkernel"
        timeout 3
}
 
"Funtoo Linux" {
        kernel bzImage[-v]
        # params += nomodeset
}
 
"Funtoo Linux genkernel" {
# if you use bliss-kernel package
# you should change string
# kernel kernel[-v]
# to
# kernel kernel/[-v]/kernel[-v]
        kernel kernel[-v]
        initrd initramfs[-v]
        params += real_root=auto
        # params += nomodeset
}
</pre>
</pre>


If you use bliss-kernel, your <code>/etc/boot.conf</code> should look like:
As you can see MAKEOPTS and emerge default options are additional strings to tweak, --keep-going=n is recommended, if something breaking during the stage building process, you can quickly diagnose the problem.


Distfiles location can be specified in <tt>/root/git/metro/etc/metro.conf</tt>
<pre>
<pre>
boot {
# Main metro configuration file
        generate grub
#  
        default "Funtoo Linux genkernel"
# Path configuration:
        timeout 3
}
 
"Funtoo Linux" {
        kernel bzImage[-v]
        # params += nomodeset
}
 
"Funtoo Linux genkernel" {
        kernel kernels/[-v]/kernel[-v]
        initrd initramfs[-v]
        params += real_root=auto
        # params += nomodeset
}
</pre>
 
Please read <code>man boot.conf</code> for further details.


===== Running grub-install and boot-update =====
[collect ../targets/$[metro/target]/$[target:zap].spec]
[collect ./builds/$[metro/build]/build.conf]
[collect ../subarch/$[target/subarch:zap].spec]


Finally, we will need to actually install the GRUB boot loader to your disk, and also run <code>boot-update</code> which will generate your boot loader configuration file:
# General Paths


<console>
[section path]
(chroot) # ##i##grub-install --no-floppy /dev/sda
tmp: /var/tmp/metro
(chroot) # ##i##boot-update
distfiles: /var/portage/distfiles
</console>
work: $[path/tmp]/work/$[metro/build]/$[target/name]


Now you need to update your boot loader configuration file:
[section path/cache]
<console>
(chroot) # ##i##boot-update
</console>
You only need to run <code>grub-install</code> when you first install Funtoo Linux, but you need to re-run <code>boot-update</code> every time you modify your <code>/etc/boot.conf</code> file, so your changes are applied on next boot.
 
=== Configuring your network ===
 
It's important to ensure that you will be able to connect to your local-area network after you reboot into Funtoo Linux. There are three approaches you can use for configuring your network: NetworkManager, dhcpcd, and the [[Funtoo Linux Networking]] scripts. Here's how to choose which one to use based on the type of network you want to set up.
 
==== Wi-Fi ====
===== Using NetworkManager =====
For laptop/mobile systems where you will be using Wi-Fi and connecting to various networks, NetworkManager is strongly recommended. The Funtoo version of NetworkManager is fully functional even from the command-line, so you can use it even without X or without the Network Manager applet. Here are the steps involved in setting up NetworkManager:
 
<console>
(chroot) # ##i##emerge linux-firmware
(chroot) # ##i##emerge networkmanager
(chroot) # ##i##rc-update add NetworkManager default
</console>
 
Above, we installed linux-firmware which contains a complete collection of available firmware for many hardware devices including Wi-Fi adapters, plus NetworkManager to manage our network connection. Then we added NetworkManager to the <code>default</code> runlevel so it will start when Funtoo Linux boots.
 
After you reboot into Funtoo Linux, you will be able to add a Wi-Fi connection this way:
 
<console>
# ##i##addwifi -S wpa -K 'wifipassword' mywifinetwork
</console>
 
The <code>addwifi</code> command is used to configure and connect to a WPA/WPA2 Wi-Fi network named <code>mywifinetwork</code> with the password <code>wifipassword</code>. This network configuration entry is stored in <code>/etc/NetworkManager/system-connections</code> so that it will be remembered in the future. You should only need to enter this command once for each Wi-Fi network you connect to.
 
===== Using wpa_supplicant =====
If for some reason you don't want to use a tool such as NetworkManager or <code>wicd</code>, you can use wpa_supplicant for wireless network connections.
 
First, emerge wpa_supplicant:
 
<console>
(chroot) ###i## emerge -a wpa_supplicant
</console>
 
Now, edit the wpa_supplicant configuration file, located at /etc/wpa_supplicant.conf.
The syntax is very easy:
<pre>
network={
ssid="MyWifiName"
psk="lol42-wifi"
}
 
network={
ssid="Other Network"
psk="6d96270004515a0486bb7f76196a72b40c55a47f"
}
</pre>
</pre>


You will need to add both <code>wpa_supplicant</code> and <code>dhcpcd</code> to the default runlevel. <code>wpa_supplicant</code> will connect to your access point, and <code>dhcpcd</code> will acquire an IP address via DHCP:
= Building Gentoo stages =
 
<console>
(chroot) # ##i##rc-update add dhcpcd default
(chroot) # ##i##rc-update add wpa_supplicant default
</console>
 
==== Desktop (Wired Ethernet) ====
 
For a home desktop or workstation with wired Ethernet that will use DHCP, the simplest and most effective option to enable network connectivity is to simply add <code>dhcpcd</code> to the default runlevel:
 
<console>
(chroot) # ##i##rc-update add dhcpcd default
</console>
 
When you reboot, <code>dhcpcd</code> will run in the background and manage all network interfaces and use DHCP to acquire network addresses from a DHCP server.
 
==== Server (Static IP) ====
 
For servers, the [[Funtoo Linux Networking]] scripts are recommended. They are optimized for static configurations and things like virtual ethernet bridging for virtualization setups. See [[Funtoo Linux Networking]] for information on how to use Funtoo Linux's template-based network configuration system.
 
=== Finishing Steps ===
 
==== Set your root password ====
It's imperative that you set your root password before rebooting so that you can log in.
<console>
(chroot) # ##i##passwd
</console>
 
===Restart your system ===
 
Now is the time to leave chroot, to unmount Funtoo Linux partitions and files and to restart your computer. When you restart, the GRUB boot loader will start, load the Linux kernel and initramfs, and your system will begin booting.
 
Leave the chroot, change directory to /mnt, unmount your Funtoo partitions, and reboot.
<console>
(chroot) # ##i##exit
# ##i##cd /mnt
# ##i##umount -l funtoo
# ##i##reboot
</console>
 
{{fancynote|System Rescue CD will gracefully unmount your new Funtoo filesystems as part of its normal shutdown sequence.}}
 
You should now see your system reboot, the GRUB boot loader appear for a few seconds, and then see the Linux kernel and initramfs loading. After this, you should see Funtoo Linux itself start to boot, and you should be greeted with a <code>login:</code> prompt. Funtoo Linux has been successfully installed!
=== Profiles ===
 
Once you have rebooted into Funtoo Linux, you can further customize your system to your needs by using Funtoo Profiles.
 
[[Funtoo 1.0 Profile|Funtoo profiles]] are used to define defaults for Portage specific to your needs. There are 4 basic profile types: arch, build, [[Flavors and Mix-ins|flavor, and mix-ins]]:
 
;arch: typically <code>x86-32bit</code> or <code>x86-64bit</code>, this defines the processor type and support of your system. This is defined when your stage was built and should not be changed.
;build: defines whether your system is a <code>current</code>, <code>stable</code> or <code>experimental</code> build. <code>current</code> systems will have newer packages unmasked than <code>stable</code> systems.
;flavor: defines the general type of system, such as <code>server</code> or <code>desktop</code>, and will set default USE flags appropriate for your needs.
;mix-ins: define various optional settings that you may be interested in enabling.
 
One arch, build and flavor must be set for each Funtoo Linux system, while mix-ins are optional and you can enable more than one if desired.
 
Remember that profiles can often be inherited. For example, the <code>desktop</code> flavor inherits the <code>workstation</code> flavor settings, which in turn inherits the <code>X</code> and <code>audio</code> mix-ins. You can view this by using eselect:
 
<console>
(chroot) # ##i##eselect profile show
Currently set profiles:
    arch: gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
  build: gentoo:funtoo/1.0/linux-gnu/build/current
  flavor: gentoo:funtoo/1.0/linux-gnu/flavor/desktop
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/kde
 
Automatically enabled profiles:
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/print
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/X
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/audio
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/dvd
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/media
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/console-extras
</console>
 
To view installed profiles:
<console>
(chroot) # ##i##eselect profile list
</console>
 
To change the profile flavor:
<console>
(chroot) # ##i##eselect profile set-flavor 7
</console>
 
To add a mix-in:
 
<console>
(chroot) # ##i##eselect profile add 10
</console>
 
===Next Steps===
 
If you are brand new to Funtoo Linux and Gentoo Linux, please check out [[Funtoo Linux First Steps]], which will help get you acquainted with your new system. We also have a category for our [[:Category:Official Documentation|official documentation]], which includes all docs that we officially maintain for installation and operation of Funtoo Linux.
 
We also have a number of pages dedicated to setting up your system, which you can find below. If you are interested in adding a page to this list, add it to the "First Steps" MediaWiki category.
 
{{#ask: [[Category:First Steps]] | format=ul }}
 
If your system did not boot correctly, see [[Installation Troubleshooting]] for steps you can take to resolve the problem.


[[Category:HOWTO]]
[[Category:HOWTO]]
[[Category:Install]]
[[Category:Metro]]
[[Category:Official Documentation]]
</div><div class="col-md-3 col-hidden-sm col-hidden-xs"><div id="tocwrap" >
__TOC__
</div></div></div>

Revision as of 16:22, October 30, 2014

Metro is the build system for Funtoo Linux and Gentoo Linux stages. It automates the bootstrapping process.

This tutorial will take you through installing, setting up and running Metro.

Preface

How Metro Works

You may be wondering how Metro creates its first stage tarball. As you may have guessed, Metro cannot create a stage tarball out of thin air. To build a new stage tarball, Metro must use an existing, older stage tarball called a "seed" stage. This "seed" stage typically is used as the build environment for creating the stage we want.

Metro can use two kinds of seed stages. Traditionally, Metro has used a stage3 as a seed stage. This stage3 is then used to build a new stage1, which in turn is used to build a new stage2, and then a new stage3. This is generally the most reliable way to build Gentoo Linux or Funtoo Linux, so it's the recommended approach.

   Important

After switching metro builds to Funtoo profile, Gentoo stages are no longer provided!

Seeds and Build Isolation

Another important concept to mention here is something called build isolation. Because Metro creates an isolated build environment, and the build environment is explicitly defined using existing, tangible entities -- a seed stage and a portage snapshot -- you will get consistent, repeatable results. In other words, the same seed stage, portage snapshot and build instructions will generate an essentially identical result, even if you perform the build a month later on someone else's workstation.

Local Build

Say you wanted to build a new pentium4 stage3 tarball. The recommended method of doing this would be to grab an existing pentium4 stage3 tarball to use as your seed stage. Metro will be told to use this existing pentium4 stage3 to build a new stage1 for the same pentium4. For this process, the generic pentium4 stage3 would provide the build environment for creating our new stage1. Then, the new stage1 would serve as the build environment for creating the new pentium4 stage2. And the new pentium4 stage2 would serve as the build environment for creating the new pentium4 stage3.

In the Metro terminology this is called a local build, which means a stage3 of a given architecture is used to seed a brand new build of the same architecture. Incidentally this will be the first exercise we are going to perform in this tutorial.

A week later, you may want to build a brand new pentium4 stage3 tarball. Rather than starting from the original pentium4 stage3 again, you'd probably configure Metro to use the most-recently-built pentium4 stage3 as the seed. Metro has built-in functionality to make this easy, allowing it to easily find and track the most recent stage3 seed available.

Remote Build

Metro can also perform remote build, where a stage3 of a different, but binary compatible, architecture is used as a seed to build a different architecture stage3. Consequentiality the second exercise we are going to perform in this tutorial will be to build a core2 32bit stage3 tarball from the pentium4 stage3 tarball we have just built.

TODO: add caveats about what archs can be seeded and what can be not (maybe a table?)

Tailored Build

Last, it's also worthy noting that both in local and remote builds, Metro can be configured to add and/or remove individual packages to the final tarball. Let's say you can't live without app-misc/screen, at the end of this tutorial, we will show how to have your tailored stage3 to include it.

Installing Metro

The recommended and supported method is to use the Git repository of Metro. First, ensure you remove the No results package if you had installed it:

root # emerge -aC dev-util/metro

Then ensure that dev-vcs/git and No results are installed on your system:

root # emerge dev-vcs/git
root # emerge dev-python/boto

Next, clone the master git repository as follows:

root # install -d /root/git
root # cd /root/git
root # git clone git://github.com/funtoo/metro.git
root # ln -s /root/git/metro /usr/lib/metro
root # ln -s /root/git/metro/metro /usr/bin/metro

You will now have a directory called /root/git/metro that contains all the Metro source code. Installation complete!

Configuring Metro

Daniel Robbins maintains Metro, so it comes pre-configured to successfully build both Gentoo Linux and Funtoo Linux releases. Before reading farther, you might want to customize some basic settings like the number of concurrent jobs to fit your hardware's capabilities or the directory to use for produced stage archives. This is accomplished by editing /root/git/metro/etc/metro.conf which is the Metro's master configuration file. The [path/mirror] section defines where Metro will look for things it needs and also dump things it creates. As initially configured, Metro is set up to build Funtoo Linux and Gentoo Linux stage tarballs and place them in the /home/mirror/funtoo directory:

# Mirror Paths - where to find required files and where to put created files

[section path/mirror]

: /home/mirror/funtoo

If you want to change the location of your mirror on disk, then edit the /home/mirror/funtoo line (which defines the path/mirror variable) to point to another directory.

For the purpose of the following steps, set an environment variable:

root # export METRO_MIRROR=/home/mirror/funtoo

Of course, set the environment variable to whatever location you used in the configuration file.

Arch and Subarch

In the following example we are creating a pentium4 stage 3 compiled for x86-32bit binary compatibility. Pentium4 is a subarch of the x86-32bit architecture. Once you have metro installed you may find a full list of each subarch in your /usr/lib/metro/subarch directory each subarch will have the file extension .spec Example:

root # ls /usr/lib/metro/subarch/
amd64-k10.spec         athlon-tbird.spec  generic_32.spec       native_32.spec   pentium-mmx.spec
amd64-k8_32.spec       athlon-xp.spec     generic_64.spec       native_64.spec   pentium-m.spec
amd64-k8.spec          atom_32.spec       generic_sparcv9.spec  niagara2.spec    pentiumpro.spec
amd64-k8+sse3_32.spec  atom_64.spec       geode.spec            niagara.spec     pentium.spec
amd64-k8+sse3.spec     btver1_64.spec     i486.spec             nocona.spec      prescott.spec
armv7a.spec            btver1.spec        i686.spec             opteron_64.spec  ultrasparc3.spec
athlon-4.spec          core2_32.spec      k6-2.spec             pentium2.spec    ultrasparc.spec
athlon-mp.spec         core2_64.spec      k6-3.spec             pentium3.spec    xen-pentium4+sse3_64.spec
athlon.spec            corei7.spec        k6.spec               pentium4.spec    xen-pentium4+sse3.spec
   Note

For an example list of Architectures, take a look at the directory listing on the Funtoo-Current Mirror.

First stages build (local build)

To get this all started, we need to bootstrap the process by downloading an initial seed stage3 to use for building and place it in its proper location in /home/mirror/funtoo, so that Metro can find it. We will also need to create some special "control" files in /home/mirror/funtoo, which will allow Metro to understand how it is supposed to proceed.

Step 0: Optional Quick Copy of Portage Tree

There is a quick step you can perform to avoid having Metro re-clone the entire Portage tree. Perform this as root:

root # install -d /var/tmp/metro/cache/cloned-repositories
root # cat /root/git/metro/etc/builds/funtoo-current/build.conf  | grep name
root # name: ports-2012
root # cp -a /usr/portage /var/tmp/metro/cache/cloned-repositories/ports-2012
root # cd /usr/portage; git checkout funtoo.org

Step 1: Set up pentium4 repository (local build)

Assuming we're following the basic steps outlined in the previous section, and building an unstable funtoo (funtoo-current) build for the pentium4, using a generic pentium4 stage3 as a seed stage, then here the first set of steps we'd perform:

root # install -d "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"
root # cd "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4"
root # install -d 2011-12-13
root # cd 2011-12-13
root # wget -c http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-32bit/pentium4/2011-12-13/stage3-pentium4-funtoo-current-2011-12-13.tar.xz
root # cd ..
root # install -d .control/version
root # echo "2011-12-13" > .control/version/stage3
root # install -d .control/strategy
root # echo "local" > .control/strategy/build
root # echo "stage3" > .control/strategy/seed

OK, let's review the steps above. First, we create the directory "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4", which is where Metro will expect to find unstable funtoo-current pentium4 builds -- it is configured to look here by default. Then we create a specially-named directory to house our seed x86 stage3. Again, by default, Metro expects the directory to be named this way. We enter this directory, and download our seed x86 stage3 from funtoo.org. Note that the 2010-12-24 version stamp matches. Make sure that your directory name matches the stage3 name too. Everything has been set up to match Metro's default filesystem layout.

Next, we go back to the "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4" directory, and inside it, we create a .control directory. This directory and its subdirectories contain special files that Metro references to determine certain aspects of its behavior. The .control/version/stage3 file is used by Metro to track the most recently-built stage3 for this particular build and subarch. Metro will automatically update this file with a new version stamp after it successfully builds a new stage3. But because Metro didn't actually build this stage3, we need to set up the .control/version/stage3 file manually. This will allow Metro to find our downloaded stage3 when we set up our pentium4 build to use it as a seed. Also note that Metro will create a similar .control/version/stage1 file after it successfully builds an pentium4 funtoo-current stage1.

We also set up .control/strategy/build and .control/strategy/seed files with values of local and stage3 respectively. These files define the building strategy Metro will use when we build pentium4 funtoo-current stages. With a build strategy of local, Metro will source its seed stage from funtoo-current pentium4, the current directory. And with a seed strategy of stage3, Metro will use a stage3 as a seed, and use this seed to build a new stage1, stage2 and stage3.

Step 2: Building the pentium4 stages

Incidentally, if all you wanted to do at this point was to build a new pentium4 funtoo-current stage1/2/3 (plus openvz and vserver templates). You would begin the process by typing:

root # cd /root/git/metro
root # scripts/ezbuild.sh funtoo-current pentium4

If you have a slow machine, it could take several hours to be completed because several "heavy" components like gcc or glibc have to be recompiled in each stage. Once a stage has been successfully completed, it is placed in the "${METRO_MIRROR}/funtoo-current/x32-bit/pentium4/YYYY-MM-DD" subdirectory, where YYYY-MM-DD is today's date at the time the ezbuild.sh script was started or the date you put on the ezscript.sh command line.

Step 3: The next build

At this point, you now have a new pentium4 stage3. If you'd like, you can reconfigure Metro to use the most recently-built pentium4 stage3 as a seed for any pentium4 builds. To do this, simply type:

 # echo "local" > /home/mirror/funtoo/funtoo-current/x86-32bit/pentium4/.control/strategy/build

Now, Metro will use the most recentpentium4 stage3 as a seed. The .control/remote files you created will be ignored by Metro, since it's no longer going to perform a remote build.

Building for another binary compatible architecture (remote build)

As written above, Metro is able to perform remote build building different architecture stage3 from a binary compatible seeding stage3 (e.g. using a pentium4 stage3 to seed a Intel Core2 32bits stage3).

In the Metro terminology this is called a remote build (a stage 3 of a different, but binary compatible, architecture is used as a seed). What's not compatible? You can't use a Sparc architecture to generate an x86 or ARM based stage and vice-versa. If you use a 32bit stage then you don't want to seed a 64bit build from it. Be sure that you are using a stage from the same architecture that you are trying to seed. Check Funtoo-current FTP Mirror for a stage that is from the same Architecture that you will be building.

Step 1: Set up Core_2 32bit repository

In this example, we're going to use this pentium4 funtoo-current stage3 to seed a new Core_2 32bit funtoo-current build. To get that done, we need to set up the pentium4 build directory as follows:

root #  cd "${METRO_MIRROR}/funtoo-current/x86-32bit"
root # install -d core2_32
root # cd core2_32
root # install -d .control/strategy
root # echo "remote" > .control/strategy/build
root # echo "stage3" > .control/strategy/seed
root # install -d .control/remote
root # echo "funtoo-current" > .control/remote/build
root # echo "pentium4" > .control/remote/subarch

The steps we follow are similar to those we performed for a local build to set up our pentium4 directory for local build. However, note the differences. We didn't download a stage, because we are going to use the pentium4 stage to build a new Core_2 32bit stage. We also didn't create the .control/version/stage{1,3} files because Metro will create them for us after it successfully builds a new stage1 and stage3. We are still using a stage3 seed strategy, but we've set the build strategy to remote, which means that we're going to use a seed stage that's not from this particular subdirectory. Where are we going to get it from? The .control/remote directory contains this information, and lets Metro know that it should look for its seed stage3 in the "${METRO_MIRROR}/home/mirror/funtoo/funtoo-current/x86-32bit/pentium4" directory. Which one will it grab? You guessed it -- the most recently built stage3 (since our seed strategy was set to stage3) that has the version stamp of 2010-12-24, as recorded in "${METRO_MIRROR}/funtoo-current/x86-32bit/pentium4/.control/version/stage3". Now you can see how all those control files come together to direct Metro to do the right thing.

Step 2: Building the Core_2 32bit stages

Now, you could start building your new Core_2 32bit stage1/2/3 (plus openvz and vserver templates) by typing the following:

root # /root/git/metro/scripts/ezbuild.sh funtoo-current core2_32

In that case, the produced stages are placed in the "${METRO_MIRROR}/funtoo-current/x32-bit/core2_32/YYYY-MM-DD" subdirectory.

Step 3: The Next Build

At this point, you now have a new Core_2 32bit stage3. If you'd like, you can reconfigure Metro to use the most recently-built Core_2 32bit stage3 as a seed for any new Core_2 32bit builds.

In the Metro terminology this is called a local build (a stage 3 of a a given architecture is used to seed a brand new build of the same architecture).

To do this, simply type:

root # echo "local" > /home/mirror/funtoo/funtoo-current/x86-32bit/core2_32/.control/strategy/build

Now, Metro will use the most recent Core_2 32bit stage3 as a seed. The .control/remote files you created will be ignored by Metro, since it's no longer going to perform a remote build.

Build your own tailored stage3

Metro can be easily configured for building custom stage3 by including additional packages. Notice that including packages with heavy dependencies such as gnome, kde, xorg-server is not recommended (not tested so far). Well tested packages are app-misc/mc, app-misc/screen, sys-process/htop, sys-apps/dstat. An example for funtoo-current stage. Edit the following configuration file /root/git/metro/etc/builds/funtoo-current/build.conf:

[collect ../../fslayouts/funtoo/layout.conf]

[section local]

author: Daniel Robbins <drobbins@funtoo.org>

[section target]

build: funtoo-current
compression: xz

[section portage]

stable: ~
MAKEOPTS: -j12
FEATURES: mini-manifest
SYNC: $[snapshot/source/remote]
USE:
profile: default/linux/$[target/arch:zap]/2008.0

[section emerge]

options: --jobs=4 --load-average=3 --keep-going=n
packages: [
	dev-vcs/git 
	net-misc/dhcpcd
	sys-fs/reiserfsprogs
	net-misc/bridge-utils
	sys-devel/bc
	sys-apps/pciutils
	app-portage/gentoolkit
        app-misc/mc
        app-misc/screen
        sys-process/htop
        sys-apps/dstat 
            
]

[section snapshot]

As you can see MAKEOPTS and emerge default options are additional strings to tweak, --keep-going=n is recommended, if something breaking during the stage building process, you can quickly diagnose the problem.

Distfiles location can be specified in /root/git/metro/etc/metro.conf

# Main metro configuration file
# 
# Path configuration:

[collect ../targets/$[metro/target]/$[target:zap].spec]
[collect ./builds/$[metro/build]/build.conf]
[collect ../subarch/$[target/subarch:zap].spec]

# General Paths

[section path]
tmp: /var/tmp/metro
distfiles: /var/portage/distfiles
work: $[path/tmp]/work/$[metro/build]/$[target/name]

[section path/cache]

Building Gentoo stages