Difference between pages "ZFS Install Guide" and "Building a Kernel from Source"

From Funtoo
(Difference between pages)
Jump to: navigation, search
(Add force for dozfs and fix default name of crypted sda)
 
m
 
Line 1: Line 1:
== Introduction ==
+
Setting up a proper kernel yourself - lean, mean and tailored to your hardware,  is the challenge by which a linux user can graduate to becoming a Funtoo knight ;-)
  
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.
+
Even though many of us are using enterprise-ready kernels in datacenters, there is almost nobody who hasn't at least considered building a kernel for his laptop / PC.
 +
We are showing here how an intermediate Linux user can use an alternative to the standard beginners "genkernel" approach, to compile a custom kernel, in a relatively still speedy and easy set up.
  
=== Introduction to ZFS ===
+
=== Minimum Requirements ===
 +
You should understand the way how things work in a terminal and how to use an editor and tweak config files. This is crucial.
 +
You don't need much knowledge about the linux kernel and it's internals. Nevertheless, you have to know at least where the files are located, how they are used and what is the file logic behind the overall structure. Otherwise you should consider using a non source based linux distribution.
 +
If you are scared now, don't worry - we are going to build a kernel the Funtoo way and you will pick up everthing necessary to accomplish this challenge, step by step, so the next time you do it yourself and become a real Funtoo knight!
  
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:
+
=== Assumptions ===
 +
You start from an installed Funtoo system on the disk, or at least, you are on stage3 in a chrooted environment from a live cd, following somehow the Funto [[Installation (Tutorial)|Installation Tutorial]].
  
* 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.
+
In this case we are building a kernel that is booting root in LVM over encrypted LUKS container.
 +
If you don't have this setup, don't worry, you just don't need all the modules, but everything else is similar.
  
* 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.
+
= Getting everything in order to start =
  
* ZFS has the ZFS Intent Log and SLOG devices, which accelerates small synchronous write performance.
+
First there is the decision which linux kernel sources we need.
 +
There are plenty of them in the repositories around, often it is not easy to distinguish between them.
  
* 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.
+
I would always trust my distribution of choice and take what is has to offer - and funtoo has a lot to offer!
  
* 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.
+
I really do recommend (especially if it is your first time) to build a debian-sourced genkernel like described in chapter 5 "Using Debian-Sources with Genkernel" in the [[Funtoo_Linux_Kernels| Funtoo Kernels Tutorial]].
  
* ZFS send/receive implementation supports incremental update when doing backups. btrfs' send/receive implementation requires sending the entire snapshot.
+
From there you should have a running system booting nicely from your own build (just little bit bloated) kernel. This is more than you can expect from any other ready to go distribution.
  
* ZFS supports data deduplication, which is a memory hog and only works well for specialized workloads. btrfs has no equivalent.
+
'''Attention'''
 +
We are using RedHat's dracut in order to build a nice initramfs (containing all the necessary tools and extra drivers our kernel might need to start the system).
  
* ZFS datasets have a hierarchical namespace while btrfs subvolumes have a flat namespace.
+
Although dracut is the way to go, more sophisticated and not as buggy as gentoo's genkernel approach, more and more funtoo geeks start using slashbeast's better-initramfs, which we will cover at the end of this howto!
  
* 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.
+
So after having set up a genkernel from debian or gentoo sources we are going to build a kernel with either (or both) dracut or/and better-initramfs.
 +
So gentoo sources with genkernel is always my backup if anything is not working correctly on my system. For the slightly more geeky approach with my own initram I am using pf-sources, ck-sources or any other more or less heavily patched sources.
  
The only area where btrfs is ahead of ZFS is in the area of small file
+
Let's go!
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).
+
  
=== Disclaimers ===
+
== Kernel Sources ==
 +
We are going to use the kernel sources from the funtoo git repository.
  
{{fancywarning|This guide is a work in progress. Expect some quirks.}}
+
The source you use on your system is up to you and your needs.
{{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'''!}}
+
For a laptop or desktop system, we recommend the following:
  
== Video Tutorial ==
+
* '''sys-kernel/pf-sources'''
 +
* '''sys-kernel/ck-sources'''
 +
* '''sys-kernel/gentoo-sources'''
 +
* '''sys-kernel/git-sources'''
 +
* '''sys-kernel/sysrescue-std-sources'''
 +
* '''sys-kernel/debian-sources'''
  
As a companion to the install instructions below, a YouTube video ZFS install tutorial is now available:
+
Please, have a look in the ebuild description, look onto their homepage and take the one that suits you best!
 +
If you are unsure for now, use sys-kernel/gentoo-sources. That's always a safe bet for a general system.
  
{{#widget:YouTube|id=kxEdSXwU0ZI|width=640|height=360}}
+
It is not a problem to have various kernels installed parallel, so go on with any one of them.
  
== Downloading the ISO (With ZFS) ==
+
I am going to use the sys-kernel/pf-sources now, as I already had the gentoo-sources installed.
In order for us to install Funtoo on ZFS, you will need an environment that provides the ZFS tools. Therefore we will download a customized version of System Rescue CD with ZFS already included. When booting, use the "alternate"-kernel. The ZFS-module won't work with the default kernel.  
+
  
<pre>
+
== Prerequisites ==
Name: sysresccd-3.8.1_zfs_0.6.2.iso  (510 MB)
+
Release Date: 2013-11-03
+
md5sum aa33ef61c5d85ad564372327940498c3
+
</pre>
+
  
 +
I don't know which tools you have already installed, so some information here might be redundant.
 +
It doesn't harm to just copy and paste and do some steps again.
  
'''[http://ftp.osuosl.org/pub/funtoo/distfiles/sysresccd/ Download System Rescue CD with ZFS]'''<br />
+
First, we look into our <code>/etc/make.conf</code>:
 
+
== Creating a bootable USB from ISO ==
+
After you download the iso, you can do the following steps to create a bootable USB:
+
  
 
<console>
 
<console>
Make a temporary directory
+
##i### nano /etc/make.conf
# ##i##mkdir /tmp/loop
+
#These compiler flags are just tweaking (optimazation) and NOT necessary:
 
+
CFLAGS="-O2 -pipe -march=native -ftracer -fforce-addr"
Mount the iso
+
CXXFLAGS="${CFLAGS} -fpermissive -fomit-frame-pointer"
# ##i##mount -o ro,loop /root/sysresccd-3.7.1_zfs_0.6.2.iso /tmp/loop
+
KDIR=/usr/src/linux
 
+
KERNEL="symlink build"
Run the usb installer
+
USE="$KERNEL ....here are your use flags...."
# ##i##/tmp/loop/usb_inst.sh
+
## These modules are available:
 +
## DRACUT_MODULES="dracut_modules_biosdevname dracut_modules_btrfs dracut_modules_caps dracut_modules_crypt dracut_modules_crypt-gpg dracut_modules_dmraid dracut_modules_dmsquash-live dracut_modules_gensplash dracut_modules_iscsi dracut_modules_livenet dracut_modules_lvm dracut_modules_mdraid dracut_modules_multipath dracut_modules_nbd dracut_modules_nfs dracut_modules_plymouth dracut_modules_ssh-client dracut_modules_syslog"
 +
## We will use these modules for LVM / LUKS:
 +
DRACUT_MODULES="crypt lvm plymouth biosdevname dmraid crypt-gpg dmsquash-live ssh-client syslog"
 
</console>
 
</console>
  
That should be all you need to do to get your flash drive working.
+
Next, we set the package keywords:
 
+
When you are booting into system rescue cd, make sure you select the '''alternative 64 bit kernel'''. ZFS support was specifically added to the alternative 64 bit kernel rather than the standard 64 bit kernel.
+
 
+
== 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>
 
<console>
# ##i##gdisk /dev/sda
+
/etc/portage/package.use/dracut:
 
+
sys-kernel/dracut dm net device-mapper crypt lvm
Command: ##i##x ↵
+
Expert command: ##i##z ↵
+
About to wipe out GPT on /dev/sda. Proceed?: ##i##y ↵
+
GPT data structures destroyed! You may now partition the disk using fdisk or other utilities.
+
Blank out MBR?: ##i##y ↵
+
 
</console>
 
</console>
  
{{fancywarning|This is a destructive operation. Make sure you really don't want anything on this disk.}}
+
{{Note}} If you don't have lvm over encrypted LUKS you probably just add the "net" keyword here, or "selinux".
  
Now that we have a clean drive, we will create the new layout.
 
  
'''Create Partition 1''' (boot):
+
After that we are going to build our packages:
 
<console>
 
<console>
Command: ##i##n ↵
+
# ##i##emerge -av app-portage/gentoolkit sys-kernel/pf-sources sys-kernel/dracut sys-boot/plymouth sys-boot/plymouth-openrc-plugin
Partition Number: ##i##↵
+
First sector: ##i##↵
+
Last sector: ##i##+250M ↵
+
Hex Code: ##i##
+
 
</console>
 
</console>
  
'''Create Partition 2''' (BIOS Boot Partition):
+
Finished? Well, then let's go on and
<console>Command: ##i##n ↵
+
Partition Number: ##i##↵
+
First sector: ##i##↵
+
Last sector: ##i##+32M ↵
+
Hex Code: ##i##EF02 ↵
+
</console>
+
  
'''Create Partition 3''' (ZFS):
+
== Preparing the kernel ==
<console>Command: ##i##n ↵
+
Partition Number: ##i##↵
+
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>
+
 
+
 
+
=== Format your boot volume ===
+
Format your separate /boot partition:
+
<console># ##i##mkfs.ext2 /dev/sda1</console>
+
 
+
=== Encryption (Optional) ===
+
If you want encryption, then create your encrypted vault(s) now by doing the following:
+
  
 +
We go now to the sources directory and enter the following commands to update the kernel's  .config  file:
 
<console>
 
<console>
# ##i##cryptsetup luksFormat /dev/sda3
+
##i### cd /usr/src/linux/
# ##i##cryptsetup luksOpen /dev/sda3 vault_1
+
##i### make clean
 +
  CLEAN  .
 +
  CLEAN  arch/x86/kernel/acpi/realmode
 +
  CLEAN  arch/x86/kernel/cpu
 +
  CLEAN  arch/x86/kernel
 +
  CLEAN  arch/x86/vdso
 +
  CLEAN  arch/x86/lib
 +
  CLEAN  drivers/gpu/drm/radeon
 +
  CLEAN  drivers/net/wan
 +
  CLEAN  drivers/scsi/aic7xxx
 +
  CLEAN  drivers/tty/vt
 +
  CLEAN  drivers/video/logo
 +
  CLEAN  firmware
 +
  CLEAN  kernel
 +
  CLEAN  lib/raid6
 +
  CLEAN  lib
 +
  CLEAN  security/apparmor
 +
  CLEAN  security/selinux
 +
  CLEAN  usr
 +
  CLEAN  arch/x86/boot/compressed
 +
  CLEAN  arch/x86/boot
 +
  CLEAN  .tmp_versions
 +
  CLEAN  vmlinux System.map .tmp_kallsyms2.S .tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms1.S .tmp_vmlinux1 .tmp_vmlinux2 .tmp_System.map
 +
##i### zcat /proc/config.gz > /usr/src/linux/.config
 
</console>
 
</console>
 
=== Create the zpool ===
 
We will first create the pool. The pool will be named `rpool` 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 rpool /dev/sda3</console>
 
 
{{fancyimportant|If you are using encrypted root, change '''/dev/sda3 to /dev/mapper/vault_1'''.}}
 
 
{{fancynote|'''ashift<nowiki>=</nowiki>12''' should be use if you have a newer, advanced format disk that has a sector size of 4096 bytes. If you have an older disk with 512 byte sectors, you should use '''ashift<nowiki>=</nowiki>9''' or don't add the option for auto detection}}
 
 
{{fancynote|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.
 
  
 
<console>
 
<console>
Create some empty containers for organization purposes, and make the dataset that will hold /
+
##i### make localmodconfig
# ##i##zfs create rpool/ROOT
+
# ##i##zfs create -o mountpoint=/ rpool/ROOT/funtoo
+
 
+
Optional, but recommended datasets: /home
+
# ##i##zfs create -o mountpoint=/home rpool/HOME
+
 
+
Optional, portage tree, distfiles, and binary packages:
+
# ##i##zfs create rpool/FUNTOO
+
# ##i##zfs create -o mountpoint=/usr/portage -o compression=off rpool/FUNTOO/portage
+
# ##i##zfs create -o mountpoint=/usr/portage/distfiles rpool/FUNTOO/portage/distfiles
+
# ##i##zfs create -o mountpoint=/usr/portage/packages rpool/FUNTOO/portage/packages
+
 
+
Optional datasets: /usr/src
+
# ##i##zfs create -o mountpoint=/usr/src rpool/FUNTOO/src
+
 
</console>
 
</console>
  
=== Create your swap zvol ===
+
You will get some questions which you can answer mostly with either M (compiled as a module) or Y (compiled directly into the kernel).
'''Make your swap +1G greater than your RAM. An 8G machine would have 9G of SWAP (This is kinda big though). For machines with this much memory, You could just make it 2G if you don't have any problems.'''
+
<pre>
<console>
+
Enable different security models (SECURITY) [Y/n/?] y
# ##i##zfs create -o sync=always -o primarycache=metadata -o secondarycache=none -o volblocksize=4K -V 1G rpool/swap
+
Enable the securityfs filesystem (SECURITYFS) [Y/?] y
</console>
+
Socket and Networking Security Hooks (SECURITY_NETWORK) [Y/?] y
 +
Security hooks for pathname based access control (SECURITY_PATH) [Y/?] y
 +
Low address space for LSM to protect from user allocation (LSM_MMAP_MIN_ADDR) [65536] 65536
 +
NSA SELinux Support (SECURITY_SELINUX) [Y/n/?] y
 +
  NSA SELinux boot parameter (SECURITY_SELINUX_BOOTPARAM) [N/y/?] n
 +
  NSA SELinux runtime disable (SECURITY_SELINUX_DISABLE) [N/y/?] n
 +
  NSA SELinux Development Support (SECURITY_SELINUX_DEVELOP) [Y/n/?] y
 +
  NSA SELinux AVC Statistics (SECURITY_SELINUX_AVC_STATS) [Y/n/?] y
 +
  NSA SELinux checkreqprot default value (SECURITY_SELINUX_CHECKREQPROT_VALUE) [1] 1
 +
  NSA SELinux maximum supported policy format version (SECURITY_SELINUX_POLICYDB_VERSION_MAX) [Y/n/?] y
 +
    NSA SELinux maximum supported policy format version value (SECURITY_SELINUX_POLICYDB_VERSION_MAX_VALUE) [19] 19
 +
TOMOYO Linux Support (SECURITY_TOMOYO) [Y/n/?] y
 +
  Default maximal count for learning mode (SECURITY_TOMOYO_MAX_ACCEPT_ENTRY) [2048] 2048
 +
  Default maximal count for audit log (SECURITY_TOMOYO_MAX_AUDIT_LOG) [1024] 1024
 +
  Activate without calling userspace policy loader. (SECURITY_TOMOYO_OMIT_USERSPACE_LOADER) [Y/n/?] y
 +
AppArmor support (SECURITY_APPARMOR) [Y/n/?] y
 +
  AppArmor boot parameter default value (SECURITY_APPARMOR_BOOTPARAM_VALUE) [1] 1
 +
Integrity Measurement Architecture(IMA) (IMA) [Y/n/?] y
 +
EVM support (EVM) [N/y/?] (NEW)
 +
Default security module
 +
  1. SELinux (DEFAULT_SECURITY_SELINUX)
 +
  2. TOMOYO (DEFAULT_SECURITY_TOMOYO)
 +
  3. AppArmor (DEFAULT_SECURITY_APPARMOR)
 +
> 4. Unix Discretionary Access Controls (DEFAULT_SECURITY_DAC)
 +
choice[1-4?]: 4
 +
warning: (ACPI_HOTPLUG_CPU) selects ACPI_CONTAINER which has unmet direct dependencies (ACPI && EXPERIMENTAL)
 +
warning: (MEDIA_TUNER) selects MEDIA_TUNER_TEA5761 which has unmet direct dependencies (MEDIA_SUPPORT && VIDEO_MEDIA && I2C && EXPERIMENTAL)
 +
#
 +
# configuration written to .config
 +
#
 +
warning: (GFS2_FS) selects DLM which has unmet direct dependencies (EXPERIMENTAL && INET && SYSFS && CONFIGFS_FS && (IPV6 || IPV6=n))
 +
warning: (IMA) selects TCG_TPM which has unmet direct dependencies (HAS_IOMEM && EXPERIMENTAL)
 +
warning: (MEDIA_TUNER) selects MEDIA_TUNER_TEA5761 which has unmet direct dependencies (MEDIA_SUPPORT && VIDEO_MEDIA && I2C && EXPERIMENTAL)
 +
warning: (ACPI_HOTPLUG_CPU) selects ACPI_CONTAINER which has unmet direct dependencies (ACPI && EXPERIMENTAL)
 +
root@[~src/linux] #
  
=== Format your swap zvol ===
+
</pre>
<console>
+
# ##i##mkswap -f /dev/zvol/rpool/swap
+
# ##i##swapon /dev/zvol/rpool/swap
+
</console>
+
  
 +
Now comes the most adventurous part!
  
=== Last minute checks and touches ===
+
= Building the Kernel =
Check to make sure everything appears fine. Your output may differ depending on the choices you made above:
+
 
<console>
 
<console>
# ##i##zpool status
+
##i### make -j8 bzImage
  pool: rpool
+
##i### make -j8 modules
  state: ONLINE
+
##i### make modules_install
  scan: none requested
+
##i### make install
config:
+
 
+
        NAME        STATE    READ WRITE CKSUM
+
        rpool      ONLINE      0    0    0
+
          sda2      ONLINE      0    0    0
+
 
+
errors: No known data errors
+
 
+
# ##i##zfs list
+
rpool              3.10G  15.5G  136K  none
+
rpool/HOME          136K  15.5G  136K  /mnt/funtoo/home
+
rpool/ROOT          308K  15.5G  136K  none
+
rpool/ROOT/funtoo  172K  15.5G  172K  /mnt/funtoo
+
rpool/swap        3.09G  18.6G    76K  -
+
 
</console>
 
</console>
  
Now we will continue to install funtoo.
 
  
== Installing Funtoo ==
+
'''Building an initramfs or not?'''
[[Funtoo_Linux_Installation|Download and extract the Funtoo stage3 and continue installation as normal.]]
+
  
Then once you've extracted the stage3, chroot into your new funtoo environment:
+
The reason to build a kernel with an initramfs is mostly for interoperability (e.g. live-cd's) and special features like an included busybox, ssh, etc.  But mostly, and that's why we are doing this here now, to have a proper kernel up and running quick'n dirty in a reasonable time without fighting hours and days until a more or less exotic hardware is perfectly run by the kernel.
<console>
+
After having a proper basic kernel running with the help of an initramfs, I really recommend you to go a step further and build a true kernel with all features includes without an initramfs. But this could be pain in the ass and very time consuming - so we do it the funtoo way here - at least in the second example when we stick to better-initramfs instead of Red-Hat's ''dracut''.
Go into the directory that you will chroot into
+
# ##i##cd /mnt/funtoo
+
  
Mount your boot drive
+
= Option one: Initrd with dracut =
# ##i##mount /dev/sda1 /mnt/funtoo/boot
+
  
Bind the kernel related directories
+
To build the initrd we just execute
# ##i##mount -t proc none /mnt/funtoo/proc
+
# ##i##mount --rbind /dev /mnt/funtoo/dev
+
# ##i##mount --rbind /sys /mnt/funtoo/sys
+
 
+
Copy network settings
+
# ##i##cp /etc/resolv.conf /mnt/funtoo/etc/
+
 
+
chroot into your new funtoo environment
+
# ##i##env -i HOME=/root TERM=$TERM chroot /mnt/funtoo /bin/bash --login
+
 
+
Place your mountpoints into your /etc/mtab file
+
# ##i##cat /proc/mounts > /etc/mtab
+
 
+
Sync your tree
+
# ##i##emerge --sync
+
</console>
+
 
+
=== 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 is your /boot so that it can place the files in there. We also need to update /etc/mtab so our system knows what is mounted
+
  
 
<console>
 
<console>
# ##i##nano /etc/fstab
+
# ##i##dracut -f --fstab --xz /boot/initramfs-3.2.6-pf.img  3.2.6-pf
 
+
# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>
+
# Do not add the /boot line below if you are using whole-disk zfs
+
/dev/sda1              /boot          ext2            defaults        0 2
+
/dev/zvol/rpool/swap    none            swap            sw              0 0
+
 
</console>
 
</console>
  
== Kernel Configuration ==
+
Generally, this really should be enough!
To speed up this step, you can install "bliss-kernel" since it's already properly configured for ZFS and a lot of other configurations. The kernel is also compiled and ready to go. To install 'bliss-kernel' type the following:
+
If you experience booting problems like missing modules / drivers then just boot from the genkernel section and fix the initrd building. You can look into the man page to tweak the command a bit (e.g. --add-drivers "xz dm_crypt" etc...).
  
<console>
+
Ok let's go on and finish the taks, we are going to tell now grub how to boot off correctly!
# ##i##emerge bliss-kernel
+
</console>
+
  
Now make sure that your /usr/src/linux symlink is pointing to this kernel by typing the following:
+
<pre>
 +
root@[~src/linux] # nano /etc/boot.conf
  
<console>
+
boot {
# ##i##eselect kernel list
+
        generate grub
Available kernel symlink targets:
+
        default "Funtoo Linux dracut"
[1]  linux-3.10.10-FB.01 *
+
        timeout 3
</console>
+
}
  
You should see a star next to the bliss-kernel version you installed. In this case it was 3.10.10-FB.01. If it's not set, you can type '''eselect kernel set #'''.
+
"Funtoo Linux genkernel" {
 +
        kernel kernel-genkernel[-v]
 +
        initrd initramfs-genkernel[-v]
 +
        params = quiet rootfstype=ext4
 +
        params += luks enc_root=/dev/sda3
 +
        params += lvm root=/dev/mapper/vg-root
 +
}
  
== Installing the ZFS userspace tools and kernel modules ==
+
"Funtoo Linux dracut" {
 +
        kernel vmlinuz[-v]
 +
## this is the better-initramfs generated initrd
 +
        initrd initramfs[-v].img
 +
        params  = quiet rootfstype=ext4
 +
        params += luks enc_root=/dev/sda3
 +
        params += lvm root=/dev/mapper/vg-root
 +
}
  
<console># ##i##emerge -av zfs spl zfs-kmod</console>
+
</pre>
  
(spl = Solaris Porting Layer)
+
That's it almost!
 
+
Check to make sure that the zfs tools are working, the zpool.cache file that you copied before should be displayed.
+
  
 +
Now write to the grub.cfg with the new handy boot-update script from funtoo:
 
<console>
 
<console>
# ##i##zpool status
+
root@[~src/linux] # boot-update -v
# ##i##zfs list
+
 
</console>
 
</console>
 +
<pre>
 +
root@[~src/linux] # sudo boot-update -v
  
If everything worked, continue.
+
boot-update 1.5.2 / Copyright 2009-2011 Funtoo Technologies
  
== Install the bootloader ==
+
[use option "-l" for license info, "-h" for help]
=== GRUB 2 ===
+
Before you do this, make sure this checklist is followed:
+
* Installed kernel and kernel modules
+
* Installed zfs package from the tree
+
* /dev, /proc, /sys are mounted in the chroot environment
+
  
Once all this is checked, let's install grub2. First we need to enable the "libzfs" use flag so zfs support is compiled for grub2.
+
* Generating config for grub...
  
<console># ##i##echo "sys-boot/grub libzfs" >> /etc/portage/package.use</console>
+
DEFAULT > Funtoo Linux - vmlinuz-3.2.6-pf
 +
          Funtoo Linux genkernel - kernel-genkernel-x86_64-3.2.6-pf
  
Then we will compile grub2:
+
* Completed successfully.
 +
</pre>
  
<console># ##i##emerge -av grub</console>
+
Okay,... here you go..! :)
  
Once this is done, you can check that grub is version 2.00 by doing the following command:
+
Reboot and see how it works!
<console>
+
# ##i##grub-install --version
+
grub-install (GRUB) 2.00
+
</console>
+
  
Now try to install grub2:
+
= Option two: using better-initramfs =
<console># ##i##grub-install --no-floppy /dev/sda</console>
+
  
You should receive the following message
+
Piotr's better-initramfs is another approach that is tiny, nice and shiny and seems to become more and more a favourite among funtoo'ers. The biggest plus is that, once built it is kernel version independant.
<console>Installation finished. No error reported.</console>
+
  
If not, then go back to the above checklist.
+
For using this you just do the following steps:
 +
<pre>
 +
1. download sources
 +
2. build kernel with "make bzImage"
 +
3. download better-initramfs
 +
4. run better-initramfs
 +
5. adjust /etc/boot.conf
 +
</pre>
  
=== LILO ===
+
Here is how in detail:
Before you do this, make sure the following checklist is followed:
+
* /dev/, /proc and /sys are mounted.
+
* Installed the sys-fs/zfs package from the tree.
+
Once the above requirements are met, LILO can be installed.
+
  
Now we will install LILO.
+
Assuming you did install already a genkernel backup or at least you have a working bzImage + modules installed, we rush forward to step 3:
<console># ##i##emerge -av sys-boot/lilo</console>
+
Once the installation of LILO is complete we will need to edit the lilo.conf file.
+
<console># ##i##nano /etc/lilo.conf
+
boot=/dev/sda
+
prompt
+
timeout=4
+
default=Funtoo
+
  
image=/boot/bzImage
+
=== download better-initramfs ===
      label=Funtoo
+
      read-only
+
      append="root=rpool/ROOT/funtoo"
+
      initrd=/boot/initramfs
+
</console>
+
All that is left now is to install the bootcode to the MBR.
+
  
This can be accomplished by running:
 
<console># ##i##/sbin/lilo</console>
 
If it is successful you should see:
 
 
<console>
 
<console>
Warning: LBA32 addressing assumed
+
➜ # cd /usr/src/;
Added Funtoo + *
+
➜ # git clone https://github.com/slashbeast/better-initramfs.git
One warning was issued
+
</console>
+
  
== Create the initramfs ==
+
# /src # cd better-initramfs
There are two ways to do this, you can use genkernel, or you can use my bliss initramfs creator. I will show you both.
+
# better-initramfs git:(master) ls
 
+
AUTHORS    LICENSE  README.rst  bootstrap  output  sourceroot
=== genkernel ===
+
ChangeLog  Makefile  TODO        examples  scripts
<console>
+
# ##i##emerge -av sys-kernel/genkernel
+
# You only need to add --luks if you used encryption
+
# ##i##genkernel --zfs --luks initramfs
+
 
</console>
 
</console>
  
=== Bliss Initramfs Creator ===
+
=== build the better-initramfs ===
If you are encrypting your drives, then add the "luks" use flag to your package.use before emerging:
+
 
+
 
<console>
 
<console>
# ##i##echo "sys-kernel/bliss-initramfs luks" >> /etc/portage/package.use
+
# better-initramfs git:(master) sudo bootstrap/bootstrap-all
 +
Passwort: xxx
 +
# from here go and grab a coffee
 +
# sudo make prepare
 +
# sudo make image
 +
# sudo mv output/initramfs.cpio.gz /boot
 
</console>
 
</console>
  
Now install the creator:
+
=== adjust grub ===
  
<console>
+
Taking the above setup we edit the /etc/boot.conf
# ##i##emerge bliss-initramfs
+
as I installed genkernel first, and dracut after - you see this setup:
</console>
+
  
 +
<pre>
 +
boot {
 +
        generate grub
 +
        default "Funtoo Linux"
 +
        timeout 3
 +
}
  
Then go into the install directory, run the script as root, and place it into /boot:
+
# Rootfs over lvm over luks
<console># ##i##cd /opt/bliss-initramfs
+
# /dev/sda3 - encrypted lvm's pv
# ##i##./createInit
+
# /dev/mapper/vg-root - rootfs's lv
# ##i##mv initrd-<kernel_name> /boot
+
</console>
+
'''<kernel_name>''' is the name of what you selected in the initramfs creator, and the name of the outputted file.
+
  
== Using boot-update ==
+
"Funtoo Linux" {
=== /boot on separate partition ===
+
         kernel bzImage[-v]
If you created a separate non-zfs partition for boot then configuring boot-update is almost exactly the same as a normal install except that auto detection for root does not work. You must tell boot-update what your root is.
+
## this is the better-initramfs generated initrd
==== Genkernel ====
+
         initrd initramfs.cpio.gz
If your using genkernel you must add 'real_root=ZFS=<root>' and 'dozfs' to your params.
+
         params = quiet rootfstype=ext4
Example entry for boot.conf:
+
         params += luks enc_root=/dev/sda3
<console>
+
         params += lvm root=/dev/mapper/vg-root
"Funtoo ZFS" {
+
         kernel vmlinuz[-v]
+
         initrd initramfs-genkernel-x86_64[-v]
+
         params real_root=ZFS=rpool/ROOT/funtoo
+
         params += dozfs=force
+
         # Also add 'params += crypt_root=/dev/sda3' if you used encryption
+
        # Adjust the above setting to your system if needed
+
 
}
 
}
</console>
 
  
==== Bliss Initramfs Creator ====
+
"Funtoo Linux dracut" {
If you used the Bliss Initramfs Creator then all you need to do is add 'root=<root>' to your params.
+
Example entry for boot.conf:
+
<console>
+
"Funtoo ZFS" {
+
 
         kernel vmlinuz[-v]
 
         kernel vmlinuz[-v]
        initrd initrd[-v]
+
## this is the dracut generated initrd
         params root=rpool/ROOT/funtoo quiet
+
        initrd initramfs[-v].img
        # If you have an encrypted device with a regular passphrase,
+
         params = quiet rootfstype=ext4
        # you can add the following line
+
         params += luks enc_root=/dev/sda3
         params += enc_root=/dev/sda3 enc_type=pass
+
        params += lvm root=/dev/mapper/vg-root
 
}
 
}
</console>
 
  
After editing /etc/boot.conf, you just need to run boot-update to update grub.cfg
 
<console># ##i##boot-update</console>
 
  
=== /boot on ZFS ===
+
"Funtoo Linux genkernel" {
TBC - pending update to boot-update to support this
+
        kernel kernel-genkernel[-v]
 
+
        initrd initramfs-genkernel[-v]
== Final configuration ==
+
        params = quiet rootfstype=ext4
=== Add the zfs tools to openrc ===
+
        params += luks enc_root=/dev/sda3
<console># ##i##rc-update add zfs boot</console>
+
        params += lvm root=/dev/mapper/vg-root
 +
}
 +
</pre>
 +
Okay,... here you go..! :)
  
=== Clean up and reboot ===
+
update the grub.cfg, then reboot and see how it works!
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>
Delete the stage3 tarball that you downloaded earlier so it doesn't take up space.
+
root@[~src/linux-3.2.6-pf] # boot-update -v   
# ##i##cd /
+
# ##i##rm stage3-latest.tar.xz
+
  
Set your root password
+
boot-update 1.5.2 / Copyright 2009-2011 Funtoo Technologies
# ##i##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
+
[use option "-l" for license info, "-h" for help]
# ##i##exit
+
  
Unmount all the kernel filesystem stuff and boot (if you have a separate /boot)
+
* Generating config for grub...
# ##i##umount -l proc dev sys boot
+
  
Turn off the swap
+
DEFAULT > Funtoo Linux better-initramfs - vmlinuz-3.2.6-pf
# ##i##swapoff /dev/zvol/rpool/swap
+
          Funtoo Linux dracut - vmlinuz-3.2.6-pf
 +
          Funtoo Linux genkernel - kernel-genkernel-x86_64-3.2.6-ck
  
Export the zpool
+
* Completed successfully.
# ##i##cd /
+
# ##i##zpool export rpool
+
  
Reboot
+
root@[~src/linux-3.2.6-pf] #
# ##i##reboot
+
</console>
+
  
{{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.'''}}
+
root@[~src/linux-3.2.6-pf] # reboot
  
and that should be enough to get your system to boot on ZFS.
+
System going down for reboot!
  
== After reboot ==
+
</console>
=== 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 rpool@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 rpool/ROOT/funtoo@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.'''}}
 
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
[[Category:Filesystems]]
 
 
[[Category:Featured]]
 
[[Category:Featured]]
 
+
[[Category:Kernel]]
__NOTITLE__
+

Revision as of 15:14, 9 January 2014

Setting up a proper kernel yourself - lean, mean and tailored to your hardware, is the challenge by which a linux user can graduate to becoming a Funtoo knight ;-)

Even though many of us are using enterprise-ready kernels in datacenters, there is almost nobody who hasn't at least considered building a kernel for his laptop / PC. We are showing here how an intermediate Linux user can use an alternative to the standard beginners "genkernel" approach, to compile a custom kernel, in a relatively still speedy and easy set up.

Contents

Minimum Requirements

You should understand the way how things work in a terminal and how to use an editor and tweak config files. This is crucial. You don't need much knowledge about the linux kernel and it's internals. Nevertheless, you have to know at least where the files are located, how they are used and what is the file logic behind the overall structure. Otherwise you should consider using a non source based linux distribution. If you are scared now, don't worry - we are going to build a kernel the Funtoo way and you will pick up everthing necessary to accomplish this challenge, step by step, so the next time you do it yourself and become a real Funtoo knight!

Assumptions

You start from an installed Funtoo system on the disk, or at least, you are on stage3 in a chrooted environment from a live cd, following somehow the Funto Installation Tutorial.

In this case we are building a kernel that is booting root in LVM over encrypted LUKS container. If you don't have this setup, don't worry, you just don't need all the modules, but everything else is similar.


Getting everything in order to start

First there is the decision which linux kernel sources we need. There are plenty of them in the repositories around, often it is not easy to distinguish between them.

I would always trust my distribution of choice and take what is has to offer - and funtoo has a lot to offer!

I really do recommend (especially if it is your first time) to build a debian-sourced genkernel like described in chapter 5 "Using Debian-Sources with Genkernel" in the Funtoo Kernels Tutorial.

From there you should have a running system booting nicely from your own build (just little bit bloated) kernel. This is more than you can expect from any other ready to go distribution.

Attention We are using RedHat's dracut in order to build a nice initramfs (containing all the necessary tools and extra drivers our kernel might need to start the system).

Although dracut is the way to go, more sophisticated and not as buggy as gentoo's genkernel approach, more and more funtoo geeks start using slashbeast's better-initramfs, which we will cover at the end of this howto!

So after having set up a genkernel from debian or gentoo sources we are going to build a kernel with either (or both) dracut or/and better-initramfs. So gentoo sources with genkernel is always my backup if anything is not working correctly on my system. For the slightly more geeky approach with my own initram I am using pf-sources, ck-sources or any other more or less heavily patched sources.

Let's go!

Kernel Sources

We are going to use the kernel sources from the funtoo git repository.

The source you use on your system is up to you and your needs. For a laptop or desktop system, we recommend the following:

  • sys-kernel/pf-sources
  • sys-kernel/ck-sources
  • sys-kernel/gentoo-sources
  • sys-kernel/git-sources
  • sys-kernel/sysrescue-std-sources
  • sys-kernel/debian-sources

Please, have a look in the ebuild description, look onto their homepage and take the one that suits you best! If you are unsure for now, use sys-kernel/gentoo-sources. That's always a safe bet for a general system.

It is not a problem to have various kernels installed parallel, so go on with any one of them.

I am going to use the sys-kernel/pf-sources now, as I already had the gentoo-sources installed.

Prerequisites

I don't know which tools you have already installed, so some information here might be redundant. It doesn't harm to just copy and paste and do some steps again.

First, we look into our /etc/make.conf:

# nano /etc/make.conf
#These compiler flags are just tweaking (optimazation) and NOT necessary:
CFLAGS="-O2 -pipe -march=native -ftracer -fforce-addr"
CXXFLAGS="${CFLAGS} -fpermissive -fomit-frame-pointer"
KDIR=/usr/src/linux
KERNEL="symlink build"
USE="$KERNEL ....here are your use flags...."
## These modules are available:
## DRACUT_MODULES="dracut_modules_biosdevname dracut_modules_btrfs dracut_modules_caps dracut_modules_crypt dracut_modules_crypt-gpg dracut_modules_dmraid dracut_modules_dmsquash-live dracut_modules_gensplash dracut_modules_iscsi dracut_modules_livenet dracut_modules_lvm dracut_modules_mdraid dracut_modules_multipath dracut_modules_nbd dracut_modules_nfs dracut_modules_plymouth dracut_modules_ssh-client dracut_modules_syslog"
## We will use these modules for LVM / LUKS:
DRACUT_MODULES="crypt lvm plymouth biosdevname dmraid crypt-gpg dmsquash-live ssh-client syslog"

Next, we set the package keywords:

/etc/portage/package.use/dracut:
sys-kernel/dracut dm net device-mapper crypt lvm

Note Note: If you don't have lvm over encrypted LUKS you probably just add the "net" keyword here, or "selinux".


After that we are going to build our packages:

# emerge -av app-portage/gentoolkit sys-kernel/pf-sources sys-kernel/dracut sys-boot/plymouth sys-boot/plymouth-openrc-plugin

Finished? Well, then let's go on and

Preparing the kernel

We go now to the sources directory and enter the following commands to update the kernel's .config file:

# cd /usr/src/linux/
# make clean
  CLEAN   .
  CLEAN   arch/x86/kernel/acpi/realmode
  CLEAN   arch/x86/kernel/cpu
  CLEAN   arch/x86/kernel
  CLEAN   arch/x86/vdso
  CLEAN   arch/x86/lib
  CLEAN   drivers/gpu/drm/radeon
  CLEAN   drivers/net/wan
  CLEAN   drivers/scsi/aic7xxx
  CLEAN   drivers/tty/vt
  CLEAN   drivers/video/logo
  CLEAN   firmware
  CLEAN   kernel
  CLEAN   lib/raid6
  CLEAN   lib
  CLEAN   security/apparmor
  CLEAN   security/selinux
  CLEAN   usr
  CLEAN   arch/x86/boot/compressed
  CLEAN   arch/x86/boot
  CLEAN   .tmp_versions
  CLEAN   vmlinux System.map .tmp_kallsyms2.S .tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms1.S .tmp_vmlinux1 .tmp_vmlinux2 .tmp_System.map
# zcat /proc/config.gz > /usr/src/linux/.config
# make localmodconfig

You will get some questions which you can answer mostly with either M (compiled as a module) or Y (compiled directly into the kernel).

Enable different security models (SECURITY) [Y/n/?] y
Enable the securityfs filesystem (SECURITYFS) [Y/?] y
Socket and Networking Security Hooks (SECURITY_NETWORK) [Y/?] y
Security hooks for pathname based access control (SECURITY_PATH) [Y/?] y
Low address space for LSM to protect from user allocation (LSM_MMAP_MIN_ADDR) [65536] 65536
NSA SELinux Support (SECURITY_SELINUX) [Y/n/?] y
  NSA SELinux boot parameter (SECURITY_SELINUX_BOOTPARAM) [N/y/?] n
  NSA SELinux runtime disable (SECURITY_SELINUX_DISABLE) [N/y/?] n
  NSA SELinux Development Support (SECURITY_SELINUX_DEVELOP) [Y/n/?] y
  NSA SELinux AVC Statistics (SECURITY_SELINUX_AVC_STATS) [Y/n/?] y
  NSA SELinux checkreqprot default value (SECURITY_SELINUX_CHECKREQPROT_VALUE) [1] 1
  NSA SELinux maximum supported policy format version (SECURITY_SELINUX_POLICYDB_VERSION_MAX) [Y/n/?] y
    NSA SELinux maximum supported policy format version value (SECURITY_SELINUX_POLICYDB_VERSION_MAX_VALUE) [19] 19
TOMOYO Linux Support (SECURITY_TOMOYO) [Y/n/?] y
  Default maximal count for learning mode (SECURITY_TOMOYO_MAX_ACCEPT_ENTRY) [2048] 2048
  Default maximal count for audit log (SECURITY_TOMOYO_MAX_AUDIT_LOG) [1024] 1024
  Activate without calling userspace policy loader. (SECURITY_TOMOYO_OMIT_USERSPACE_LOADER) [Y/n/?] y
AppArmor support (SECURITY_APPARMOR) [Y/n/?] y
  AppArmor boot parameter default value (SECURITY_APPARMOR_BOOTPARAM_VALUE) [1] 1
Integrity Measurement Architecture(IMA) (IMA) [Y/n/?] y
EVM support (EVM) [N/y/?] (NEW)
Default security module
  1. SELinux (DEFAULT_SECURITY_SELINUX)
  2. TOMOYO (DEFAULT_SECURITY_TOMOYO)
  3. AppArmor (DEFAULT_SECURITY_APPARMOR)
> 4. Unix Discretionary Access Controls (DEFAULT_SECURITY_DAC)
choice[1-4?]: 4
warning: (ACPI_HOTPLUG_CPU) selects ACPI_CONTAINER which has unmet direct dependencies (ACPI && EXPERIMENTAL)
warning: (MEDIA_TUNER) selects MEDIA_TUNER_TEA5761 which has unmet direct dependencies (MEDIA_SUPPORT && VIDEO_MEDIA && I2C && EXPERIMENTAL)
#
# configuration written to .config
#
warning: (GFS2_FS) selects DLM which has unmet direct dependencies (EXPERIMENTAL && INET && SYSFS && CONFIGFS_FS && (IPV6 || IPV6=n))
warning: (IMA) selects TCG_TPM which has unmet direct dependencies (HAS_IOMEM && EXPERIMENTAL)
warning: (MEDIA_TUNER) selects MEDIA_TUNER_TEA5761 which has unmet direct dependencies (MEDIA_SUPPORT && VIDEO_MEDIA && I2C && EXPERIMENTAL)
warning: (ACPI_HOTPLUG_CPU) selects ACPI_CONTAINER which has unmet direct dependencies (ACPI && EXPERIMENTAL)
root@[~src/linux] #

Now comes the most adventurous part!

Building the Kernel

# make -j8  bzImage
# make -j8 modules
# make modules_install
# make install


Building an initramfs or not?

The reason to build a kernel with an initramfs is mostly for interoperability (e.g. live-cd's) and special features like an included busybox, ssh, etc. But mostly, and that's why we are doing this here now, to have a proper kernel up and running quick'n dirty in a reasonable time without fighting hours and days until a more or less exotic hardware is perfectly run by the kernel. After having a proper basic kernel running with the help of an initramfs, I really recommend you to go a step further and build a true kernel with all features includes without an initramfs. But this could be pain in the ass and very time consuming - so we do it the funtoo way here - at least in the second example when we stick to better-initramfs instead of Red-Hat's dracut.

Option one: Initrd with dracut

To build the initrd we just execute

# dracut -f --fstab --xz /boot/initramfs-3.2.6-pf.img  3.2.6-pf

Generally, this really should be enough! If you experience booting problems like missing modules / drivers then just boot from the genkernel section and fix the initrd building. You can look into the man page to tweak the command a bit (e.g. --add-drivers "xz dm_crypt" etc...).

Ok let's go on and finish the taks, we are going to tell now grub how to boot off correctly!

root@[~src/linux] # nano /etc/boot.conf

boot {
        generate grub
        default "Funtoo Linux dracut"
        timeout 3
}

"Funtoo Linux genkernel" {
        kernel kernel-genkernel[-v]
        initrd initramfs-genkernel[-v]
        params = quiet rootfstype=ext4
        params += luks enc_root=/dev/sda3
        params += lvm root=/dev/mapper/vg-root
}

"Funtoo Linux dracut" {
        kernel vmlinuz[-v]
## this is the better-initramfs generated initrd
        initrd initramfs[-v].img
        params  = quiet rootfstype=ext4
        params += luks enc_root=/dev/sda3
        params += lvm root=/dev/mapper/vg-root
}

That's it almost!

Now write to the grub.cfg with the new handy boot-update script from funtoo:

root@[~src/linux] # boot-update -v
root@[~src/linux] # sudo boot-update -v

 boot-update 1.5.2 / Copyright 2009-2011 Funtoo Technologies

 [use option "-l" for license info, "-h" for help]

 * Generating config for grub...

 DEFAULT > Funtoo Linux - vmlinuz-3.2.6-pf
           Funtoo Linux genkernel - kernel-genkernel-x86_64-3.2.6-pf

 * Completed successfully.

Okay,... here you go..! :)

Reboot and see how it works!

Option two: using better-initramfs

Piotr's better-initramfs is another approach that is tiny, nice and shiny and seems to become more and more a favourite among funtoo'ers. The biggest plus is that, once built it is kernel version independant.

For using this you just do the following steps:

1. download sources
2. build kernel with "make bzImage"
3. download better-initramfs
4. run better-initramfs
5. adjust /etc/boot.conf

Here is how in detail:

Assuming you did install already a genkernel backup or at least you have a working bzImage + modules installed, we rush forward to step 3:

download better-initramfs

➜ # cd /usr/src/;
➜ # git clone https://github.com/slashbeast/better-initramfs.git

➜ # /src #  cd better-initramfs
➜ # better-initramfs git:(master) ls
AUTHORS    LICENSE   README.rst  bootstrap  output   sourceroot
ChangeLog  Makefile  TODO        examples   scripts

build the better-initramfs

➜ # better-initramfs git:(master) sudo bootstrap/bootstrap-all
Passwort: xxx 
# from here go and grab a coffee
➜ # sudo make prepare
➜ # sudo make image
➜ # sudo mv output/initramfs.cpio.gz /boot

adjust grub

Taking the above setup we edit the /etc/boot.conf as I installed genkernel first, and dracut after - you see this setup:

boot {
        generate grub
        default "Funtoo Linux"
        timeout 3
}

# Rootfs over lvm over luks
# /dev/sda3 - encrypted lvm's pv
# /dev/mapper/vg-root - rootfs's lv

"Funtoo Linux" {
        kernel bzImage[-v]
## this is the better-initramfs generated initrd
        initrd initramfs.cpio.gz
        params  = quiet rootfstype=ext4
        params += luks enc_root=/dev/sda3
        params += lvm root=/dev/mapper/vg-root
}

"Funtoo Linux dracut" {
        kernel vmlinuz[-v]
## this is the dracut generated initrd
        initrd initramfs[-v].img
        params  = quiet rootfstype=ext4
        params += luks enc_root=/dev/sda3
        params += lvm root=/dev/mapper/vg-root
}


"Funtoo Linux genkernel" {
        kernel kernel-genkernel[-v]
        initrd initramfs-genkernel[-v]
        params = quiet rootfstype=ext4
        params += luks enc_root=/dev/sda3
        params += lvm root=/dev/mapper/vg-root
}

Okay,... here you go..! :)

update the grub.cfg, then reboot and see how it works!

root@[~src/linux-3.2.6-pf] # boot-update -v     

 boot-update 1.5.2 / Copyright 2009-2011 Funtoo Technologies

 [use option "-l" for license info, "-h" for help]

 * Generating config for grub...

 DEFAULT > Funtoo Linux better-initramfs - vmlinuz-3.2.6-pf
           Funtoo Linux dracut - vmlinuz-3.2.6-pf
           Funtoo Linux genkernel - kernel-genkernel-x86_64-3.2.6-ck

 * Completed successfully.

root@[~src/linux-3.2.6-pf] #

root@[~src/linux-3.2.6-pf] # reboot

System going down for reboot!