Pre-NOTE: I'm a total kernel building n00b. Please, please, please comment if I made any errors or could improve the folowing procedure. I just wanted to contribute and help anyone looking to ride the bleeding-edge a little.
My daily driver laptop has Ubuntu 17.04 installed with the OS running on a ZFS root pool on my m.2 SSD (120GB). I also have a zpool on a second HDD (500GB). With the release of kernel 4.12, I was interested in trying it out. Basically as a learning experience building the kernel. I know if I didn't build it with ZFS enabled, the OS wouldn't even be able to get to GRUB during boot. Leaving the machine in an unbootable state.
So I spun up a VM (in Virtualbox) with the same file system layout to test it. NOTE: I'm following the procedure below as I write this so I'm 100% sure it works. I'll be using Ubuntu 17.10 Artful Daily ('cause why not. ).
TL;DR: Here's the procedure.
Preface (OS Setup)
Start a VM installing Ubuntu onto a ZFS root pool. Following this procedure. The system has two pools.
- ssdpool: 120GB SSD (Ubuntu OS)
- hddpool: 500GB HDD (Empty Zpool)
Install Kernel Build Software
Install required dependencies for building the kernel.sudo apt install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache
Install dependencies for building SPL and ZFSsudo apt install build-essential autoconf libtool gawk alien fakeroot linux-headers-$(uname -r)
sudo apt install zlib1g-dev uuid-dev libattr1-dev libblkid-dev libselinux-dev libudev-dev libdevmapper-dev
sudo apt install parted lsscsi ksh
Download Kernel, SPL, and ZFS Source
mkdir ~/src && cd ~/src
git clone -b linux-4.12.y git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
git clone https://github.com/zfsonlinux/spl
git clone https://github.com/zfsonlinux/zfs
Copy Working Kernel Config and Prepare
cd ./linux-stable
cp /boot/config-"$(uname -r)" .config
yes '' | make oldconfig
make prepare scripts
Configure and Build SPL
cd ~/src/spl
git checkout master
sh autogen.sh
./configure --prefix=/ --libdir=/lib --includedir=/usr/include --datarootdir=/usr/share --enable-linux-builtin=yes --with-linux=/home/<username>/src/linux-stable --with-linux-obj=/home/<username>/src/linux-stable
./copy-builtin /home/<username>/src/linux-stable
make
sudo make install
Configure and Build ZFS
cd ~/src/zfs
git checkout master
sh autogen.sh
./configure --prefix=/ --libdir=/lib --includedir=/usr/include --datarootdir=/usr/share --enable-linux-builtin=yes --with-linux=/home/<username>/src/linux-stable --with-linux-obj=/home/<username>/src/linux-stable --with-spl=/home/<username>/src/spl --with-spl-obj=/home/<username>/src/spl
./copy-builtin /home/<username>/src/linux-stable
make
sudo make install
Enable SPL/ZFS & Build The Kernel
cd ~/src/linux-stable
make menuconfig
Enable the following (pressing 'Y' to include)
Then navigate into "File systems" and activate ZFS.
Press tab to navigate to "Exit" and press enter. Then press tab to navigate to "Save" and press enter overriding ".config". Then press tab to navigate to "Exit" and press enter to exit.
make clean
make -j <number of CPU cores> deb-pkg LOCALVERSION=-custom
Install Kernel DEB Packages
NOTE: Prior to installing the kernel, do a ZFS snapshot of your operating system. If the system becomes unbootable, boot up a live CD/USB and do a rollback.
Inside the 'src' directory should be several installable DEB packages. Install them one-by-one with the following commands:cd ..
sudo dpkg -i linux-firmware-image-4.12.1-custom_4.12.1-custom-1_amd64.deb
sudo dpkg -i linux-libc-dev_4.12.1-custom-1_amd64.deb
sudo dpkg -i linux-headers-4.12.1-custom_4.12.1-custom-1_amd64.deb
sudo dpkg -i linux-image-4.12.1-custom-dbg_4.12.1-custom-1_amd64.deb
sudo dpkg -i linux-image-4.12.1-custom_4.12.1-custom-1_amd64.deb
Reboot and you should be on the latest LInux kernel with ZFS support.
Resources
https://github.com/zfsonlinux/zfs/wiki/Ubuntu-16.10-Root-on-ZFS
https://www.maketecheasier.com/build-custom-kernel-ubuntu/
https://github.com/zfsonlinux/zfs/wiki/Building-ZFS
http://www.linuxquestions.org/questions/linux-from-scratch-13/%5Bhow-to%5D-add-zfs-to-the-linux-kernel-4175514510/