Difference between pages "Funtoo Linux Installation" and "ZFS Install Guide"

(Difference between pages)
(Partitioning Recommendations)
 
(Create the zpool)
 
Line 1: Line 1:
== Introduction ==  
+
== 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 show you how to install Funtoo on ZFS (rootfs). This tutorial is meant to be an "overlay" over the [[Funtoo_Linux_Installation|Regular Funtoo Installation]]. Follow the normal installation and only use this guide for steps 2, 3, and 8.
  
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.
+
=== Introduction to ZFS ===
  
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]].
+
Since ZFS is a new technology for Linux, it can be helpful to understand some of its benefits, particularly in comparison to BTRFS, another popular next-generation Linux filesystem:
  
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.
+
* On Linux, the ZFS code can be updated independently of the kernel to obtain the latest fixes. btrfs is exclusive to Linux and you need to build the latest kernel sources to get the latest fixes.
  
== Installation Overview ==
+
* ZFS is supported on multiple platforms. The platforms with the best support are Solaris, FreeBSD and Linux. Other platforms with varying degrees of support are NetBSD, Mac OS X and Windows. btrfs is exclusive to Linux.
  
This is a basic overview of the Funtoo installation process:
+
* ZFS has the Adaptive Replacement Cache replacement algorithm while btrfs uses the Linux kernel's Last Recently Used replacement algorithm. The former often has an overwhelmingly superior hit rate, which means fewer disk accesses.
  
# [[#Live CD|Download and boot the live CD of your choice]].
+
* ZFS has the ZFS Intent Log and SLOG devices, which accelerates small synchronous write performance.
# [[#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 ===
+
* ZFS handles internal fragmentation gracefully, such that you can fill it until 100%. Internal fragmentation in btrfs can make btrfs think it is full at 10%. Btrfs has no automatic rebalancing code, so it requires a manual rebalance to correct it.
  
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.
+
* ZFS has raidz, which is like RAID 5/6 (or a hypothetical RAID 7 that supports 3 parity disks), except it does not suffer from the RAID write hole issue thanks to its use of CoW and a variable stripe size. btrfs gained integrated RAID 5/6 functionality in Linux 3.9. However, its implementation uses a stripe cache that can only partially mitigate the effect of the RAID write hole.
  
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.
+
* ZFS send/receive implementation supports incremental update when doing backups. btrfs' send/receive implementation requires sending the entire snapshot.
  
To begin a Funtoo Linux installation, download System Rescue CD from:
+
* ZFS supports data deduplication, which is a memory hog and only works well for specialized workloads. btrfs has no equivalent.
  
{{MirrorList}}
+
* ZFS datasets have a hierarchical namespace while btrfs subvolumes have a flat namespace.
  
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 <tt>rescue64</tt> 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.
+
* ZFS has the ability to create virtual block devices called zvols in its namespace. btrfs has no equivalent and must rely on the loop device for this functionality, which is cumbersome.
  
=== Prepare Hard Disk ===
+
The only area where btrfs is ahead of ZFS is in the area of small file
==== Partitions ====
+
efficiency. btrfs supports a feature called block suballocation, which
 +
enables it to store small files far more efficiently than ZFS. It is
 +
possible to use another filesystem (e.g. reiserfs) on top of a ZFS zvol
 +
to obtain similar benefits (with arguably better data integrity) when
 +
dealing with many small files (e.g. the portage tree).
  
Funtoo Linux fully supports traditional MBR partitions, as well as newer GPT/GUID partition formats. See below to determine which partitioning scheme to use:
+
For a quick tour of ZFS and have a big picture of its common operations you can consult the page [[ZFS Fun]].
  
===== MBR Partitions =====
+
=== Disclaimers ===
  
* '''Recommended if your system disk is <=2TB in size'''
+
{{fancywarning|This guide is a work in progress. Expect some quirks.}}
* Legacy, DOS partitioning scheme
+
{{fancyimportant|'''Since ZFS was really designed for 64 bit systems, we are only recommending and supporting 64 bit platforms and installations. We will not be supporting 32 bit platforms'''!}}
* 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.}}
+
== Video Tutorial ==
  
===== GPT Partitions =====
+
As a companion to the installation instructions below, a YouTube video tutorial is now available:
  
* '''Recommended if your disk is >2TB in size'''
+
{{#widget:YouTube|id=SWyThdxNoP8|width=640|height=360}}
* 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.}}
+
== Downloading the ISO (With ZFS) ==
 +
In order for us to install Funtoo on ZFS, you will need an environment that already provides the ZFS tools. Therefore we will download a customized version of System Rescue CD with ZFS included.  
  
===== Filesystem Resources =====
+
<pre>
 +
Name: sysresccd-4.0.1_zfs_0.6.2.iso  (545 MB)
 +
Release Date: 2014-02-25
 +
md5sum 01f4e6929247d54db77ab7be4d156d85
 +
</pre>
  
Advanced users may be interested in the following topics:
 
  
* [[GUID Booting Guide]]
+
'''[http://ftp.osuosl.org/pub/funtoo/distfiles/sysresccd/ Download System Rescue CD with ZFS]'''<br />
* [[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 =====
+
== Creating a bootable USB from ISO (From a Linux Environment) ==
 +
After you download the iso, you can do the following steps to create a bootable USB:
  
Below are our partitioning recommendations in table form. For MBR-based partitions, use the MBR Block Device and MBR code columns with <tt>fdisk</tt>. For GPT-based partitions, use the GPT Block Device and GPT Code columns with <tt>gdisk</tt>:
+
<console>
 +
Make a temporary directory
 +
# ##i##mkdir /tmp/loop
  
{{TableStart}}
+
Mount the iso
<tr class="active"><th>Partition</th>
+
# ##i##mount -o ro,loop /root/sysresccd-4.0.1_zfs_0.6.2.iso /tmp/loop
<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><tt>/boot</tt></td>
+
<td>128 MB for MBR, 512 MB for GPT</td>
+
<td><tt>/dev/sda1</tt></td>
+
<td><tt>/dev/sda1</tt></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><tt>/dev/sda2</tt></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><tt>/dev/sda2</tt></td>
+
<td><tt>/dev/sda3</tt></td>
+
<td>swap (default)</td>
+
<td>82</td>
+
<td>8200</td>
+
</tr><tr>
+
<td><tt>/</tt> (root)</td>
+
<td>Rest of the disk, minimum of 10GB.</td>
+
<td><tt>/dev/sda3</tt></td>
+
<td><tt>/dev/sda4</tt></td>
+
<td>XFS recommended, alternatively ext4</td>
+
<td>83</td>
+
<td>8300</td>
+
</tr><tr>
+
<td><tt>/home</tt> (optional) </td>
+
<td>User storage and media. Typically most of the disk.</td>
+
<td><tt>/dev/sda4</tt> (if created)</td>
+
<td><tt>/dev/sda5</tt> (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><tt>/dev/sda4</tt> (PV, if created)</td>
+
<td><tt>/dev/sda5</tt> (PV, if created)</td>
+
<td>LVM PV</td>
+
<td>8E</td>
+
<td>8E00</td>
+
</tr>{{TableEnd}}
+
  
===== Partitioning Using fdisk (MBR) =====
+
Run the usb installer
 +
# ##i##/tmp/loop/usb_inst.sh
 +
</console>
  
{{fancyimportant|If you need to create a GPT partition table, see [[Partitioning using gdisk]].}}
+
That should be all you need to do to get your flash drive working.
  
{{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.}}
+
== Booting the ISO ==
  
<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.
+
{{fancywarning|'''When booting into the ISO, Make sure that you select the "Alternate 64 bit kernel (altker64)". The ZFS modules have been built specifically for this kernel rather than the standard kernel. If you select a different kernel, you will get a fail to load module stack error message.'''}}
  
====== Preparation ======
+
== Creating partitions ==
 +
There are two ways to partition your disk: You can use your entire drive and let ZFS automatically partition it for you, or you can do it manually.
  
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:
+
We will be showing you how to partition it '''manually''' because if you partition it manually you get to create your own layout, you get to have your own separate /boot partition (Which is nice since not every bootloader supports booting from ZFS pools), and you get to boot into RAID10, RAID5 (RAIDZ) pools and any other layouts due to you having a separate /boot partition.
  
<console>
+
==== gdisk (GPT Style) ====
# ##i##fdisk -l /dev/sda
+
  
Disk /dev/sda: 640.1 GB, 640135028736 bytes, 1250263728 sectors
+
'''A Fresh Start''':
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
+
  
 
+
First lets make sure that the disk is completely wiped from any previous disk labels and partitions.
#        Start          End    Size  Type            Name
+
We will also assume that <tt>/dev/sda</tt> is the target drive.<br />
1        2048  1250263694  596.2G  Linux filesyste Linux filesystem
+
</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>:
+
{{fancywarning|This will make your current partitions inaccessable! You are '''strongly''' cautioned and advised to backup any critical data before proceeding. In case of need, you can try recovering your partition table using <code>testdisk</code>.}}
+
  
 
<console>
 
<console>
# ##i##sgdisk --zap-all /dev/sda
+
# ##i##sgdisk -Z /dev/sda
 
+
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:
+
{{fancywarning|This is a destructive operation and the program will not ask you for confirmation! Make sure you really don't want anything on this disk.}}
  
<console>
+
Now that we have a clean drive, we will create the new layout.
***************************************************************
+
Found invalid GPT and valid MBR; converting MBR to GPT format
+
in memory.  
+
***************************************************************
+
</console>
+
 
+
====== Partitioning ======
+
  
Now we will use <code>fdisk</code> to create the MBR partition table and partitions:
+
First open up the application:
  
 
<console>
 
<console>
# ##i##fdisk /dev/sda
+
# ##i##gdisk /dev/sda
</console>
+
 
+
Within <code>fdisk</code>, follow these steps:
+
 
+
'''Empty the partition table''':
+
 
+
<console>
+
Command (m for help): ##i##o ↵
+
 
</console>
 
</console>
  
 
'''Create Partition 1''' (boot):
 
'''Create Partition 1''' (boot):
 
 
<console>
 
<console>
Command (m for help): ##i##n ↵
+
Command: ##i##n ↵
Partition type (default p): ##i##↵
+
Partition Number: ##i##↵
Partition number (1-4, default 1): ##i##↵
+
 
First sector: ##i##↵
 
First sector: ##i##↵
Last sector: ##i##+128M
+
Last sector: ##i##+250M ↵
 +
Hex Code: ##i##
 
</console>
 
</console>
  
'''Create Partition 2''' (swap):
+
'''Create Partition 2''' (BIOS Boot Partition):
 
+
<console>Command: ##i##n ↵
<console>
+
Partition Number: ##i##↵
Command (m for help): ##i##n ↵
+
Partition type (default p): ##i##↵
+
Partition number (2-4, default 2): ##i##↵
+
 
First sector: ##i##↵
 
First sector: ##i##↵
Last sector: ##i##+2G ↵
+
Last sector: ##i##+32M
Command (m for help): ##i##t ↵
+
Hex Code: ##i##EF02
Partition number (1,2, default 2): ##i##
+
Hex code (type L to list all codes): ##i##82
+
 
</console>
 
</console>
  
'''Create the root partition:'''
+
'''Create Partition 3''' (ZFS):
 
+
<console>Command: ##i##n ↵
<console>
+
Partition Number: ##i##↵
Command (m for help): ##i##n ↵
+
Partition type (default p): ##i##↵
+
Partition number (3,4, default 3): ##i##↵
+
 
First sector: ##i##↵
 
First sector: ##i##↵
 
Last sector: ##i##↵
 
Last sector: ##i##↵
</console>
+
Hex Code: ##i##bf00 ↵
  
'''Verify the partition table:'''
+
Command: ##i##p ↵
  
<console>
+
Number  Start (sector)   End (sector) Size      Code  Name
Command (m for help): ##i##p
+
  1            2048          514047  250.0 MiB  8300  Linux filesystem
 
+
  2          514048          579583  32.0 MiB    EF02  BIOS boot partition
Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
+
  3          579584      1953525134  931.2 GiB  BF00  Solaris root
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
+
Command: ##i##w ↵
/dev/sda1          2048    264191    131072  83 Linux
+
/dev/sda2        264192  4458495  2097152  82 Linux swap / Solaris
+
/dev/sda3        4458496 625142447 310341976  83 Linux
+
 
</console>
 
</console>
  
'''Write the parition table to disk:'''
+
 
 +
=== Format your /boot partition ===
  
 
<console>
 
<console>
Command (m for help): ##i##w
+
# ##i##mkfs.ext2 -m 1 /dev/sda1
 
</console>
 
</console>
  
Your new MBR partition table will now be written to your system disk.
+
=== Encryption (Optional) ===
 +
If you want encryption, then create your encrypted vault(s) now by doing the following:
  
==== Creating filesystems ====
+
<console>
 +
# ##i##cryptsetup luksFormat /dev/sda3
 +
# ##i##cryptsetup luksOpen /dev/sda3 vault_1
 +
</console>
  
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.
+
{{fancywarning|On some machines, a combination of ZFS and LUKS has caused instability and system crashes.}}
  
You will not create a filesystem on your swap partition, but will initialize it using the <tt>mkswap</tt> command so that it can be used as disk-based virtual memory. Then we'll run the <tt>swapon</tt> 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.
+
=== Create the zpool ===
 +
We will first create the pool. The pool will be named `tank` and the disk will be aligned to 4096 (using ashift=12)
 +
<console># ##i##zpool create -f -o ashift=12 -o cachefile= -O compression=on -m none -R /mnt/funtoo tank /dev/sda3</console>
  
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.
+
{{fancyimportant|If you are using encrypted root, change '''/dev/sda3 to /dev/mapper/vault_1'''.}}
  
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 <tt>/dev/sda3</tt> instead and you will need to adjust the target block devices. If you are following our recommendations, then simply do this:
+
{{fancynote|1=
 +
If you have a previous pool that you would like to import, you can do a: <code>zpool import -f -R /mnt/funtoo pool_name</code>.}}
  
'''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 <tt>/etc/fstab</tt> file reflects this.
+
=== Create the zfs datasets ===
 
+
We will now create some datasets. For this installation, we will create a small but future proof amount of datasets. We will have a dataset for the OS (/), and your swap. We will also show you how to create some optional datasets: <tt>/home</tt>, <tt>/var</tt>, <tt>/usr/src</tt>, and <tt>/usr/portage</tt>.
{{fancywarning|1=
+
When deploying an OpenVZ host, please use ext4 exclusively. The Parallels development team tests extensively with ext4, and modern versions of <tt>openvz-rhel6-stable</tt> are '''not''' compatible with XFS, and you may experience kernel bugs.
+
}}
+
 
+
'''To use ext4 as your root filesystem:'''
+
  
 
<console>
 
<console>
# ##i##mke2fs -t ext2 /dev/sda1
+
Create some empty containers for organization purposes, and make the dataset that will hold /
# ##i##mkfs.ext4 /dev/sda3
+
# ##i##zfs create -p tank/funtoo
# ##i##mkswap /dev/sda2
+
# ##i##zfs create -o mountpoint=/ tank/funtoo/root
# ##i##swapon /dev/sda2
+
</console>
+
  
'''To use XFS as your root filesystem:'''
+
Optional, but recommended datasets: /home
 +
# ##i##zfs create -o mountpoint=/home tank/funtoo/home
  
<console>
+
Optional datasets: /usr/src, /usr/portage/{distfiles,packages}
# ##i##mke2fs -t ext2 /dev/sda1
+
# ##i##zfs create -o mountpoint=/usr/src tank/funtoo/src
# ##i##mkfs.xfs /dev/sda3
+
# ##i##zfs create -o mountpoint=/usr/portage -o compression=off tank/funtoo/portage
# ##i##mkswap /dev/sda2
+
# ##i##zfs create -o mountpoint=/usr/portage/distfiles tank/funtoo/portage/distfiles
# ##i##swapon /dev/sda2
+
# ##i##zfs create -o mountpoint=/usr/portage/packages tank/funtoo/portage/packages
 
</console>
 
</console>
  
==== Mounting filesystems ====
+
=== Create your swap zvol ===
 +
For modern machines that have greater than 4 GB of RAM, A swap size of 2G should be enough. However if your machine doesn't have a lot of RAM, the rule of thumb is either 2x the RAM or RAM + 1 GB.
  
Mount the newly-created filesystems as follows, creating <tt>/mnt/funtoo</tt> as the installation mount point:
+
For this tutorial we will assume that it is a newer machine and make a 2 GB swap.
  
 
<console>
 
<console>
# ##i##mkdir /mnt/funtoo
+
# ##i##zfs create -o sync=always -o primarycache=metadata -o secondarycache=none -o volblocksize=4K -V 2G tank/swap
# ##i##mount /dev/sda3 /mnt/funtoo
+
# ##i##mkdir /mnt/funtoo/boot
+
# ##i##mount /dev/sda1 /mnt/funtoo/boot
+
 
</console>
 
</console>
  
Optionally, if you have a separate filesystem for <tt>/home</tt> or anything else:
+
=== Format your swap zvol ===
 
+
 
<console>
 
<console>
# ##i##mkdir /mnt/funtoo/home
+
# ##i##mkswap -f /dev/zvol/tank/swap
# ##i##mount /dev/sda4 /mnt/funtoo/home
+
# ##i##swapon /dev/zvol/tank/swap
 
</console>
 
</console>
  
If you have <tt>/tmp</tt> or <tt>/var/tmp</tt> on a separate filesystem, be sure to change the permissions of the mount point to be globally-writeable after mounting, as follows:
+
Now we will continue to install funtoo.
  
<console>
+
== Installing Funtoo ==
# ##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>x86-64bit</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 <tt>date</tt> command to verify the date and time:
+
=== Pre-Chroot ===
  
 
<console>
 
<console>
# ##i##date
+
Go into the directory that you will chroot into
Fri Jul 15 19:47:18 UTC 2011
+
# ##i##cd /mnt/funtoo
</console>
+
  
If the date and/or time need to be corrected, do so using <tt>date MMDDhhmmYYYY</tt>, keeping in mind <tt>hhmm</tt> are in 24-hour format. The example below changes the date and time to "July 16th, 2011 @ 8:00PM" UTC:
+
Make a boot folder and mount your boot drive
 
+
# ##i##mkdir boot
<console>
+
# ##i##mount /dev/sda1 boot
# ##i##date 071620002011
+
Fri Jul 16 20:00:00 UTC 2011
+
 
</console>
 
</console>
  
==== Download the Stage3 ====
+
[[Funtoo_Linux_Installation|Now download and extract the Funtoo stage3 ...]]
Once you are in your Funtoo Linux root filesystem, use <tt>wget</tt> 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 <tt>/mnt/funtoo</tt> directory as follows:
+
  
<console># ##i##cd /mnt/funtoo
+
Once you've extracted the stage3, do a few more preparations and chroot into your new funtoo environment:
# ##i##wget http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-64bit/generic_64/stage3-latest.tar.xz
+
</console>
+
  
 
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 <tt>generic_64</tt> or <tt>generic_32</tt> stage. Consult the [[Download]] page for more information.
 
 
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
+
Bind the kernel related directories
</console>
+
 
+
{{fancyimportant|It is very important to use <tt>tar's</tt> "<tt>'''p'''</tt>" option when extracting the Stage 3 tarball - it tells <tt>tar</tt> to ''preserve'' any permissions and ownership that exist within the archive. Without this option, your Funtoo Linux filesystem permissions will be incorrect.}}
+
 
+
=== Chroot into Funtoo ===
+
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 -t proc none proc
 +
# ##i##mount --rbind /dev dev
 
# ##i##mount --rbind /sys sys
 
# ##i##mount --rbind /sys sys
# ##i##mount --rbind /dev dev
 
</console>
 
  
You'll also want to copy over <tt>resolv.conf</tt> in order to have proper DNS name resolution from inside the chroot:
+
Copy network settings
<console>
+
# ##i##cp -f /etc/resolv.conf etc
# ##i##cp /etc/resolv.conf etc
+
</console>
+
  
Now you can chroot into your new system. Use <tt>env</tt> before <tt>chroot</tt> to ensure that no environment variables from the installation media are used by your new system:
+
Make the zfs folder in 'etc' and copy your zpool.cache
 +
# ##i##mkdir etc/zfs
 +
# ##i##cp /etc/zfs/zpool.cache etc/zfs
  
<console>
+
Chroot into Funtoo
 
# ##i##env -i HOME=/root TERM=$TERM chroot . bash -l
 
# ##i##env -i HOME=/root TERM=$TERM chroot . bash -l
 
</console>
 
</console>
  
{{fancynote|Users of live CDs with 64-bit kernels: Some software may use <tt>uname -r</tt> 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.}}
+
=== In Chroot ===
{{fancyimportant|If you receive the error "<tt>chroot: failed to run command `/bin/bash': Exec format error</tt>", 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:
 
 
<console>
 
<console>
# ##i##export PS1="(chroot) $PS1"
+
Create a symbolic link to your mountpoints
 +
# ##i##ln -sf /proc/mounts /etc/mtab
 +
 
 +
Sync your tree
 +
# ##i##emerge --sync
 
</console>
 
</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.
+
=== Add filesystems to /etc/fstab ===
  
=== Downloading the Portage tree ===
+
Before we continue to compile and or install our kernel in the next step, we will edit the <tt>/etc/fstab</tt> file because if we decide to install our kernel through portage, portage will need to know where our <tt>/boot</tt> is, so that it can place the files in there.
  
{{fancynote|For an alternative way to do this, see [[Installing Portage From Snapshot]].}}
+
Edit <tt>/etc/fstab</tt>:
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 <tt>emerge --sync</tt> from within the chroot. This will automatically clone the portage tree from [https://github.com/funtoo/ports-2012 GitHub]:
+
  
<console>
+
<pre>
(chroot) # ##i##emerge --sync
+
# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>
</console>
+
  
{{fancyimportant|If you receive the error with initial <tt>emerge --sync</tt> due to git protocol restrictions, change <tt>SYNC</tt> variable in <tt>/etc/make.conf</tt>}}
+
/dev/sda1              /boot          ext2            defaults        0 2
<pre>
+
/dev/zvol/tank/swap    none            swap            sw              0 0
SYNC="https://github.com/funtoo/ports-2012.git"
+
 
</pre>
 
</pre>
  
=== Configuring your system ===
+
== Kernel Configuration ==
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 <tt>/etc/fstab</tt>. The others are optional. Here are a list of files that you should consider editing:
+
To speed up this step, you can install a pre-configured/compiled kernel called '''bliss-kernel'''. This kernel already has the correct configurations for ZFS and a variety of other scenarios. It's a vanilla kernel from kernel.org without any external patches.
{{TableStart}}
+
<tr class="active"><th>File</th>
+
<th>Do I need to change it?</th>
+
<th>Description</th>
+
</tr><tr>
+
<td><tt>/etc/fstab</tt></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><tt>/etc/localtime</tt></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><tt>/etc/make.conf</tt> (symlink) - also known as:<br/><tt>/etc/portage/make.conf</tt></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><tt>/etc/conf.d/hostname</tt></td>
+
<td>''Maybe - recommended''</td>
+
<td>Used to set system hostname. Set the <tt>hostname</tt> variable to the fully-qualified (with dots, ie. <tt>foo.funtoo.org</tt>) name if you have one. Otherwise, set to the local system hostname (without dots, ie. <tt>foo</tt>). Defaults to <tt>localhost</tt> if not set.</td>
+
</tr><tr>
+
<td><tt>/etc/hosts</tt></td>
+
<td>''No''</td>
+
<td> You no longer need to manually set the hostname in this file. This file is automatically generated by <tt>/etc/init.d/hostname</tt>.</td>
+
</tr><tr>
+
<td><tt>/etc/conf.d/keymaps</tt></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><tt>/etc/conf.d/hwclock</tt></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><tt>/etc/conf.d/modules</tt></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><tt>profiles</tt></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]])
+
To install {{Package|sys-kernel/bliss-kernel}} type the following:
  
Let's go ahead and see what we have to do. Use <tt>nano -w <name_of_file></tt> to edit files -- the "<tt>-w</tt>" disables word-wrapping, which is handy when editing configuration files. You can copy and paste from the examples.
+
<console>
 
+
# ##i##emerge bliss-kernel
{{fancywarning|It's important to edit your <tt>/etc/fstab</tt> 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 <tt>gdisk</tt> or <tt>fdisk</tt>. Skipping this step may prevent Funtoo Linux from booting successfully.}}
+
</console>
 
+
==== /etc/fstab ====
+
  
<tt>/etc/fstab</tt> is used by the <tt>mount</tt> command which is ran when your system boots. Statements of this file inform <tt>mount</tt> about partitions to be mounted and how they are mounted. In order for the system to boot properly, you must edit <tt>/etc/fstab</tt> and ensure that it reflects the partition configuration you used earlier:
+
Now make sure that your <tt>/usr/src/linux symlink</tt> is pointing to this kernel by typing the following:
  
 
<console>
 
<console>
(chroot) # ##i##nano -w /etc/fstab
+
# ##i##eselect kernel list
 +
Available kernel symlink targets:
 +
[1]  linux-3.12.13-KS.02 *
 
</console>
 
</console>
  
You can use arrow keys to move around and hit Control-X to exit. If you want to save your changes, type "<tt>Y</tt>" when asked if you want to save the modified buffer, or hit Control-O before closing <tt>nano</tt>. Otherwise your changes will be discarded.
+
You should see a star next to the version you installed. In this case it was 3.12.13-KS.02. If it's not set, you can type '''eselect kernel set #'''.
  
<pre>
+
== Installing the ZFS userspace tools and kernel modules ==
# The root filesystem should have a pass number of either 0 or 1.
+
Emerge {{Package|sys-fs/zfs}}. This package will bring in {{Package|sys-kernel/spl}}, and {{Package|sys-fs/zfs-kmod}} as its dependencies:
# 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
+
/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 ====
+
 
+
<tt>/etc/localtime</tt> 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 <tt>/etc/localtime</tt> with a symbolic link to the timezone that you wish to use.
+
  
 
<console>
 
<console>
(chroot) # ##i##ln -sf /usr/share/zoneinfo/MST7MDT /etc/localtime
+
# ##i##emerge zfs
 
</console>
 
</console>
  
The above sets the timezone to Mountain Standard Time (with daylight savings). Type <tt>ls /usr/share/zoneinfo</tt> to see what timezones are available. There are also sub-directories containing timezones described by location.
+
Check to make sure that the zfs tools are working. The <code>zpool.cache</code> file that you copied before should be displayed.
  
==== /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:
 
 
<pre>
 
MAKEOPTS="-j3"
 
</pre>
 
 
If you are unsure about how many processors/threads you have then use /proc/cpuinfo to help you.
 
 
<console>
 
<console>
(chroot) # ##i##grep "processor" /proc/cpuinfo | wc -l
+
# ##i##zpool status
16
+
# ##i##zfs list
 
</console>
 
</console>
  
Set MAKEOPTS to this number plus one:
+
If everything worked, continue.
  
<pre>
+
== Create the initramfs ==
MAKEOPTS="-j17"
+
There are two ways to do this, you can use "genkernel" or "bliss-initramfs". Both will be shown.
</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 ("<tt>-</tt>") 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].
+
=== genkernel ===
 +
Install genkernel and run it:
 +
<console>
 +
# ##i##emerge genkernel
  
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:
+
You only need to add --luks if you used encryption
 +
# ##i##genkernel --zfs --luks initramfs
 +
</console>
  
<pre>
+
=== Bliss Initramfs Creator ===
LINGUAS="fr"
+
If you are encrypting your drives, then add the "luks" use flag to your package.use before emerging:
</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>
 
<console>
(chroot) # ##i##nano -w /etc/conf.d/hwclock
+
# ##i##echo "sys-kernel/bliss-initramfs luks" >> /etc/portage/package.use
 
</console>
 
</console>
  
==== Localization ====
+
Now install the program and run it:
 +
<console>
 +
# ##i##emerge bliss-initramfs
  
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]].
+
You can either run it without any parameters to get an interactive menu
 +
or you can pass the parameters directly. 1 = zfs, 6 = encrypted zfs, and the kernel name.
 +
# ##i##bliss-initramfs 1 3.12.13-KS.02
 +
</console>
  
==== Profiles ====
+
=== Moving into the correct location ===
 
+
Place the file that was generated by the above applications into either your /boot folder (If you are using boot-update) or into your /boot/kernels/3.12.13-KS.02 folder (If you are using bliss-boot). For bliss-boot, the file needs to be called 'initrd' rather than 'initrd-3.12.13-KS.02'.
[[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 <tt>x86-32bit</tt> or <tt>x86-64bit</tt>, 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 <tt>current</tt>, <tt>stable</tt> or <tt>experimental</tt> build. <tt>current</tt> systems will have newer packages unmasked than <tt>stable</tt> systems.
+
;flavor: defines the general type of system, such as <tt>server</tt> or <tt>desktop</tt>, 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 <tt>desktop</tt> flavor inherits the <tt>workstation</tt> flavor settings, which in turn inherits the <tt>X</tt> and <tt>audio</tt> mix-ins. You can view this by using eselect:
+
  
 +
==== boot-update ====
 
<console>
 
<console>
(chroot) # ##i##eselect profile show
+
# ##i##mv initrd-3.12.13-KS.02 /boot
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>
 
</console>
  
To view installed profiles:
+
==== bliss-boot ====
 
<console>
 
<console>
(chroot) # ##i##eselect profile list
+
# ##i##mv initrd-3.12.13-KS.02 /boot/kernels/3.12.13-KS.02/initrd
 
</console>
 
</console>
  
To change the profile flavor:
+
== Installing & Configuring the Bootloader ==
 +
 
 +
=== GRUB 2 (Optional if you are using another bootloader) ===
 
<console>
 
<console>
(chroot) # ##i##eselect profile set-flavor 7
+
# ##i##emerge grub
 
</console>
 
</console>
  
To add a mix-in:
+
You can check that grub is version 2.00 by typing the following command:
  
 
<console>
 
<console>
(chroot) # ##i##eselect profile add 10
+
# ##i##grub-install --version
 +
grub-install (GRUB) 2.00
 
</console>
 
</console>
  
=== Introducing Portage ===
+
Now install grub to the drive itself (not a partition):
 
+
Portage, the Funtoo Linux package manager has a command called <tt>emerge</tt> 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:
+
 
+
 
<console>
 
<console>
(chroot) # ##i##emerge packagename
+
# ##i##grub-install /dev/sda
 
</console>
 
</console>
  
When you install a package by specifying its name in the command-line, Portage records its name in the <tt>/var/lib/portage/world</tt> 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:
+
You should receive the following message:
  
 
<console>
 
<console>
(chroot) # ##i##emerge --sync
+
Installation finished. No error reported.
(chroot) # ##i##emerge -auDN @world
+
 
</console>
 
</console>
  
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 <tt>emerge</tt> to:
+
You should now see some a grub directory with some files inside your /boot folder:
 
+
* '''<tt>a</tt>''' - show us what will be emerged, and '''ask''' us if we want to proceed
+
* '''<tt>u</tt>''' - ''update'' the packages we specify -- don't emerge them again if they are already emerged.
+
* '''<tt>D</tt>''' - Consider the entire dependency tree of packages when looking for updates. In other words, do a '''deep''' update.
+
* '''<tt>N</tt>''' - Update any packages that have changed ('''new''') USE settings.
+
 
+
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.
+
 
+
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>
 
<console>
(chroot) # ##i##emerge -1 packagename
+
# ##i##ls -l /boot/grub
 +
total 2520
 +
-rw-r--r-- 1 root root    1024 Jan  4 16:09 grubenv
 +
drwxr-xr-x 2 root root    8192 Jan 12 14:29 i386-pc
 +
drwxr-xr-x 2 root root    4096 Jan 12 14:28 locale
 +
-rw-r--r-- 1 root root 2555597 Feb  4 11:50 unifont.pf2
 
</console>
 
</console>
  
Advanced users may be interested in the [[Emerge]] wiki page.
+
=== Extlinux (Optional if you are using another bootloader) ===
 
+
To install extlinux, you can follow the guide here: [[Extlinux|Link to Extlinux Guide]].
==== Updating World ====
+
  
Now it is actually a very good time to update the entire system and it is very important that you do so before rebooting to resolve various issues.
+
=== LILO (Optional if you are using another bootloader) ===
 +
To install lilo you can type the following:
  
 
<console>
 
<console>
(chroot) # ##i##emerge --sync
+
# ##i##emerge lilo
(chroot) # ##i##emerge -auDN @world
+
 
</console>
 
</console>
  
{{fancyimportant|1=
+
=== boot-update ===
Make sure you read any post emerge messages and follow their instructions. This is especially true if you have upgraded perl or python.}}
+
boot-update comes as a dependency of grub2, so if you already installed grub, it's already on your system!
  
=== Configuring and installing the Linux kernel ===
+
==== Genkernel ====
 +
If your using genkernel you must add 'real_root=ZFS=<root>' and 'dozfs' to your params.
 +
Example entry for <tt>/etc/boot.conf</tt>:
  
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.
+
<pre>
 +
"Funtoo ZFS" {
 +
        kernel vmlinuz[-v]
 +
        initrd initramfs-genkernel-x86_64[-v]
 +
        params real_root=ZFS=tank/funtoo/root
 +
        params += dozfs=force
 +
        # Also add 'params += crypt_root=/dev/sda3' if you used encryption
 +
        # Adjust the above setting to your system if needed
  
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.
+
        # You should also add 'root=none' to your params (not 'params +=') if you plan to use it along with boot-update
 +
        # If root variable will not be set, boot-update will fail to generate boot.conf
 +
        # This is right for <=sys-boot/boot-update-1.6.11 on 16.08.2014 date
 +
}
 +
</pre>
  
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.
+
==== Bliss Initramfs Creator ====
 +
If you used Bliss Initramfs Creator then all you need to do is add 'root=<root>' to your params.
 +
Example entry for <tt>/etc/boot.conf</tt>:
  
==== Package Sets ====
+
<pre>
 +
"Funtoo ZFS" {
 +
        kernel vmlinuz[-v]
 +
        initrd initrd[-v]
 +
        params root=tank/funtoo/root quiet
 +
        # If you have an encrypted device with a regular passphrase,
 +
        # you can add the following line
 +
        params += enc_root=/dev/sda3 enc_type=pass
 +
}
 +
</pre>
  
Before we install a kernel, we're going to cover a feature of Portage called package sets. Earlier we learned about one such package set called the ''world set''. This is a handy feature because packages in additionally defined package sets  are not updated when the ''world set'' is updated. This behavior is generally desired for packages that are time consuming or should not change be updated often without reasons, such as kernel packages.
+
After editing /etc/boot.conf, you just need to run boot-update to update grub.cfg
 
+
==== Kernel Package Set ====
+
 
+
{{Fancynote|1=
+
See [[Funtoo Linux Kernels]] for a full list of kernels supported in Funtoo Linux. We recommend <tt>debian-sources</tt> for new users.}}
+
 
+
{{fancyimportant|1=
+
<tt>debian-sources</tt> with <tt>binary</tt> USE flag requires at least 14GB free in <tt>/var/tmp</tt> and takes around 1 hour to build on a Intel Core i7 Processor.}}
+
 
+
To create the kernel package set, perform the following steps:
+
  
 
<console>
 
<console>
(chroot) # ##i##mkdir /etc/portage/sets
+
###i## boot-update
(chroot) # ##i##echo sys-kernel/debian-sources > /etc/portage/sets/kernel
+
 
</console>
 
</console>
  
Now, we'll want to set a USE variable to tell <tt>debian-sources</tt> 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 <tt>binary</tt> USE variable for <tt>debian-sources</tt>, as follows:
+
=== bliss-boot ===
 +
This is a new program that is designed to generate a simple, human-readable/editable, configuration file for a variety of bootloaders. It currently supports grub2, extlinux, and lilo.
  
 +
You can install it via the following command:
 
<console>
 
<console>
(chroot) # ##i##echo "sys-kernel/debian-sources binary" >> /etc/portage/package.use
+
# ##i##emerge bliss-boot
 
</console>
 
</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 <tt>binary</tt> USE flag to the <tt>debian-sources</tt> 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.
+
==== Bootloader Configuration ====
 +
In order to generate our bootloader configuration file, we will first configure bliss-boot so that it knows what we want. The 'bliss-boot' configuration file is located in '''/etc/bliss-boot/conf.py'''. Open that file and make sure that the following variables are set appropriately:
  
Now, when we just want to update our system's packages, we'll type <tt>emerge -auDN @world</tt>, and it will update our world set, leaving out the kernel. Likewise, when we just want to update our kernel, we'll type <tt>emerge -au @kernel</tt>, and it will update our kernel, leaving out the world set.
+
<pre>
 +
# This should be set to the bootloader you installed earlier: (grub2, extlinux, and lilo are the available options)
 +
bootloader = "grub2"
  
==== Building the Kernel ====
+
# This should be set to the kernel you installed earlier
 +
default = "3.12.13-KS.02"
 +
</pre>
  
Let's emerge our kernel:
+
Scroll all the way down until you find 'kernels'. You will need to add the kernels and the options
 +
you want for these kernels here. Below are a few configuration options depending if you are using
 +
'''bliss-initramfs''' or '''genkernel'''.
  
<console>
+
===== Genkernel =====
(chroot) # ##i##emerge @kernel
+
</console>
+
 
+
Note that while use of the <tt>binary</tt> 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 <tt>MAKEOPTS</tt> in <tt>/etc/make.conf</tt> 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 <tt>binary</tt> 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 <tt>/etc/modprobe.d/</tt>.}}
+
 
+
{{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 <tt>emerge</tt> completes, you'll have a brand new kernel and initramfs installed to <tt>/boot</tt>, plus kernel headers installed in <tt>/usr/src/linux</tt>, and you'll be ready to configure the boot loader to load these to boot your Funtoo Linux system.
+
 
+
=== Installing a Bootloader ===
+
 
+
==== 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 <tt>boot-update</tt>. This will also cause <tt>grub-2</tt> to be merged, since it is a dependency of <tt>boot-update</tt>. (You may need to adjust <tt>GRUB_PLATFORMS</tt> if you are on a UEFI system. See [[UEFI Install Guide]]).
+
 
+
<console>
+
(chroot) # ##i##emerge boot-update
+
</console>
+
 
+
Then, edit <tt>/etc/boot.conf</tt> and specify "<tt>Funtoo Linux genkernel</tt>" as the <tt>default</tt> setting at the top of the file, replacing <tt>"Funtoo Linux"</tt>.
+
 
+
<tt>/etc/boot.conf</tt> should now look like this:
+
  
 
<pre>
 
<pre>
boot {
+
kernel = {
        generate grub
+
    '3.12.13-KS.02' : 'real_root=ZFS=tank/funtoo/root dozfs=force quiet',
        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 <tt>/etc/boot.conf</tt> should look like:
+
'''If you are using encryption you can add the crypt_root option:'''
  
 
<pre>
 
<pre>
boot {
+
kernel = {
        generate grub
+
    '3.12.13-KS.02' : 'real_root=ZFS=tank/funtoo/root dozfs=force crypt_root=/dev/sda3 quiet',
        default "Funtoo Linux genkernel"
+
        timeout 3  
+
 
}
 
}
 +
</pre>
  
"Funtoo Linux" {
+
===== Bliss Initramfs Creator =====
        kernel bzImage[-v]
+
<pre>
        # params += nomodeset
+
kernel = {
 +
    '3.12.13-KS.02' : 'root=tank/funtoo/root quiet',
 
}
 
}
 
"Funtoo Linux genkernel" {
 
        kernel kernels/[-v]/kernel[-v]
 
        initrd initramfs[-v]
 
        params += real_root=auto
 
        # params += nomodeset
 
}
 
 
</pre>
 
</pre>
  
Please read <tt>man boot.conf</tt> for further details.
+
'''If you are using encryption then you would let the initramfs know:'''
  
===== Running grub-install and boot-update =====
+
#"What type of encryption authentication you want to use? ('''enc_type=''')
 +
::* pass = will ask for passphrase directly
 +
::* key = a plain unencrypted key file
 +
::* key_gpg = an encrypted key file
 +
#"Where is the encrypted drive?" ('''enc_root=''')
 +
#"Where is the root pool after it has been decrypted?" ('''root=''')
  
Finally, we will need to actually install the GRUB boot loader to your disk, and also run <tt>boot-update</tt> which will generate your boot loader configuration file:
+
<pre>
 +
kernel = {
 +
    '3.12.13-KS.02' : 'root=tank/funtoo/root enc_root=/dev/sda3 enc_type=pass quiet',
 +
}
 +
</pre>
  
<console>
+
==== Generate the configuration ====
(chroot) # ##i##grub-install --no-floppy /dev/sda
+
Now that we have configure our '''/etc/bliss-boot/conf.py''' file, we can generate our config. Simply run the following command:
(chroot) # ##i##boot-update
+
</console>
+
  
if you boot system in efi/uefi mode to run installation process and want to install new system with grub for booting via classic/legacy mode - you will need to add <tt>GRUB_PLATFORMS="pc"</tt> to <tt>/etc/make.conf</tt> configuration file and install grub with this command instad of one that you see above:
 
 
<console>
 
<console>
(chroot) # ##i##grub-install --loader=i386-pc --no-floppy /dev/sda
+
# ##i##bliss-boot
 
</console>
 
</console>
if you get:
 
<console>mkdir: cannot create directory '/boot/grub': Read-only file system</console>
 
or
 
<console>grub2-install: error: failed to get canonical path of `/boot/grub'</console>
 
then run:
 
<console>(chroot) # ##i##mount -o rw,remount /dev/sda1</console>
 
replacing /dev/sda1 with whatever your boot partition is (/dev/sdc1, etc.) and run the grub-install command again.
 
  
Now you need to update your boot loader configuration file:
+
This will generate a configuration file for the bootloader you specified previously in your current directory. You can check your config file before hand to make sure it doesn't have any errors. Simply open either: grub.cfg, extlinux.conf, or lilo.conf.
<console>
+
(chroot) # ##i##boot-update
+
</console>
+
You only need to run <tt>grub-install</tt> when you first install Funtoo Linux, but you need to re-run <tt>boot-update</tt> every time you modify your <tt>/etc/boot.conf</tt> file, so your changes are applied on next boot.
+
  
OK - your system should be ready to boot! Well, there are a few more loose ends...
+
Once you have checked it for errors, place this file in the correct directory:
  
==== Installing Syslinux/Extlinux ====
+
* grub2 = /boot/grub/
 +
* extlinux = /boot/extlinux/
 +
* lilo = /etc/lilo.conf
  
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.
+
=== LILO (Optional if you are using another bootloader) ===
 
+
Now that bliss-boot generated the lilo.conf file, move that config file to its appropriate location
=== Configuring your network ===
+
and install lilo to the MBR:
 
+
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>
 
<console>
(chroot) # ##i##emerge linux-firmware
+
# ##i##mv lilo.conf /etc
(chroot) # ##i##emerge networkmanager
+
# ##i##lilo
(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 <tt>default</tt> runlevel so it will start when Funtoo Linux boots.
+
You should see the following:
  
After you reboot into Funtoo Linux, you will be able to add a Wi-Fi connection this way:
+
Warning: LBA32 addressing assumed
 
+
Added Funtoo + *
<console>
+
One warning was issued
# ##i##addwifi -S wpa -K 'wifipassword' mywifinetwork
+
 
</console>
 
</console>
  
The <tt>addwifi</tt> command is used to configure and connect to a WPA/WPA2 Wi-Fi network named <tt>mywifinetwork</tt> with the password <tt>wifipassword</tt>. This network configuration entry is stored in <tt>/etc/NetworkManager/system-connections</tt> 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.
+
== Final configuration ==
 +
=== Add the zfs tools to openrc ===
 +
<console># ##i##rc-update add zfs boot</console>
  
===== Using wpa_supplicant =====
+
=== Clean up and reboot ===
If for some reason you don't want to use a tool such as NetworkManager or <tt>wicd</tt>, you can use wpa_supplicant for wireless network connections.
+
We are almost done, we are just going to clean up, '''set our root password''', and unmount whatever we mounted and get out.
 
+
First, emerge wpa_supplicant:
+
  
 
<console>
 
<console>
(chroot) ###i## emerge -a wpa_supplicant
+
Delete the stage3 tarball that you downloaded earlier so it doesn't take up space.
</console>
+
# ##i##cd /
 +
# ##i##rm stage3-latest.tar.xz
  
Now, edit the wpa_supplicant configuration file, located at /etc/wpa_supplicant.conf.
+
Set your root password
The syntax is very easy:
+
# ##i##passwd
<pre>
+
>> Enter your password, you won't see what you are writing (for security reasons), but it is there!
network={
+
ssid="MyWifiName"
+
psk="lol42-wifi"
+
}
+
  
network={
+
Get out of the chroot environment
ssid="Other Network"
+
# ##i##exit
psk="6d96270004515a0486bb7f76196a72b40c55a47f"
+
}
+
</pre>
+
  
You will need to add both <tt>wpa_supplicant</tt> and <tt>dhcpcd</tt> to the default runlevel. <tt>wpa_supplicant</tt> will connect to your access point, and <tt>dhcpcd</tt> will acquire an IP address via DHCP:
+
Unmount all the kernel filesystem stuff and boot (if you have a separate /boot)
 +
# ##i##umount -l proc dev sys boot
  
<console>
+
Turn off the swap
(chroot) # ##i##rc-update add dhcpcd default
+
# ##i##swapoff /dev/zvol/tank/swap
(chroot) # ##i##rc-update add wpa_supplicant default
+
</console>
+
  
==== Desktop (Wired Ethernet) ====
+
Export the zpool
 +
# ##i##cd /
 +
# ##i##zpool export tank
  
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 <tt>dhcpcd</tt> to the default runlevel:
+
Reboot
 
+
# ##i##reboot
<console>
+
(chroot) # ##i##rc-update add dhcpcd default
+
 
</console>
 
</console>
  
When you reboot, <tt>dhcpcd</tt> will run in the background and manage all network interfaces and use DHCP to acquire network addresses from a DHCP server.
+
{{fancyimportant|'''Don't forget to set your root password as stated above before exiting chroot and rebooting. If you don't set the root password, you won't be able to log into your new system.'''}}
  
==== Server (Static IP) ====
+
and that should be enough to get your system to boot on ZFS.
  
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.
+
== After reboot ==
  
=== Finishing Steps ===
+
=== Forgot to reset password? ===
 +
==== System Rescue CD ====
 +
If you aren't using bliss-initramfs, then you can reboot back into your sysresccd and reset through there by mounting your drive, chrooting, and then typing passwd.
  
==== Set your root password ====
+
Example:
It's imperative that you set your root password before rebooting so that you can log in.
+
 
<console>
 
<console>
(chroot) # ##i##passwd
+
# ##i##zpool import -f -R /mnt/funtoo tank
 +
# ##i##chroot /mnt/funtoo bash -l
 +
# ##i##passwd
 +
# ##i##exit
 +
# ##i##zpool export -f tank
 +
# ##i##reboot
 
</console>
 
</console>
  
===Restart your system ===
+
==== Using bliss-initramfs ====
 +
If you forgot to reset your password and are using '''bliss-initramfs''', you can add the '''su''' option to your bootloader parameters and the initramfs will throw you into the rootfs of your drive. In there you can run 'passwd' and then type 'exit'. Once you type 'exit', the initramfs will continue to boot your system as normal.
  
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.
+
=== Create initial ZFS Snapshot ===
 +
Continue to set up anything you need in terms of /etc configurations. Once you have everything the way you like it, take a snapshot of your system. You will be using this snapshot to revert back to this state if anything ever happens to your system down the road. The snapshots are cheap, and almost instant.  
  
Leave the chroot, change directory to /mnt, unmount your Funtoo partitions, and reboot.
+
To take the snapshot of your system, type the following:
<console>
+
<console># ##i##zfs snapshot -r tank@install</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.}}
+
To see if your snapshot was taken, type:
 +
<console># ##i##zfs list -t snapshot</console>
  
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 <tt>login:</tt> prompt. Funtoo Linux has been successfully installed!
+
If your machine ever fails and you need to get back to this state, just type (This will only revert your / dataset while keeping the rest of your data intact):
 +
<console># ##i##zfs rollback tank/funtoo/root@install</console>
  
===Next Steps===
+
{{fancyimportant|'''For a detailed overview, presentation of ZFS' capabilities, as well as usage examples, please refer to the [[ZFS_Fun|ZFS Fun]] page.'''}}
  
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.
+
== Troubleshooting ==
  
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.
+
=== Starting from scratch ===
 +
If your installation has gotten screwed up for whatever reason and you need a fresh restart, you can do the following from sysresccd to start fresh:
  
{{#ask: [[Category:First Steps]] | format=category }}
+
<console>
 +
Destroy the pool and any snapshots and datasets it has
 +
# ##i##zpool destroy -R -f tank
  
If your system did not boot correctly, see [[Installation Troubleshooting]] for steps you can take to resolve the problem.
+
This deletes the files from /dev/sda1 so that even after we zap, recreating the drive in the exact sector
 +
position and size will not give us access to the old files in this partition.
 +
# ##i##mkfs.ext2 /dev/sda1
 +
# ##i##sgdisk -Z /dev/sda
 +
</console>
 +
 
 +
Now start the guide again :).
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
 +
[[Category:Filesystems]]
 +
[[Category:Featured]]
 
[[Category:Install]]
 
[[Category:Install]]
[[Category:Official Documentation]]
+
 
 +
__NOTITLE__

Latest revision as of 00:58, September 21, 2014

Contents

Introduction

This tutorial will show you how to install Funtoo on ZFS (rootfs). This tutorial is meant to be an "overlay" over the Regular Funtoo Installation. Follow the normal installation and only use this guide for steps 2, 3, and 8.

Introduction to ZFS

Since ZFS is a new technology for Linux, it can be helpful to understand some of its benefits, particularly in comparison to BTRFS, another popular next-generation Linux filesystem:

  • On Linux, the ZFS code can be updated independently of the kernel to obtain the latest fixes. btrfs is exclusive to Linux and you need to build the latest kernel sources to get the latest fixes.
  • ZFS is supported on multiple platforms. The platforms with the best support are Solaris, FreeBSD and Linux. Other platforms with varying degrees of support are NetBSD, Mac OS X and Windows. btrfs is exclusive to Linux.
  • ZFS has the Adaptive Replacement Cache replacement algorithm while btrfs uses the Linux kernel's Last Recently Used replacement algorithm. The former often has an overwhelmingly superior hit rate, which means fewer disk accesses.
  • ZFS has the ZFS Intent Log and SLOG devices, which accelerates small synchronous write performance.
  • ZFS handles internal fragmentation gracefully, such that you can fill it until 100%. Internal fragmentation in btrfs can make btrfs think it is full at 10%. Btrfs has no automatic rebalancing code, so it requires a manual rebalance to correct it.
  • ZFS has raidz, which is like RAID 5/6 (or a hypothetical RAID 7 that supports 3 parity disks), except it does not suffer from the RAID write hole issue thanks to its use of CoW and a variable stripe size. btrfs gained integrated RAID 5/6 functionality in Linux 3.9. However, its implementation uses a stripe cache that can only partially mitigate the effect of the RAID write hole.
  • ZFS send/receive implementation supports incremental update when doing backups. btrfs' send/receive implementation requires sending the entire snapshot.
  • ZFS supports data deduplication, which is a memory hog and only works well for specialized workloads. btrfs has no equivalent.
  • ZFS datasets have a hierarchical namespace while btrfs subvolumes have a flat namespace.
  • ZFS has the ability to create virtual block devices called zvols in its namespace. btrfs has no equivalent and must rely on the loop device for this functionality, which is cumbersome.

The only area where btrfs is ahead of ZFS is in the area of small file efficiency. btrfs supports a feature called block suballocation, which enables it to store small files far more efficiently than ZFS. It is possible to use another filesystem (e.g. reiserfs) on top of a ZFS zvol to obtain similar benefits (with arguably better data integrity) when dealing with many small files (e.g. the portage tree).

For a quick tour of ZFS and have a big picture of its common operations you can consult the page ZFS Fun.

Disclaimers

Warning

This guide is a work in progress. Expect some quirks.

Important

Since ZFS was really designed for 64 bit systems, we are only recommending and supporting 64 bit platforms and installations. We will not be supporting 32 bit platforms!

Video Tutorial

As a companion to the installation instructions below, a YouTube video tutorial is now available:

Downloading the ISO (With ZFS)

In order for us to install Funtoo on ZFS, you will need an environment that already provides the ZFS tools. Therefore we will download a customized version of System Rescue CD with ZFS included.

Name: sysresccd-4.0.1_zfs_0.6.2.iso  (545 MB)
Release Date: 2014-02-25
md5sum 01f4e6929247d54db77ab7be4d156d85


Download System Rescue CD with ZFS

Creating a bootable USB from ISO (From a Linux Environment)

After you download the iso, you can do the following steps to create a bootable USB:

Make a temporary directory
# mkdir /tmp/loop

Mount the iso
# mount -o ro,loop /root/sysresccd-4.0.1_zfs_0.6.2.iso /tmp/loop

Run the usb installer
# /tmp/loop/usb_inst.sh

That should be all you need to do to get your flash drive working.

Booting the ISO

Warning

When booting into the ISO, Make sure that you select the "Alternate 64 bit kernel (altker64)". The ZFS modules have been built specifically for this kernel rather than the standard kernel. If you select a different kernel, you will get a fail to load module stack error message.

Creating partitions

There are two ways to partition your disk: You can use your entire drive and let ZFS automatically partition it for you, or you can do it manually.

We will be showing you how to partition it manually because if you partition it manually you get to create your own layout, you get to have your own separate /boot partition (Which is nice since not every bootloader supports booting from ZFS pools), and you get to boot into RAID10, RAID5 (RAIDZ) pools and any other layouts due to you having a separate /boot partition.

gdisk (GPT Style)

A Fresh Start:

First lets make sure that the disk is completely wiped from any previous disk labels and partitions. We will also assume that /dev/sda is the target drive.

# sgdisk -Z /dev/sda

Warning

This is a destructive operation and the program will not ask you for confirmation! Make sure you really don't want anything on this disk.

Now that we have a clean drive, we will create the new layout.

First open up the application:

# gdisk /dev/sda

Create Partition 1 (boot):

Command: n ↵
Partition Number: 
First sector: 
Last sector: +250M ↵
Hex Code: 

Create Partition 2 (BIOS Boot Partition):

Command: n ↵
Partition Number: 
First sector: 
Last sector: +32M ↵
Hex Code: EF02 ↵

Create Partition 3 (ZFS):

Command: n ↵
Partition Number: 
First sector: 
Last sector: 
Hex Code: bf00 ↵

Command: p ↵

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          514047   250.0 MiB   8300  Linux filesystem
   2          514048          579583   32.0 MiB    EF02  BIOS boot partition
   3          579584      1953525134   931.2 GiB   BF00  Solaris root

Command: w ↵


Format your /boot partition

# mkfs.ext2 -m 1 /dev/sda1

Encryption (Optional)

If you want encryption, then create your encrypted vault(s) now by doing the following:

# cryptsetup luksFormat /dev/sda3
# cryptsetup luksOpen /dev/sda3 vault_1

Warning

On some machines, a combination of ZFS and LUKS has caused instability and system crashes.

Create the zpool

We will first create the pool. The pool will be named `tank` and the disk will be aligned to 4096 (using ashift=12)

# zpool create -f -o ashift=12 -o cachefile= -O compression=on -m none -R /mnt/funtoo tank /dev/sda3

Important

If you are using encrypted root, change /dev/sda3 to /dev/mapper/vault_1.

Note

If you have a previous pool that you would like to import, you can do a: zpool import -f -R /mnt/funtoo pool_name.

Create the zfs datasets

We will now create some datasets. For this installation, we will create a small but future proof amount of datasets. We will have a dataset for the OS (/), and your swap. We will also show you how to create some optional datasets: /home, /var, /usr/src, and /usr/portage.

Create some empty containers for organization purposes, and make the dataset that will hold /
# zfs create -p tank/funtoo
# zfs create -o mountpoint=/ tank/funtoo/root

Optional, but recommended datasets: /home
# zfs create -o mountpoint=/home tank/funtoo/home

Optional datasets: /usr/src, /usr/portage/{distfiles,packages}
# zfs create -o mountpoint=/usr/src tank/funtoo/src
# zfs create -o mountpoint=/usr/portage -o compression=off tank/funtoo/portage
# zfs create -o mountpoint=/usr/portage/distfiles tank/funtoo/portage/distfiles
# zfs create -o mountpoint=/usr/portage/packages tank/funtoo/portage/packages

Create your swap zvol

For modern machines that have greater than 4 GB of RAM, A swap size of 2G should be enough. However if your machine doesn't have a lot of RAM, the rule of thumb is either 2x the RAM or RAM + 1 GB.

For this tutorial we will assume that it is a newer machine and make a 2 GB swap.

# zfs create -o sync=always -o primarycache=metadata -o secondarycache=none -o volblocksize=4K -V 2G tank/swap

Format your swap zvol

# mkswap -f /dev/zvol/tank/swap
# swapon /dev/zvol/tank/swap

Now we will continue to install funtoo.

Installing Funtoo

Pre-Chroot

Go into the directory that you will chroot into
# cd /mnt/funtoo

Make a boot folder and mount your boot drive
# mkdir boot
# mount /dev/sda1 boot

Now download and extract the Funtoo stage3 ...

Once you've extracted the stage3, do a few more preparations and chroot into your new funtoo environment:

Bind the kernel related directories
# mount -t proc none proc
# mount --rbind /dev dev
# mount --rbind /sys sys

Copy network settings
# cp -f /etc/resolv.conf etc

Make the zfs folder in 'etc' and copy your zpool.cache
# mkdir etc/zfs
# cp /etc/zfs/zpool.cache etc/zfs

Chroot into Funtoo
# env -i HOME=/root TERM=$TERM chroot . bash -l

In Chroot

Create a symbolic link to your mountpoints
# ln -sf /proc/mounts /etc/mtab

Sync your tree
# emerge --sync

Add filesystems to /etc/fstab

Before we continue to compile and or install our kernel in the next step, we will edit the /etc/fstab file because if we decide to install our kernel through portage, portage will need to know where our /boot is, so that it can place the files in there.

Edit /etc/fstab:

# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>

/dev/sda1               /boot           ext2            defaults        0 2
/dev/zvol/tank/swap     none            swap            sw              0 0

Kernel Configuration

To speed up this step, you can install a pre-configured/compiled kernel called bliss-kernel. This kernel already has the correct configurations for ZFS and a variety of other scenarios. It's a vanilla kernel from kernel.org without any external patches.

To install sys-kernel/bliss-kernel (package not on wiki - please add) type the following:

# emerge bliss-kernel

Now make sure that your /usr/src/linux symlink is pointing to this kernel by typing the following:

# eselect kernel list
Available kernel symlink targets:
[1]   linux-3.12.13-KS.02 *

You should see a star next to the version you installed. In this case it was 3.12.13-KS.02. If it's not set, you can type eselect kernel set #.

Installing the ZFS userspace tools and kernel modules

Emerge sys-fs/zfs (package not on wiki - please add). This package will bring in sys-kernel/spl (package not on wiki - please add), and sys-fs/zfs-kmod (package not on wiki - please add) as its dependencies:

# emerge zfs

Check to make sure that the zfs tools are working. The zpool.cache file that you copied before should be displayed.

# zpool status
# zfs list

If everything worked, continue.

Create the initramfs

There are two ways to do this, you can use "genkernel" or "bliss-initramfs". Both will be shown.

genkernel

Install genkernel and run it:

# emerge genkernel

You only need to add --luks if you used encryption
# genkernel --zfs --luks initramfs

Bliss Initramfs Creator

If you are encrypting your drives, then add the "luks" use flag to your package.use before emerging:

# echo "sys-kernel/bliss-initramfs luks" >> /etc/portage/package.use

Now install the program and run it:

# emerge bliss-initramfs

You can either run it without any parameters to get an interactive menu
or you can pass the parameters directly. 1 = zfs, 6 = encrypted zfs, and the kernel name.
# bliss-initramfs 1 3.12.13-KS.02

Moving into the correct location

Place the file that was generated by the above applications into either your /boot folder (If you are using boot-update) or into your /boot/kernels/3.12.13-KS.02 folder (If you are using bliss-boot). For bliss-boot, the file needs to be called 'initrd' rather than 'initrd-3.12.13-KS.02'.

boot-update

# mv initrd-3.12.13-KS.02 /boot

bliss-boot

# mv initrd-3.12.13-KS.02 /boot/kernels/3.12.13-KS.02/initrd

Installing & Configuring the Bootloader

GRUB 2 (Optional if you are using another bootloader)

# emerge grub

You can check that grub is version 2.00 by typing the following command:

# grub-install --version
grub-install (GRUB) 2.00

Now install grub to the drive itself (not a partition):

# grub-install /dev/sda

You should receive the following message:

Installation finished. No error reported.

You should now see some a grub directory with some files inside your /boot folder:

# ls -l /boot/grub
total 2520
-rw-r--r-- 1 root root    1024 Jan  4 16:09 grubenv
drwxr-xr-x 2 root root    8192 Jan 12 14:29 i386-pc
drwxr-xr-x 2 root root    4096 Jan 12 14:28 locale
-rw-r--r-- 1 root root 2555597 Feb  4 11:50 unifont.pf2

Extlinux (Optional if you are using another bootloader)

To install extlinux, you can follow the guide here: Link to Extlinux Guide.

LILO (Optional if you are using another bootloader)

To install lilo you can type the following:

# emerge lilo

boot-update

boot-update comes as a dependency of grub2, so if you already installed grub, it's already on your system!

Genkernel

If your using genkernel you must add 'real_root=ZFS=<root>' and 'dozfs' to your params. Example entry for /etc/boot.conf:

"Funtoo ZFS" {
        kernel vmlinuz[-v]
        initrd initramfs-genkernel-x86_64[-v]
        params real_root=ZFS=tank/funtoo/root
        params += dozfs=force
        # Also add 'params += crypt_root=/dev/sda3' if you used encryption
        # Adjust the above setting to your system if needed

        # You should also add 'root=none' to your params (not 'params +=') if you plan to use it along with boot-update
        # If root variable will not be set, boot-update will fail to generate boot.conf
        # This is right for <=sys-boot/boot-update-1.6.11 on 16.08.2014 date
}

Bliss Initramfs Creator

If you used Bliss Initramfs Creator then all you need to do is add 'root=<root>' to your params. Example entry for /etc/boot.conf:

"Funtoo ZFS" {
        kernel vmlinuz[-v]
        initrd initrd[-v]
        params root=tank/funtoo/root quiet
        # If you have an encrypted device with a regular passphrase,
        # you can add the following line
        params += enc_root=/dev/sda3 enc_type=pass
}

After editing /etc/boot.conf, you just need to run boot-update to update grub.cfg

# boot-update

bliss-boot

This is a new program that is designed to generate a simple, human-readable/editable, configuration file for a variety of bootloaders. It currently supports grub2, extlinux, and lilo.

You can install it via the following command:

# emerge bliss-boot

Bootloader Configuration

In order to generate our bootloader configuration file, we will first configure bliss-boot so that it knows what we want. The 'bliss-boot' configuration file is located in /etc/bliss-boot/conf.py. Open that file and make sure that the following variables are set appropriately:

# This should be set to the bootloader you installed earlier: (grub2, extlinux, and lilo are the available options)
bootloader = "grub2"

# This should be set to the kernel you installed earlier
default = "3.12.13-KS.02" 

Scroll all the way down until you find 'kernels'. You will need to add the kernels and the options you want for these kernels here. Below are a few configuration options depending if you are using bliss-initramfs or genkernel.

Genkernel
kernel = {
    '3.12.13-KS.02' : 'real_root=ZFS=tank/funtoo/root dozfs=force quiet',
}

If you are using encryption you can add the crypt_root option:

kernel = {
    '3.12.13-KS.02' : 'real_root=ZFS=tank/funtoo/root dozfs=force crypt_root=/dev/sda3 quiet',
}
Bliss Initramfs Creator
kernel = {
    '3.12.13-KS.02' : 'root=tank/funtoo/root quiet',
}

If you are using encryption then you would let the initramfs know:

  1. "What type of encryption authentication you want to use? (enc_type=)
  • pass = will ask for passphrase directly
  • key = a plain unencrypted key file
  • key_gpg = an encrypted key file
  1. "Where is the encrypted drive?" (enc_root=)
  2. "Where is the root pool after it has been decrypted?" (root=)
kernel = {
    '3.12.13-KS.02' : 'root=tank/funtoo/root enc_root=/dev/sda3 enc_type=pass quiet',
}

Generate the configuration

Now that we have configure our /etc/bliss-boot/conf.py file, we can generate our config. Simply run the following command:

# bliss-boot

This will generate a configuration file for the bootloader you specified previously in your current directory. You can check your config file before hand to make sure it doesn't have any errors. Simply open either: grub.cfg, extlinux.conf, or lilo.conf.

Once you have checked it for errors, place this file in the correct directory:

  • grub2 = /boot/grub/
  • extlinux = /boot/extlinux/
  • lilo = /etc/lilo.conf

LILO (Optional if you are using another bootloader)

Now that bliss-boot generated the lilo.conf file, move that config file to its appropriate location and install lilo to the MBR:

# mv lilo.conf /etc
# lilo

You should see the following:

Warning: LBA32 addressing assumed
Added Funtoo + *
One warning was issued

Final configuration

Add the zfs tools to openrc

# rc-update add zfs boot

Clean up and reboot

We are almost done, we are just going to clean up, set our root password, and unmount whatever we mounted and get out.

Delete the stage3 tarball that you downloaded earlier so it doesn't take up space.
# cd /
# rm stage3-latest.tar.xz

Set your root password
# passwd
>> Enter your password, you won't see what you are writing (for security reasons), but it is there!

Get out of the chroot environment
# exit

Unmount all the kernel filesystem stuff and boot (if you have a separate /boot)
# umount -l proc dev sys boot

Turn off the swap
# swapoff /dev/zvol/tank/swap

Export the zpool
# cd /
# zpool export tank

Reboot
# reboot

Important

Don't forget to set your root password as stated above before exiting chroot and rebooting. If you don't set the root password, you won't be able to log into your new system.

and that should be enough to get your system to boot on ZFS.

After reboot

Forgot to reset password?

System Rescue CD

If you aren't using bliss-initramfs, then you can reboot back into your sysresccd and reset through there by mounting your drive, chrooting, and then typing passwd.

Example:

# zpool import -f -R /mnt/funtoo tank
# chroot /mnt/funtoo bash -l
# passwd
# exit
# zpool export -f tank
# reboot

Using bliss-initramfs

If you forgot to reset your password and are using bliss-initramfs, you can add the su option to your bootloader parameters and the initramfs will throw you into the rootfs of your drive. In there you can run 'passwd' and then type 'exit'. Once you type 'exit', the initramfs will continue to boot your system as normal.

Create initial ZFS Snapshot

Continue to set up anything you need in terms of /etc configurations. Once you have everything the way you like it, take a snapshot of your system. You will be using this snapshot to revert back to this state if anything ever happens to your system down the road. The snapshots are cheap, and almost instant.

To take the snapshot of your system, type the following:

# zfs snapshot -r tank@install

To see if your snapshot was taken, type:

# zfs list -t snapshot

If your machine ever fails and you need to get back to this state, just type (This will only revert your / dataset while keeping the rest of your data intact):

# zfs rollback tank/funtoo/root@install

Important

For a detailed overview, presentation of ZFS' capabilities, as well as usage examples, please refer to the ZFS Fun page.

Troubleshooting

Starting from scratch

If your installation has gotten screwed up for whatever reason and you need a fresh restart, you can do the following from sysresccd to start fresh:

Destroy the pool and any snapshots and datasets it has
# zpool destroy -R -f tank

This deletes the files from /dev/sda1 so that even after we zap, recreating the drive in the exact sector
position and size will not give us access to the old files in this partition.
# mkfs.ext2 /dev/sda1
# sgdisk -Z /dev/sda

Now start the guide again :).