Ubuntu On a ZFS Root File System for Ubuntu 15.04
Start Update 03.18.15:
This is untested but I suspect if you are upgrading the kernel to 3.19.0 and you have issues you may need to change to the daily Vivid ppa. In my initial post I used stable and Utopic since Vivid was very new.
End Update 03.18.15:
This is what I did to make an Ubuntu 15.04 virtualbox guest (works for Ubuntu 14.10 also) boot with the ZFS file system.
Previous articles:
http://blog.ls-al.com/ubuntu-on-a-zfs-root-file-system-for-ubuntu-14-04/
http://blog.ls-al.com/booting-ubuntu-on-a-zfs-root-file-system/
SYSTEM REQUIREMENTS
64-bit Ubuntu Live CD. (Not the alternate or 32-bit installer)
AMD64 or EM64T compatible computer. (ie: x86-64)
15GB disk, 2GB memory minimum, Virtualbox
Create new VM. I use bridged networking in case I want to use ssh during the setup.
Start the Ubuntu LiveCD and open a terminal at the desktop. I used the 15.04 64-bit alpha CD.
Control-F1 to first text terminal.
1. Setup repo.
$ sudo -i # /etc/init.d/lightdm stop # apt-add-repository --yes ppa:zfs-native/stable
** Change /etc/apt/sources.list.d/... down to trusty. Or utopic possibly. I did not test.
2. Install zfs.
# apt-get update # apt-get install debootstrap ubuntu-zfs # dmesg | grep ZFS: [ 3900.114234] ZFS: Loaded module v0.6.3-4~trusty, ZFS pool version 5000, ZFS filesystem version 5
** takes a long time to compile initial module for 3.16.0-28-generic
3. Install ssh.
Using a ssh terminal makes it easier to copy and paste for both command execution and documentation. However with this bare bones environment at this point openssh might not install very clean. I played with it a little to get at least sshd to run.
# apt-get install ssh # /etc/init.d/ssh start # /usr/sbin/sshd
** check with ps if ssh process is running
** edit sshd_config and allow root login
** set root passwd
4. Setup disk partitions.
# fdisk -l Disk /dev/loop0: 1 GiB, 1103351808 bytes, 2154984 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/sda: 15 GiB, 16106127360 bytes, 31457280 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xc2c7def9 Device Boot Start End Sectors Size Id Type /dev/sda1 2048 411647 409600 200M be Solaris boot /dev/sda2 411648 31457279 31045632 14.8G bf Solaris
5. Format partitions.
# mke2fs -m 0 -L /boot/grub -j /dev/disk/by-id/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part1 # zpool create -o ashift=9 rpool /dev/disk/by-id/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part2
6. ZFS Setup and Mountpoints.
# zpool create -o ashift=9 rpool /dev/disk/by-id/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part2 # zfs create rpool/ROOT # zfs create rpool/ROOT/ubuntu-1 # zfs umount -a # zfs set mountpoint=/ rpool/ROOT/ubuntu-1 # zpool set bootfs=rpool/ROOT/ubuntu-1 rpool # zpool export rpool # zpool import -d /dev/disk/by-id -R /mnt rpool # mkdir -p /mnt/boot/grub # mount /dev/disk/by-id/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part1 /mnt/boot/grub
7. Install Ubuntu 15.04 on /mnt
# debootstrap vivid /mnt I: Retrieving Release ... I: Base system installed successfully. # cp /etc/hostname /mnt/etc/ # cp /etc/hosts /mnt/etc/ # vi /mnt/etc/fstab # cat /mnt/etc/fstab /dev/disk/by-id/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part1 /boot/grub auto defaults 0 1 # cat /mnt/etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) # Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp
8. Setup chroot to update and install ubuntu-minimal
# 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 install ubuntu-minimal software-properties-common
9. Setup ZOL repo
# apt-add-repository --yes ppa:zfs-native/stable
** leave grub repo off for now.
# cat /etc/apt/sources.list.d/zfs-native-ubuntu-stable-vivid.list deb http://ppa.launchpad.net/zfs-native/stable/ubuntu trusty main # deb-src http://ppa.launchpad.net/zfs-native/stable/ubuntu vivid main # apt-get update # apt-get install --no-install-recommends linux-image-generic linux-headers-generic # apt-get install ubuntu-zfs
** skipped grub stuff for this pass
# apt-get install zfs-initramfs # apt-get dist-upgrade
10. Make sure root has access
# passwd root
11. Test grub
# grub-probe / bash: grub-probe: command not found
12. Use older patched grub from ZOL project
# apt-add-repository --yes ppa:zfs-native/grub gpg: keyring `/tmp/tmp5urr4u7g/secring.gpg' created gpg: keyring `/tmp/tmp5urr4u7g/pubring.gpg' created gpg: requesting key F6B0FC61 from hkp server keyserver.ubuntu.com gpg: /tmp/tmp5urr4u7g/trustdb.gpg: trustdb created gpg: key F6B0FC61: public key "Launchpad PPA for Native ZFS for Linux" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) OK # cat /etc/apt/sources.list.d/zfs-native-ubuntu-grub-vivid.list deb http://ppa.launchpad.net/zfs-native/grub/ubuntu raring main # apt-get install grub2-common grub-pc Installation finished. No error reported. /usr/sbin/grub-probe: error: failed to get canonical path of `/dev/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part2'.
** As you can see grub has issues with dev path.
# ln -s /dev/disk/by-id/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part2 /dev/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part2 # apt-get install grub2-common grub-pc # grub-probe / zfs # ls /boot/grub/i386-pc/zfs* /boot/grub/i386-pc/zfscrypt.mod /boot/grub/i386-pc/zfsinfo.mod /boot/grub/i386-pc/zfs.mod
** Note at the end I show a udev rule that can help work around this path issue.
# update-initramfs -c -k all # grep "boot=zfs" /boot/grub/grub.cfg linux /ROOT/ubuntu-1@/boot/vmlinuz-3.16.0-28-generic root=ZFS=rpool/ROOT/ubuntu-1 ro boot=zfs quiet splash $vt_handoff # grep "boot=zfs" /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT="quiet splash boot=zfs" # update-grub Generating grub configuration file ... Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. Found linux image: /boot/vmlinuz-3.16.0-28-generic Found initrd image: /boot/initrd.img-3.16.0-28-generic done # grub-install $(readlink -f /dev/disk/by-id/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52) Installing for i386-pc platform. Installation finished. No error reported. # exit logout
13. unmount chroot and shutdown
# umount /mnt/boot/grub # umount /mnt/dev # umount /mnt/proc # umount /mnt/sys # zfs umount -a # zpool export rpool # init 0
14. Cleanup and finish
** Create snapshot
** bootup
** install ssh and configure root to login in sshd_config, restart ssh
15. udev rule for grub bug
# cat /etc/udev/rules.d/70-zfs-grub-fix.rules ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*", ENV{ID_FS_TYPE}=="zfs_member", SYMLINK+="$env{ID_BUS}-$env{ID_SERIAL} $env{ID_BUS}-$env{ID_SERIAL}-part%n" # /etc/init.d/udev restart
16. install desktop software
# apt-get install ubuntu-desktop