{"id":787,"date":"2015-01-01T14:31:10","date_gmt":"2015-01-01T22:31:10","guid":{"rendered":"http:\/\/blog.ls-al.com\/?p=787"},"modified":"2015-03-18T12:45:18","modified_gmt":"2015-03-18T19:45:18","slug":"ubuntu-on-a-zfs-root-file-system-for-ubuntu-15-04","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/ubuntu-on-a-zfs-root-file-system-for-ubuntu-15-04\/","title":{"rendered":"Ubuntu On a ZFS Root File System for Ubuntu 15.04"},"content":{"rendered":"

Start Update 03.18.15:<\/strong>
\nThis 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.
\nEnd Update 03.18.15:<\/strong><\/p>\n

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.<\/p>\n

Previous articles:<\/span>
\nhttp:\/\/blog.ls-al.com\/ubuntu-on-a-zfs-root-file-system-for-ubuntu-14-04\/
\nhttp:\/\/blog.ls-al.com\/booting-ubuntu-on-a-zfs-root-file-system\/<\/p>\n

SYSTEM REQUIREMENTS<\/span>
\n64-bit Ubuntu Live CD. (Not the alternate or 32-bit installer)
\nAMD64 or EM64T compatible computer. (ie: x86-64)
\n15GB disk,\u00a02GB memory minimum,\u00a0Virtualbox
\nCreate new VM. I use bridged networking in case I want to use ssh during the setup.
\nStart the Ubuntu LiveCD and open a terminal at the desktop. I used the 15.04 64-bit alpha CD.
\nControl-F1 to first text terminal.<\/p>\n

1. Setup repo.<\/span><\/p>\n

\r\n$ sudo -i\r\n# \/etc\/init.d\/lightdm stop\r\n# apt-add-repository --yes ppa:zfs-native\/stable\r\n<\/pre>\n

** Change \/etc\/apt\/sources.list.d\/... down to trusty. Or utopic possibly. I did not test.<\/span><\/p>\n

2. Install zfs.<\/span><\/p>\n

\r\n# apt-get update\r\n# apt-get install debootstrap ubuntu-zfs\r\n# dmesg | grep ZFS:\r\n[ 3900.114234] ZFS: Loaded module v0.6.3-4~trusty, ZFS pool version 5000, ZFS filesystem version 5\r\n<\/pre>\n

** takes a long time to compile initial module for 3.16.0-28-generic<\/span><\/em><\/p>\n

3. Install ssh. <\/span><\/p>\n

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.<\/em><\/span><\/p>\n

\r\n# apt-get install ssh\r\n# \/etc\/init.d\/ssh start\r\n# \/usr\/sbin\/sshd\r\n<\/pre>\n

** check with ps if ssh process is running<\/em><\/span>
\n ** edit sshd_config and allow root login<\/em><\/span>
\n ** set root passwd<\/em><\/span><\/p>\n

4. Setup disk partitions.<\/span><\/p>\n

\r\n# fdisk -l\r\nDisk \/dev\/loop0: 1 GiB, 1103351808 bytes, 2154984 sectors\r\nUnits: sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 512 bytes\r\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\r\nDisk \/dev\/sda: 15 GiB, 16106127360 bytes, 31457280 sectors\r\nUnits: sectors of 1 * 512 = 512 bytes\r\nSector size (logical\/physical): 512 bytes \/ 512 bytes\r\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\r\nDisklabel type: dos\r\nDisk identifier: 0xc2c7def9\r\n\r\nDevice Boot Start End Sectors Size Id Type\r\n\/dev\/sda1 2048 411647 409600 200M be Solaris boot\r\n\/dev\/sda2 411648 31457279 31045632 14.8G bf Solaris\r\n<\/pre>\n

5. Format partitions.<\/span><\/p>\n

\r\n# mke2fs -m 0 -L \/boot\/grub -j \/dev\/disk\/by-id\/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part1\r\n# zpool create -o ashift=9 rpool \/dev\/disk\/by-id\/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part2\r\n<\/pre>\n

6. ZFS Setup and Mountpoints.<\/span><\/p>\n

\r\n# zpool create -o ashift=9 rpool \/dev\/disk\/by-id\/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part2\r\n# zfs create rpool\/ROOT\r\n# zfs create rpool\/ROOT\/ubuntu-1\r\n# zfs umount -a\r\n# zfs set mountpoint=\/ rpool\/ROOT\/ubuntu-1\r\n# zpool set bootfs=rpool\/ROOT\/ubuntu-1 rpool\r\n# zpool export rpool\r\n# zpool import -d \/dev\/disk\/by-id -R \/mnt rpool\r\n# mkdir -p \/mnt\/boot\/grub\r\n# mount \/dev\/disk\/by-id\/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part1 \/mnt\/boot\/grub\r\n<\/pre>\n

7. Install Ubuntu 15.04 on \/mnt<\/span><\/p>\n

\r\n# debootstrap vivid \/mnt\r\nI: Retrieving Release\r\n...\r\nI: Base system installed successfully.\r\n\r\n# cp \/etc\/hostname \/mnt\/etc\/\r\n# cp \/etc\/hosts \/mnt\/etc\/\r\n# vi \/mnt\/etc\/fstab\r\n# cat \/mnt\/etc\/fstab\r\n\/dev\/disk\/by-id\/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part1 \/boot\/grub auto defaults 0 1\r\n\r\n# cat \/mnt\/etc\/network\/interfaces\r\n# interfaces(5) file used by ifup(8) and ifdown(8)\r\n# Include files from \/etc\/network\/interfaces.d:\r\nsource-directory \/etc\/network\/interfaces.d\r\nauto lo\r\niface lo inet loopback\r\n\r\nauto eth0\r\niface eth0 inet dhcp\r\n<\/pre>\n

8. Setup chroot to update and install ubuntu-minimal<\/span><\/p>\n

\r\n# mount --bind \/dev \/mnt\/dev\r\n# mount --bind \/proc \/mnt\/proc\r\n# mount --bind \/sys \/mnt\/sys\r\n# chroot \/mnt \/bin\/bash --login\r\n# locale-gen en_US.UTF-8\r\n\r\n# apt-get update\r\n# apt-get install ubuntu-minimal software-properties-common\r\n<\/pre>\n

9. Setup ZOL repo<\/span><\/p>\n

\r\n# apt-add-repository --yes ppa:zfs-native\/stable\r\n<\/pre>\n

** leave grub repo off for now.<\/span><\/em><\/p>\n

\r\n# cat \/etc\/apt\/sources.list.d\/zfs-native-ubuntu-stable-vivid.list\r\ndeb http:\/\/ppa.launchpad.net\/zfs-native\/stable\/ubuntu trusty main\r\n# deb-src http:\/\/ppa.launchpad.net\/zfs-native\/stable\/ubuntu vivid main\r\n# apt-get update\r\n# apt-get install --no-install-recommends linux-image-generic linux-headers-generic\r\n\r\n# apt-get install ubuntu-zfs\r\n<\/pre>\n

** skipped grub stuff for this pass<\/span><\/em><\/p>\n

\r\n# apt-get install zfs-initramfs\r\n# apt-get dist-upgrade\r\n<\/pre>\n

10. Make sure root has access<\/span><\/p>\n

\r\n# passwd root\r\n<\/pre>\n

11. Test grub<\/span><\/p>\n

\r\n# grub-probe \/\r\nbash: grub-probe: command not found\r\n<\/pre>\n

12. Use older patched grub from ZOL project<\/span><\/p>\n

\r\n# apt-add-repository --yes ppa:zfs-native\/grub\r\ngpg: keyring `\/tmp\/tmp5urr4u7g\/secring.gpg' created\r\ngpg: keyring `\/tmp\/tmp5urr4u7g\/pubring.gpg' created\r\ngpg: requesting key F6B0FC61 from hkp server keyserver.ubuntu.com\r\ngpg: \/tmp\/tmp5urr4u7g\/trustdb.gpg: trustdb created\r\ngpg: key F6B0FC61: public key "Launchpad PPA for Native ZFS for Linux" imported\r\ngpg: Total number processed: 1\r\ngpg: imported: 1 (RSA: 1)\r\nOK\r\n\r\n# cat \/etc\/apt\/sources.list.d\/zfs-native-ubuntu-grub-vivid.list\r\ndeb http:\/\/ppa.launchpad.net\/zfs-native\/grub\/ubuntu raring main\r\n\r\n# apt-get install grub2-common grub-pc\r\nInstallation finished. No error reported.\r\n\/usr\/sbin\/grub-probe: error: failed to get canonical path of `\/dev\/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part2'.\r\n<\/pre>\n

** As you can see grub has issues with dev path.<\/span><\/em><\/p>\n

\r\n# ln -s \/dev\/disk\/by-id\/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part2 \/dev\/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52-part2\r\n# apt-get install grub2-common grub-pc\r\n\r\n# grub-probe \/\r\nzfs\r\n# ls \/boot\/grub\/i386-pc\/zfs*\r\n\/boot\/grub\/i386-pc\/zfscrypt.mod \/boot\/grub\/i386-pc\/zfsinfo.mod \/boot\/grub\/i386-pc\/zfs.mod\r\n<\/pre>\n

** Note at the end I show a udev rule that can help work around this path issue.<\/span><\/em><\/p>\n

\r\n# update-initramfs -c -k all\r\n\r\n# grep "boot=zfs" \/boot\/grub\/grub.cfg\r\nlinux \/ROOT\/ubuntu-1@\/boot\/vmlinuz-3.16.0-28-generic root=ZFS=rpool\/ROOT\/ubuntu-1 ro boot=zfs quiet splash $vt_handoff\r\n\r\n# grep "boot=zfs" \/etc\/default\/grub\r\nGRUB_CMDLINE_LINUX_DEFAULT="quiet splash boot=zfs"\r\n\r\n# update-grub\r\nGenerating grub configuration file ...\r\nWarning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.\r\nFound linux image: \/boot\/vmlinuz-3.16.0-28-generic\r\nFound initrd image: \/boot\/initrd.img-3.16.0-28-generic\r\ndone\r\n\r\n# grub-install $(readlink -f \/dev\/disk\/by-id\/ata-VBOX_HARDDISK_VBf3c0d5ba-e6881c52)\r\nInstalling for i386-pc platform.\r\nInstallation finished. No error reported.\r\n\r\n# exit\r\nlogout\r\n<\/pre>\n

13. unmount chroot and shutdown<\/span><\/p>\n

\r\n# umount \/mnt\/boot\/grub\r\n# umount \/mnt\/dev\r\n# umount \/mnt\/proc\r\n# umount \/mnt\/sys\r\n# zfs umount -a\r\n# zpool export rpool\r\n# init 0\r\n<\/pre>\n

14. Cleanup and finish<\/span>
\n** Create snapshot<\/em>
\n ** bootup<\/em>
\n ** install ssh and configure root to login in sshd_config, restart ssh<\/em><\/p>\n

15. udev rule for grub bug<\/span><\/p>\n

\r\n# cat \/etc\/udev\/rules.d\/70-zfs-grub-fix.rules\r\nENV{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"\r\n\r\n# \/etc\/init.d\/udev restart\r\n<\/pre>\n

16. install desktop software<\/span><\/p>\n

\r\n# apt-get install ubuntu-desktop\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

Start Update 03.18.15: This is untested but I suspect if you are upgrading the kernel to 3.19.0 and you have<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31,30],"tags":[],"class_list":["post-787","post","type-post","status-publish","format-standard","hentry","category-ubuntu","category-zfs"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/787","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=787"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/787\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=787"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=787"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}