Difference between pages "Install/Partitioning" and "ZFS Install Guide"

< Install(Difference between pages)
(Introduction)
 
(Extlinux (Optional if you are using another bootloader))
 
Line 1: Line 1:
<noinclude>
+
== Introduction ==
{{InstallPart|the process of partitioning and filesystem creation}}
+
</noinclude>
+
=== Prepare Hard Disk ===
+
  
In this section, we'll learn about the different ways that Funtoo Linux can be installed on -- and boot from -- a hard disk.
+
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.
  
==== Introduction ====
+
=== Introduction to ZFS ===
  
In earlier times, there was only one way to boot a PC-compatible computer. All of our desktops and servers had a standard PC BIOS, all our hard drives used Master Boot Records to boot the system, and our hard drives were partitioned into different regions using the MBR partition scheme. That was just how it was done. And we liked it that way!
+
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:
  
Then, along came EFI and UEFI, which are new-style firmware designed to boot systems, along with GPT partition tables to support disks larger than 2.2TB. All of the sudden, we had a variety of options to boot Linux systems, turning what once was a one-method-fits-all approach into something a lot more complex.
+
* 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.
  
Let's take a moment to review the options available to you for configuring a hard drive to boot Funtoo Linux. This Install Guide uses, and recommends, the old-school method of BIOS booting and using an MBR. It works. There's nothing wrong with it. If your system disk is 2TB or smaller in size, it won't prevent you from using all of your disk's capacity, either.
+
* 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.
  
But, there are some situations where the old-school method isn't optimal. If you have a system disk >2TB in size, then MBR partitions won't allow you to access all your storage. So that's one reason. Another reason is that there are some so-called "PC" systems out there that don't support BIOS booting anymore, and force you to use UEFI to boot. So, out of compassion for people who fall into this predicament, this Install Guide documents UEFI booting too.
+
* 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.
  
Our recommendation is still to go old-school unless you have reason not to. We call this method the '''BIOS + GRUB (MBR)''' method. It's the traditional method of setting up a PC-compatible system to boot Linux.
+
* ZFS has the ZFS Intent Log and SLOG devices, which accelerates small synchronous write performance.
  
If you need to use UEFI to boot, we recommend not using the MBR at all for booting, as some systems support this, but others don't. Instead, we recommend using UEFI to boot GRUB, which in turn will load Linux. We refer to this method as the '''UEFI + GRUB (GPT)''' method.
+
* 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.
  
And yes, there are even more methods, some of which are documented on the [[Boot Methods]] page. We used to recommend a '''BIOS + GRUB (GPT)''' method but it is not consistently supported across a wide variety of hardware.
+
* 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.
  
'''The big question is -- which boot method should you use?''' Here's how to tell.
+
* ZFS send/receive implementation supports incremental update when doing backups. btrfs' send/receive implementation requires sending the entire snapshot.
  
;Principle 1 - Old School: If you can reliably boot System Rescue CD and it shows you an initial light blue menu, you are booting the CD using the BIOS, and it's likely that you can thus boot Funtoo Linux using the BIOS. So, go old-school and use BIOS booting, ''unless'' you have some reason to use UEFI, such as having a >2.2TB system disk. In that case, see Principle 2, as your system may also support UEFI booting.
+
* ZFS supports data deduplication, which is a memory hog and only works well for specialized workloads. btrfs has no equivalent.
  
;Principle 2 - New School: If you can reliably boot System Rescue CD and it shows you an initial black and white menu -- congratulations, your system is configured to support UEFI booting. This means that you are ready to install Funtoo Linux to boot via UEFI. Your system may still support BIOS booting, but just be trying UEFI first. You can poke around in your BIOS boot configuration and play with this.
+
* ZFS datasets have a hierarchical namespace while btrfs subvolumes have a flat namespace.
  
;What's the Big Difference between Old School and New School?: Here's the deal. If you go with old-school MBR partitions, your <code>/boot</code> partition will be an ext2 filesystem, and you'll use <code>fdisk</code> to create your MBR partitions. If you go with new-school GPT partitions and UEFI booting, your <code>/boot</code> partition will be a vfat filesystem, because this is what UEFI is able to read, and you will use <code>gdisk</code> to create your GPT partitions. And you'll install GRUB a bit differently. That's about all it comes down to, in case you were curious.
+
* 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.
  
{{Note|'''Some motherboards may appear to support UEFI, but don't.''' Do your research. For example, the Award BIOS in my Gigabyte GA-990FXA-UD7 rev 1.1 has an option to enable UEFI boot for CD/DVD. '''This is not sufficient for enabling UEFI boot for hard drives and installing Funtoo Linux.''' UEFI must be supported for both removable media (so you can boot System Rescue CD using UEFI) as well as fixed media (so you can boot your new Funtoo Linux installation.) It turns out that later revisions of this board (rev 3.0) have a new BIOS that fully supports UEFI boot. This may point to a third principle -- know thy hardware.}}
+
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).
  
==== Old-School (BIOS/MBR) Method ====
+
For a quick tour of ZFS and have a big picture of its common operations you can consult the page [[ZFS Fun]].
  
{{Note|Use this method if you are booting using your BIOS, and if your System Rescue CD initial boot menu was light blue. If you're going to use the new-school method, [[#New-School (UEFI/GPT) Method|click here to jump down to UEFI/GPT.]]}}
+
=== Disclaimers ===
  
===== Preparation =====
+
{{fancywarning|This guide is a work in progress. Expect some quirks.}}
 +
{{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'''!}}
 +
== 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.
  
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:
+
<pre>
 +
Name: sysresccd-4.2.0_zfs_0.6.2.iso  (545 MB)
 +
Release Date: 2014-02-25
 +
md5sum 01f4e6929247d54db77ab7be4d156d85
 +
</pre>
 +
 
 +
 
 +
'''[http://ftp.osuosl.org/pub/funtoo/distfiles/sysresccd/ Download System Rescue CD with ZFS]'''<br />
 +
 
 +
== 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:
  
 
<console>
 
<console>
# ##i##fdisk -l /dev/sda
+
Make a temporary directory
 +
# ##i##mkdir /tmp/loop
  
Disk /dev/sda: 640.1 GB, 640135028736 bytes, 1250263728 sectors
+
Mount the iso
Units = sectors of 1 * 512 = 512 bytes
+
# ##i##mount -o ro,loop /root/sysresccd-4.2.0_zfs_0.6.2.iso /tmp/loop
Sector size (logical/physical): 512 bytes / 512 bytes
+
I/O size (minimum/optimal): 512 bytes / 512 bytes
+
Disk label type: gpt
+
  
 +
Run the usb installer
 +
# ##i##/tmp/loop/usb_inst.sh
 +
</console>
  
#        Start         End    Size  Type            Name
+
That should be all you need to do to get your flash drive working.
1        2048  1250263694  596.2G  Linux filesyste Linux filesystem
+
 
 +
== Booting the ISO ==
 +
 
 +
{{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.'''}}
 +
 
 +
== 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 <tt>/dev/sda</tt> is the target drive.<br />
 +
 
 +
<console>
 +
# ##i##sgdisk -Z /dev/sda
 
</console>
 
</console>
  
Now, it's recommended that you erase any existing MBR or GPT partition tables on the disk, which could confuse the system's BIOS at boot time. We do this using <code>sgdisk</code>:
+
{{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.}}
{{fancywarning|This will make any existing partitions inaccessible! You are '''strongly''' cautioned and advised to backup any critical data before proceeding.}}
+
 
 +
Now that we have a clean drive, we will create the new layout.
 +
 
 +
First open up the application:
  
 
<console>
 
<console>
# ##i##sgdisk --zap-all /dev/sda
+
# ##i##gdisk /dev/sda
 +
</console>
  
Creating new GPT entries.
+
'''Create Partition 1''' (boot):
GPT data structures destroyed! You may now partition the disk using fdisk or
+
<console>
other utilities.
+
Command: ##i##n ↵
 +
Partition Number: ##i##↵
 +
First sector: ##i##↵
 +
Last sector: ##i##+250M ↵
 +
Hex Code: ##i##↵
 
</console>
 
</console>
  
This output is also nothing to worry about, as the command still succeded:
+
'''Create Partition 2''' (BIOS Boot Partition):
 +
<console>Command: ##i##n ↵
 +
Partition Number: ##i##↵
 +
First sector: ##i##↵
 +
Last sector: ##i##+32M ↵
 +
Hex Code: ##i##EF02 ↵
 +
</console>
  
<console>
+
'''Create Partition 3''' (ZFS):
***************************************************************
+
<console>Command: ##i##n ↵
Found invalid GPT and valid MBR; converting MBR to GPT format
+
Partition Number: ##i##↵
in memory.  
+
First sector: ##i##↵
***************************************************************
+
Last sector: ##i##↵
 +
Hex Code: ##i##bf00 ↵
 +
 
 +
Command: ##i##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: ##i##w ↵
 
</console>
 
</console>
  
===== Partitioning =====
 
  
Now we will use <code>fdisk</code> to create the MBR partition table and partitions:
+
=== Format your /boot partition ===
  
 
<console>
 
<console>
# ##i##fdisk /dev/sda
+
# ##i##mkfs.ext2 -m 1 /dev/sda1
 
</console>
 
</console>
  
Within <code>fdisk</code>, follow these steps:
+
=== 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>
  
'''Empty the partition table''':
+
=== 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>.
  
 
<console>
 
<console>
Command (m for help): ##i##o
+
Create some empty containers for organization purposes, and make the dataset that will hold /
 +
# ##i##zfs create -p tank/funtoo
 +
# ##i##zfs create -o mountpoint=/ tank/funtoo/root
 +
 
 +
Optional, but recommended datasets: /home
 +
# ##i##zfs create -o mountpoint=/home tank/funtoo/home
 +
 
 +
Optional datasets: /usr/src, /usr/portage/{distfiles,packages}
 +
# ##i##zfs create -o mountpoint=/usr/src tank/funtoo/src
 +
# ##i##zfs create -o mountpoint=/usr/portage -o compression=off tank/funtoo/portage
 +
# ##i##zfs create -o mountpoint=/usr/portage/distfiles tank/funtoo/portage/distfiles
 +
# ##i##zfs create -o mountpoint=/usr/portage/packages tank/funtoo/portage/packages
 
</console>
 
</console>
  
'''Create Partition 1''' (boot):
+
=== 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.
  
 
<console>
 
<console>
Command (m for help): ##i##n ↵
+
# ##i##zfs create -o sync=always -o primarycache=metadata -o secondarycache=none -o volblocksize=4K -V 2G tank/swap
Partition type (default p): ##i##
+
Partition number (1-4, default 1): ##i##↵
+
First sector: ##i##↵
+
Last sector: ##i##+128M ↵
+
 
</console>
 
</console>
 +
{{fancywarning|ZFS swap is not stable and should be used with precautions.}}
  
'''Create Partition 2''' (swap):
+
=== Format your swap zvol ===
 
+
 
<console>
 
<console>
Command (m for help): ##i##n ↵
+
# ##i##mkswap -f /dev/zvol/tank/swap
Partition type (default p): ##i##
+
# ##i##swapon /dev/zvol/tank/swap
Partition number (2-4, default 2): ##i##↵
+
First sector: ##i##↵
+
Last sector: ##i##+2G ↵
+
Command (m for help): ##i##t ↵
+
Partition number (1,2, default 2): ##i## ↵
+
Hex code (type L to list all codes): ##i##82 ↵
+
 
</console>
 
</console>
  
'''Create the root partition:'''
+
Now we will continue to install funtoo.
 +
 
 +
== Installing Funtoo ==
 +
 
 +
=== Pre-Chroot ===
  
 
<console>
 
<console>
Command (m for help): ##i##n ↵
+
Go into the directory that you will chroot into
Partition type (default p): ##i##↵
+
# ##i##cd /mnt/funtoo
Partition number (3,4, default 3): ##i##
+
 
First sector: ##i##↵
+
Make a boot folder and mount your boot drive
Last sector: ##i##
+
# ##i##mkdir boot
 +
# ##i##mount /dev/sda1 boot
 
</console>
 
</console>
  
'''Verify the partition table:'''
+
[[Funtoo_Linux_Installation|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:
  
 
<console>
 
<console>
Command (m for help): ##i##p
+
Bind the kernel related directories
 +
# ##i##mount -t proc none proc
 +
# ##i##mount --rbind /dev dev
 +
# ##i##mount --rbind /sys sys
  
Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
+
Copy network settings
Units: sectors of 1 * 512 = 512 bytes
+
# ##i##cp -f /etc/resolv.conf etc
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
+
Make the zfs folder in 'etc' and copy your zpool.cache
/dev/sda1          2048    264191    131072  83 Linux
+
# ##i##mkdir etc/zfs
/dev/sda2        264192  4458495  2097152  82 Linux swap / Solaris
+
# ##i##cp /etc/zfs/zpool.cache etc/zfs
/dev/sda3        4458496 625142447 310341976  83 Linux
+
 
 +
Chroot into Funtoo
 +
# ##i##env -i HOME=/root TERM=$TERM chroot . bash -l
 
</console>
 
</console>
  
'''Write the parition table to disk:'''
+
=== In Chroot ===
  
 
<console>
 
<console>
Command (m for help): ##i##w
+
Create a symbolic link to your mountpoints
 +
# ##i##ln -sf /proc/mounts /etc/mtab
 +
 
 +
Sync your tree
 +
# ##i##emerge --sync
 
</console>
 
</console>
  
Your new MBR partition table will now be written to your system disk.
+
=== Add filesystems to /etc/fstab ===
  
{{Note|You're done with partitioning! Now, jump over to [[#Creating filesystems|Creating filesystems]].}}
+
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.  
  
==== New-School (UEFI/GPT) Method ====
+
Edit <tt>/etc/fstab</tt>:
  
{{Note|Use this method if you are booting using UEFI, and if your System Rescue CD initial boot menu was black and white. If it was light blue, this method will not work.}}
+
<pre>
 +
# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>
  
The <tt>gdisk</tt> commands to create a GPT partition table are as follows. Adapt sizes as necessary, although these defaults will work for most users. Start <code>gdisk</code>:
+
/dev/sda1              /boot          ext2            defaults        0 2
 +
/dev/zvol/tank/swap    none            swap            sw              0 0
 +
</pre>
 +
 
 +
== Kernel Configuration ==
 +
...wip
 +
 
 +
== Installing the ZFS userspace tools and kernel modules ==
 +
Emerge {{Package|sys-fs/zfs}}. This package will bring in {{Package|sys-kernel/spl}}, and {{Package|sys-fs/zfs-kmod}} as its dependencies:
  
 
<console>
 
<console>
# ##i##gdisk
+
# ##i##emerge zfs
 
</console>
 
</console>
  
Within <tt>gdisk</tt>, follow these steps:
+
Check to make sure that the zfs tools are working. The <code>zpool.cache</code> file that you copied before should be displayed.
  
'''Create a new empty partition table''' (This ''will'' erase all data on the disk when saved):
+
<console>
 +
# ##i##zpool status
 +
# ##i##zfs list
 +
</console>
  
 +
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:
 
<console>
 
<console>
Command: ##i##o ↵
+
# ##i##emerge genkernel
This option deletes all partitions and creates a new protective MBR.
+
 
Proceed? (Y/N): ##i##y ↵
+
You only need to add --luks if you used encryption
 +
# ##i##genkernel --zfs --luks initramfs
 
</console>
 
</console>
  
'''Create Partition 1''' (boot):
+
== Installing & Configuring the Bootloader ==
  
 +
=== GRUB 2 (Optional if you are using another bootloader) ===
 
<console>
 
<console>
Command: ##i##n ↵
+
# ##i##emerge grub
Partition Number: ##i##1 ↵
+
First sector: ##i##↵
+
Last sector: ##i##+500M ↵
+
Hex Code: ##i##
+
 
</console>
 
</console>
  
'''Create Partition 2''' (swap):
+
You can check that grub is version 2.00 by typing the following command:
  
 
<console>
 
<console>
Command: ##i##n ↵
+
# ##i##grub-install --version
Partition Number: ##i##2
+
grub-install (GRUB) 2.00
First sector: ##i##↵
+
Last sector: ##i##+4G ↵
+
Hex Code: ##i##8200 ↵
+
 
</console>
 
</console>
  
'''Create Partition 3''' (root):
+
Now install grub to the drive itself (not a partition):
 +
<console>
 +
# ##i##grub-install /dev/sda
 +
</console>
 +
 
 +
You should receive the following message:
  
 
<console>
 
<console>
Command: ##i##n ↵
+
Installation finished. No error reported.
Partition Number: ##i##3 ↵
+
First sector: ##i##↵
+
Last sector: ##i##↵##!i## (for rest of disk)
+
Hex Code: ##i##↵
+
 
</console>
 
</console>
  
Along the way, you can type "<tt>p</tt>" and hit Enter to view your current partition table. If you make a mistake, you can type "<tt>d</tt>" to delete an existing partition that you created. When you are satisfied with your partition setup, type "<tt>w</tt>" to write your configuration to disk:
+
You should now see some a grub directory with some files inside your /boot folder:
  
'''Write Partition Table To Disk''':
+
<console>
 +
# ##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>
 +
 
 +
=== LILO (Optional if you are using another bootloader) ===
 +
To install lilo you can type the following:
  
 
<console>
 
<console>
Command: ##i##w ↵
+
# ##i##emerge lilo
Do you want to proceed? (Y/N): ##i##Y ↵
+
 
</console>
 
</console>
  
The partition table will now be written to disk and <tt>gdisk</tt> will close.
+
=== boot-update ===
 +
boot-update comes as a dependency of grub2, so if you already installed grub, it's already on your system!
  
Now, your GPT/GUID partitions have been created, and will show up as the following ''block devices'' under Linux:
+
==== 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>:
  
* <tt>/dev/sda1</tt>, which will be used to hold the <tt>/boot</tt> filesystem,
+
<pre>
* <tt>/dev/sda2</tt>, which will be used for swap space, and
+
"Funtoo ZFS" {
* <tt>/dev/sda3</tt>, which will hold your root filesystem.
+
        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
  
==== Creating filesystems ====
+
        # 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>
  
{{Note|This section covers both BIOS ''and'' UEFI installs. Don't skip it!}}
+
==== 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>:
  
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.
+
<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>
  
Let's keep this simple. Are you using old-school MBR partitions? If so, let's create an ext2 filesystem on /dev/sda1:
+
After editing /etc/boot.conf, you just need to run boot-update to update grub.cfg
  
 
<console>
 
<console>
# ##i##mkfs.ext2 /dev/sda1
+
###i## boot-update
 
</console>
 
</console>
  
If you're using new-school GPT partitions for UEFI, you'll want to create a vfat filesystem on /dev/sda1, because this is what UEFI is able to read:
+
=== 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>
# ##i##mkfs.vfat -F 32 /dev/sda1
+
# ##i##emerge bliss-boot
 
</console>
 
</console>
  
Now, let's create a swap partition. This partition will be used as disk-based virtual memory for your Funtoo Linux system.
+
==== 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:
  
You will not create a filesystem on your swap partition, since it is not used to store files. But it is necessary to initialize it using the <code>mkswap</code> command. Then we'll run the <code>swapon</code> command to make your newly-initialized swap space immediately active within the live CD environment, in case it is needed during the rest of the install process:
+
<pre>
 +
# 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"
 +
</pre>
 +
 
 +
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 =====
 +
 
 +
<pre>
 +
kernel = {
 +
    '3.12.13-KS.02' : 'real_root=ZFS=tank/funtoo/root dozfs=force quiet',
 +
}
 +
</pre>
 +
 
 +
'''If you are using encryption you can add the crypt_root option:'''
 +
 
 +
<pre>
 +
kernel = {
 +
    '3.12.13-KS.02' : 'real_root=ZFS=tank/funtoo/root dozfs=force crypt_root=/dev/sda3 quiet',
 +
}
 +
</pre>
 +
 
 +
===== Bliss Initramfs Creator =====
 +
<pre>
 +
kernel = {
 +
    '3.12.13-KS.02' : 'root=tank/funtoo/root quiet',
 +
}
 +
</pre>
 +
 
 +
'''If you are using encryption then you would let the initramfs know:'''
 +
 
 +
#"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=''')
 +
 
 +
<pre>
 +
kernel = {
 +
    '3.12.13-KS.02' : 'root=tank/funtoo/root enc_root=/dev/sda3 enc_type=pass quiet',
 +
}
 +
</pre>
 +
 
 +
==== 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:
  
 
<console>
 
<console>
# ##i##mkswap /dev/sda2
+
# ##i##bliss-boot
# ##i##swapon /dev/sda2
+
 
</console>
 
</console>
  
Now, we need to create a root filesystem. This is where Funtoo Linux will live. We generally recommend ext4 or XFS root filesystems. If you're not sure, choose ext4. Here's how to create a root ext4 filesystem:
+
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:
  
 
<console>
 
<console>
# ##i##mkfs.ext4 /dev/sda3
+
# ##i##mv lilo.conf /etc
 +
# ##i##lilo
 +
 
 +
You should see the following:
 +
 
 +
Warning: LBA32 addressing assumed
 +
Added Funtoo + *
 +
One warning was issued
 
</console>
 
</console>
  
...and here's how to create an XFS root filesystem, if you choose to use XFS:
+
== Final configuration ==
 +
=== Add the zfs tools to openrc ===
 +
<console># ##i##rc-update add zfs boot</console>
 +
 
 +
=== 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.
  
 
<console>
 
<console>
# ##i##mkfs.xfs /dev/sda3
+
Delete the stage3 tarball that you downloaded earlier so it doesn't take up space.
</console>
+
# ##i##cd /
 +
# ##i##rm stage3-latest.tar.xz
  
Your filesystems (and swap) have all now been initialized, so that that can be mounted (attached to your existing directory heirarchy) and used to store files. We are ready to begin installing Funtoo Linux on these brand-new filesystems.
+
Set your root password
 +
# ##i##passwd
 +
>> Enter your password, you won't see what you are writing (for security reasons), but it is there!
  
{{fancywarning|1=
+
Get out of the chroot environment
When deploying an OpenVZ host, please use ext4 exclusively. The Parallels development team tests extensively with ext4, and modern versions of <code>openvz-rhel6-stable</code> are '''not''' compatible with XFS, and you may experience kernel bugs.
+
# ##i##exit
}}
+
  
==== Mounting filesystems ====
+
Unmount all the kernel filesystem stuff and boot (if you have a separate /boot)
 +
# ##i##umount -l proc dev sys boot
  
Mount the newly-created filesystems as follows, creating <code>/mnt/funtoo</code> as the installation mount point:
+
Turn off the swap
 +
# ##i##swapoff /dev/zvol/tank/swap
  
<console>
+
Export the zpool
# ##i##mkdir /mnt/funtoo
+
# ##i##cd /
# ##i##mount /dev/sda3 /mnt/funtoo
+
# ##i##zpool export tank
# ##i##mkdir /mnt/funtoo/boot
+
 
# ##i##mount /dev/sda1 /mnt/funtoo/boot
+
Reboot
 +
# ##i##reboot
 
</console>
 
</console>
  
Optionally, if you have a separate filesystem for <code>/home</code> or anything else:
+
{{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.'''}}
  
 +
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:
 
<console>
 
<console>
# ##i##mkdir /mnt/funtoo/home
+
# ##i##zpool import -f -R /mnt/funtoo tank
# ##i##mount /dev/sda4 /mnt/funtoo/home
+
# ##i##chroot /mnt/funtoo bash -l
 +
# ##i##passwd
 +
# ##i##exit
 +
# ##i##zpool export -f tank
 +
# ##i##reboot
 
</console>
 
</console>
  
If you have <code>/tmp</code> or <code>/var/tmp</code> on a separate filesystem, be sure to change the permissions of the mount point to be globally-writeable after mounting, as follows:
+
==== 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:
 +
<console># ##i##zfs snapshot -r tank@install</console>
 +
 
 +
To see if your snapshot was taken, type:
 +
<console># ##i##zfs list -t snapshot</console>
 +
 
 +
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>
 +
 
 +
{{fancyimportant|'''For a detailed overview, presentation of ZFS' capabilities, as well as usage examples, please refer to the [[ZFS_Fun|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:
  
 
<console>
 
<console>
# ##i##chmod 1777 /mnt/funtoo/tmp
+
Destroy the pool and any snapshots and datasets it has
 +
# ##i##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.
 +
# ##i##mkfs.ext2 /dev/sda1
 +
# ##i##sgdisk -Z /dev/sda
 
</console>
 
</console>
 +
 +
Now start the guide again :).
 +
 +
[[Category:HOWTO]]
 +
[[Category:Filesystems]]
 +
[[Category:Featured]]
 +
[[Category:Install]]
 +
 +
__NOTITLE__

Revision as of 14:57, January 5, 2015

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!

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

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

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
Warning

ZFS swap is not stable and should be used with precautions.

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

...wip

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

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

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