Native ZFS + rootfs + GPT on Gentoo

Step by step:

  • Boot install CD (i.e. Gentoo 12.1 LiveDVD)
  • Parted disk using gpt mode (i.e. GPTFDISK, make sure "BIOS boot partition" being parted, zfs partition set type "Solaris zfs")
  • create zpool and zfs partitions
zpool create -f -o ashift=12 -o cachefile=/tmp/zpool.cache -O normalization=formD -m none -R /mnt/gentoo zdisk /dev/sda2
zfs create -o mountpoint=none zdisk/ROOT
zfs create -o mountpoint=/ zdisk/ROOT/gentoo
zfs create -o mountpoint=/home zdisk/HOME
zfs create -o mountpoint=none zdisk/PORTS
zfs create -o mountpoint=/usr/portage zdisk/PORTS/portage
zfs create -o mountpoint=/usr/portage/distfiles zdisk/PORTS/portage/distfiles
zfs create -o sync=always -o primarycache=metadata -o secondarycache=none -V 8G zdisk/swap
  • config and chroot
ifconfig eth* ?.?.?.? broadcast ?.?.?.? netmask ?.?.?.? up
route add default gw ?.?.?.?
vi /etc/resolv.conf
tar -xf stage3-amd64-*.tar.bz2 -C /mnt/gentoo
mkdir -p /mnt/gentoo/etc/zfs
cp /tmp/zpool.cache /mnt/gentoo/etc/zfs/zpool.cache
cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
mount -t proc none /mnt/gentoo/proc
mount --rbind /dev /mnt/gentoo/dev
mount --rbind /sys /mnt/gentoo/sys
chroot /mnt/gentoo /bin/bash
env-update; source /etc/profile; export PS1="(chroot) $PS1"; cd
  • instasll softs and make genkernel (attention: zfs supported latest kernel is 3.11 now)
echo "GENTOO_MIRRORS=""" >> /etc/make.conf
emerge --sync
emerge -avuDN world
echo "ACCEPT_KEYWORDS=~amd64" >> /etc/make.conf
emerge sys-kernel/genkernel
emerge =sys-kernel/gentoo-sources-3.11.*
genkernel kernel --no-clean --no-mountboot
emerge sys-fs/zfs
rc-update add zfs boot
  • export and import zpool for instlling grub2
umount -l /mnt/gentoo/proc /mnt/gentoo/dev /mnt/gentoo/sys
zpool export zdisk
zpool import -f -o cachefile=/tmp/zpool.cache -R /mnt/gentoo zdisk
mount -t proc none /mnt/gentoo/proc
mount --rbind /dev /mnt/gentoo/dev
mount --rbind /sys /mnt/gentoo/sys
chroot /mnt/gentoo /bin/bash
env-update; source /etc/profile; export PS1="(chroot) $PS1"; cd
  • install grub2 and make initramfs
echo "sys-boot/grub libzfs" >> /etc/portage/package.use
emerge sys-boot/grub
touch /etc/mtab
grub2-install /dev/sda
emerge module-rebuild
genkernel all --no-clean --no-mountboot --zfs --bootloader=grub2 --callback="module-rebuild rebuild"
grub2-mkconfig -o /boot/grub/grub.cfg
  • config your new gentoo system, press here
  • Possible errors and solutions
when installing grub appears perl error, run command "perl-cleaner --all"
when rebooting system appears kernel panic, edit grub.cfg and add "dozfs=force" after "root=ZFS=zdisk/ROOT/gentoo"
  • If you can, Customize initramfs
xz -dc initramfs_name | cpio -id
find . | cpio -c -o | xz -9 --format=lzma > initramfs_name


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: