Ubuntu root on zfs upgrading kernels
title: 'Ubuntu root on ZFS upgrading kernels'
title: 'Ubuntu root on ZFS upgrading kernels' date: '2013-06-11T02:16:08-05:00' status: publish permalink: /ubuntu-root-on-zfs-upgrading-kernels author: admin excerpt: '' type: post id: 341 category: - Linux - Ubuntu - ZFS tag:  post_format: 
On a subsequent kernel upgrade to 22.214.171.124 I realized that the zfs modules are getting compiled just fine when the kernel is upgraded. On Ubuntu 13.04 anyhow. So all you need to do is fix the grub.cfg file because of the bug mentioned below where "/ROOT/ubuntu-1@" is inserted twice. Quick fix you could use sed but be careful to verify your temporary file before copying in place:
# sed 's/\/ROOT\/ubuntu-1\/@//g' /boot/grub/grub.cfg > /tmp/grub.cfg # cp /tmp/grub.cfg /boot/grub/grub.cfg
I left the rest of the initial post below in case I ever need to really boot with a live CD and redo kernel modules from scratch. Or maybe that would also work for upgrading the zfs modules from git I suppose.
Original post below:
This is a follow on to my running Ubuntu on a ZFS root file system http://blog.ls-al.com/booting-ubuntu-on-a-zfs-root-file-system/ article. I decided to document how to do a kernel upgrade in this configuration. It serves two scenarios A) user decided kernel upgrade or B) accidentally upgraded the kernel and now I can't boot any longer. I wish I could say I wrote this article in response to number 1 but no it was in response to number 2.
In this case the kernel was upgraded from 126.96.36.199 to 188.8.131.52.
Boot a live cd to start.
Install zfs module:
$ sudo -i # /etc/init.d/lightdm stop # apt-add-repository --yes ppa:zfs-native/stable # apt-get update # apt-get install debootstrap ubuntu-zfs # modprobe zfs # dmesg | grep ZFS: ZFS: Loaded module v0.6.1-rc14, ZFS pool version 5000, ZFS filesystem version 5
Import pool, mount and chroot:
# zpool import -d /dev/disk/by-id -R /mnt rpool # mount /dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBb59e0ffb-68fb0252-part1 /mnt/boot/grub # mount --bind /dev /mnt/dev # mount --bind /proc /mnt/proc # mount --bind /sys /mnt/sys # chroot /mnt /bin/bash --login
# locale-gen en_US.UTF-8 # apt-get update # apt-get dist-upgrade
** At this point remove any old kernels manually if you want.
# grub-probe / zfs # ls /boot/grub/i386-pc/zfs* /boot/grub/i386-pc/zfs.mod /boot/grub/i386-pc/zfsinfo.mod # update-initramfs -c -k all # update-grub # grep boot=zfs /boot/grub/grub.cfg
** Currently a bug in the Ubuntu 13.04 grub scripts. Look at boot lines there is a duplicated string /ROOT/ubuntu-1/@/ROOT/ubuntu-1@/ in there.
According to https://github.com/zfsonlinux/zfs/issues/1441 it can be fixed with grub-install below. That did not work for me though I fixed it manually.
# grub-install $(readlink -f /dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBb59e0ffb-68fb0252) Installation finished. No error reported.
Unmount and reboot:
# umount /mnt/boot/grub # umount /mnt/dev # umount /mnt/proc # umount /mnt/sys # zfs umount -a # zpool export rpool