Installing Arch Linux on ZFS
This tutorial will show you how to install Arch Linux (Your / partition) on ZFS.
Installing Arch Linux on a regular filesystem
1. Install Arch Linux to wherever you want as normal
2. Compile a custom kernel (with everything needed to boot built into the kernel and with ZLIB_DEFLATE support)
3. Compile the zfs/spl rc9 from the aur with kylef's PKGBUILD. https://aur.archlinux.org/packages.php?ID=41045 Modify the PKGBUILD so that the ./configure has --with-linux=/usr/src/linux --with-linux-obj=/usr/src/linux
4. Install the spl/zfs packages
5. Install git and cpio
pacman -S git cpio
6. Clone my zfs initramfs creator and make a new initramfs
git clone git://github.com/fearedbliss/Bliss-Initramfs-Creator.git cd Bliss-Initramfs-Creator git checkout archlinux ./createInit ^^ # Follow the instructions and copy the ZFS file to your /boot afterwards cp ZFS-kernel-version.img /boot/initramfs-zfs.img
Back up Arch Linux via stage5
cd / tar --exclude proc --exclude tmp --exclude var/cache/pacman/pkg --exclude sys -cvvpf stage5-arch.tar .
- Compress the stage5 if you want to with pbzip2 (dont use bzip2.. it will take a much longer time, use pbzip2 if you have a multicore system)
- Save this file somewhere because we will be moving it to our new installation afterwards (stage5-arch.tar.bz2)
(Note, you will need to remake the proc, tmp, and sys directories after you extract it onto the ZFS system)
- edit your fstab to remove old mountpoints
- add zfs to rc.d
vim /etc/rc.conf (and add zfs to your daemons)
New install with ZFS as the filesystem
In order to partition the system, I was using system rescue cd v2.5.1. The reason I'm using 2.5.1 is because it's the last version that had the native ZFS on Linux modules. Any version before or later does not have them. Since the link for 2.5.1 was removed from the author's website, I recommend you to use the Gentoo Live DVD 2012. http://torrents.gentoo.org/ , download the `livedvd-amd64-multilib-2012.1`.
Our system will be using GPT as the base and extlinux as the bootloader.
The layout will look like this:
/dev/sda1 Linux FS 250M /dev/sda2 bf01 Rest of Disk
- Create ZFS Pool and Mountpoints
zpool create -o ashift=12 -o cachefile= -O normalization=formD -R /mnt/custom rpool /dev/sda2 zfs create -o mountpoint=none rpool/ROOT zfs create -o mountpoint=/ rpool/ROOT/arch zfs create -o mountpoint=/home rpool/HOME zfs create -o mountpoint=/root rpool/HOME/root
- Mount /boot partition in the zfs /
mkdir /mnt/custom/boot mount /dev/sda1 /mnt/custom/boot
- Extract Arch Stage5 (Preloaded with ZFS modules and your own kernel)
- Change into the directory
Install Extlinux bootloader
- Bind proc in the chroot env before chroot so that extlinux can find the correct device
mount --bind /proc ./proc env HOME=/root TERM=$TERM chroot . /bin/bash --login mkdir /boot/extlinux extlinux --install /boot/extlinux
- Set correct boot flags in the GPT legacy bios and then flash mbrgpt
sgdisk /dev/sda --attributes=1:set:2 sgdisk /dev/sda --atributes=1:show dd count=1 bs=440 conv=notrunc if=/usr/lib/syslinux/gptmbr.bin of=/dev/sda
- Make an extlinux.conf
cd /boot/extlinux vim extlinux.conf
Inside extlinux.conf put the following
PROMPT 0 TIMEOUT 50 UI menu.c32 MENU TITLE Boot Menu DEFAULT arch LABLE Arch MENU LABEL Arch [ZFS] LINUX /kernel-thatyoucompiled INITRD /initramfs-zfs.img
and save it.
That's it, restart your computer and you should be inside Arch on ZFS :)!