summaryrefslogtreecommitdiffstats
path: root/server/setup
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-06-04 04:51:26 +0200
committerSven Gothel <[email protected]>2013-06-04 04:51:26 +0200
commit3d29685ac14d29b0f0e49a8401028c74c3e26d7a (patch)
treed12b8fb1f5f4de55000e9c69d20375bffb8c34e7 /server/setup
parentedc22ed546513910e87a93acebece75882be951d (diff)
Add initial Debian 7.00 Server Setup w/ ZFS
Diffstat (limited to 'server/setup')
-rw-r--r--server/setup/zfs_linux_bringup/README.txt377
-rw-r--r--server/setup/zfs_linux_bringup/apt-install-zfs_kernel_etc.sh11
-rw-r--r--server/setup/zfs_linux_bringup/apt-sources.list15
-rw-r--r--server/setup/zfs_linux_bringup/chroot-chroot.sh3
-rw-r--r--server/setup/zfs_linux_bringup/chroot-mount.sh5
-rw-r--r--server/setup/zfs_linux_bringup/chroot-umount.sh5
-rw-r--r--server/setup/zfs_linux_bringup/etc_fstab.txt3
-rw-r--r--server/setup/zfs_linux_bringup/grub_custom.cfg27
-rw-r--r--server/setup/zfs_linux_bringup/initramfs-tools.scripts.zfs163
-rw-r--r--server/setup/zfs_linux_bringup/zfs01-create_config-pool.sh17
-rw-r--r--server/setup/zfs_linux_bringup/zfs02-create-datasets.sh12
-rw-r--r--server/setup/zfs_linux_bringup/zfs03-export_import.sh11
-rw-r--r--server/setup/zfs_linux_bringup/zfs04-system-populate.sh14
13 files changed, 663 insertions, 0 deletions
diff --git a/server/setup/zfs_linux_bringup/README.txt b/server/setup/zfs_linux_bringup/README.txt
new file mode 100644
index 0000000..2eac52f
--- /dev/null
+++ b/server/setup/zfs_linux_bringup/README.txt
@@ -0,0 +1,377 @@
+GNU/Linux Debian Wheezy Server Bringup w/ ZFS
+
+2013 May 30th
+
+Sven Gothel
+JogAmp Community
+Creative Commons Attribution 3.0 License. http://creativecommons.org/licenses/by/3.0/
+
++++
+
+Small Pool:
+ 1x ZPool
+ 1x VDEV 2x n TB raidz1 ( 1 + 1 )
+
+ or better
+
+ 1x Mirror
+ 1x VDEV 2x n TB mirror ( 1 + 1 )
+
+
+Big Pool:
+ 1x ZPool
+ 2x VDEV 2x n TB raidz1 ( 1 + 1 )
+
++++
+
+Tuning:
+ - no dedup (huge memory consumption / performance)
+ - no compression (cheap .. but why ?)
+ - max ARC cache .. 50/50 ?
+ - http://www.solarisinternals.com/wiki/index.php/ZFS_Evil_Tuning_Guide#Limiting_the_ARC_Cache
+ arc_c_min= (16MB?)
+ arc_c_max= 17179869184 (16GB) (50% of 32GB)
+ arc.c = arc.c_max
+ arc.p = arc.c / 2
+ or
+ # ARC: 512MB - 12 GB
+ echo options zfs zfs_arc_min=536870912 zfs_arc_max=12884901888 >> /etc/modprobe.d/zfs.conf
+
+ 17179869184 # 0x400000000 (16 GB)
+ 12884901888 # 0x300000000 (12 GB)
+ 8589934592 # 0x200000000 ( 8 GB)
+ 4294967296 # 0x100000000 ( 4 GB)
+ 1073741824 # 0x040000000 ( 1 GB)
+ 536870912 # 0x020000000 (.5 GB)
+
+ - Dedup Ram: 5GB of RAM per Terrabyte of storage ?
+ - Advanced Format 4096 byte blocks -> ashift=12 ?!
+
+ echo options zfs zfs_arc_min=536870912 zfs_arc_max=8589934592 >> /etc/modprobe.d/zfs.conf
+
++++
+
+Install:
+
+ 1 Boot in Debian Rescue mode
+ 1.0 Install on USB drive
+ - No DESKTOP, ..
+ - Leave 1-2GB available for extra ext4 boot partition
+ to mitigate grub's lack of ZFS support!!
+
+ /dev/sdc USB drive
+ /dev/sdc1 root
+ /dev/sdc2 boot2
+
+ 1.1 Network Setup ..
+ 1.1.1 Manual Setup /etc/network/interfaces
+ auto lo
+ iface lo inet loopback
+
+ auto eth0
+ iface eth0 inet static
+ address a.b.c.d
+ netmask 255.255.255.255
+ dns-nameservers a.b.c.d 1.2.3.4 5.6.7.8
+ gateway 1.2.3.4
+ iface eth0 inet6 static
+ address a:b:c:d:::1:1
+ netmask 64
+ up ip -6 route add fe80::1 dev eth0
+ down ip -6 route del fe80::1 dev eth0
+ up ip -6 route add default via fe80::1 dev eth0
+ down ip -6 route del default via fe80::1 dev eth0
+
+ - echo jogamp.org > /etc/hostname
+
+
+ 2 Boot USB drive
+ 2.0 Old md superblock ?
+ Example: /dev/sdb is autodetected as md0:
+ - mdadm --manage --stop /dev/md0
+ - mdadm --zero-superblock /dev/sdb
+
+ 2.1 Fix /etc/apt/sources.list
+ - remove dvd driver
+ - add 'wheezy main contrib non-free' net source
+ - cp -a apt-sources.list /etc/apt/sources.list
+
+ 'apt-sources.list':
+ deb http://ftp.debian.org/debian/ wheezy main contrib non-free
+ deb-src http://ftp.debian.org/debian/ wheezy main contrib non-free
+
+ deb http://security.debian.org/ wheezy/updates main contrib
+ deb-src http://security.debian.org/ wheezy/updates main contrib
+
+ deb http://ftp.de.debian.org/debian/ wheezy-updates main contrib non-free
+ deb-src http://ftp.de.debian.org/debian/ wheezy-updates main contrib non-free
+
+ 2.2 Install ZFS on USB drive (Script './apt-install-zfs_kernel_etc.sh'):
+ - wget http://archive.zfsonlinux.org/debian/pool/main/z/zfsonlinux/zfsonlinux_1%7Ewheezy_all.deb
+ - dpkg -i zfsonlinux_1~wheezy_all.deb
+ - apt-get update
+ - apt-get upgrade
+ - apt-get install linux-base linux-image-amd64 linux-headers-amd64 util-linux
+ - apt-get install debian-zfs libzfs-dev
+ - apt-get install zfs-initramfs
+ - apt-get install vim
+
+ 2.3 Gather some specs ..
+ - Gather hdd UUIDs
+ - $ ls -l /dev/disk/by-uuid
+ lrwxrwxrwx 1 root root 10 11. Okt 18:02 53cdad3b-4b01-4a6c-a099-be1cdf1acf6d -> ../../sda2
+
+ - Check whether hdd uses Advanced Formating, i.e. blk size 4096 instead of 512.
+ - apt-get install smartmontools
+ - smartctl -a /dev/sda, .. etc .. see whether (Adv. Format) is listed
+ - if any disk uses Adv. Format -> "zfs create -o ashift=12 jogamp07 .."
+
+ However, to be future-proof, it is recommended to always use 4096 block size for ZFS.
+ You won't be able to change your pool later.
+
+ 2.4 Config zfs on sda sdb
+ - Below we use 'jogamp07' as the zfs pool name,
+ it's best to replace it w/ a meaningful name, i.e. your hostname.
+
+ Below is scripted in './zfs01-create_config-pool.sh' (using jogamp07 as pool name)
+
+ - Create zpool
+ - mirror: if cheap redundancy is more important than size and disks == 2
+ - zpool create -f -o ashift=12 jogamp07 mirror /dev/disk/by-id/uuid1 /dev/disk/by-id/uuid2
+ - .. else zraid:
+ - zpool create -f -o ashift=12 jogamp07 raidz1 /dev/disk/by-id/ata...
+ - -f -> overwrite existing partition table / data
+ - ashift=12 -> blocksize 2096
+
+ - Config zpool
+ - zpool autoexpand=on jogamp07
+ - zpool autoreplace=on jogamp07
+ - zpool listsnapshots=on jogamp07
+
+ - Config root dataset (for all datasets)
+ - zfs set dedup=off jogamp07
+ - zfs set compression=off jogamp07
+ - zfs set atime=off jogamp07
+ - zfs set mountpoint=none jogamp07
+
+ - Swap (Ram 32G, CPU x86_64 == 4k page size)
+ - zfs create jogamp07/swap -V 33G -b 4K
+ - zfs set checksum=off jogamp07/swap
+ ZVOL should be either:
+ /dev/zvol/jogamp07/swap -> ../../zd0
+ /dev/zvol/swap
+ /dev/jogamp07/swap
+
+ - mkswap -f /dev/zvol/jogamp07/swap
+
+ Below is scripted in './zfs02-create-datasets.sh' (using jogamp07 as pool name)
+
+ - Create Datasets
+ Separation of system/* and the other (users, ..)
+ allows moving onto another OS/distri while maintaining the data.
+
+ - zfs create -o mountpoint=none jogamp07/system
+ - zfs create -o mountpoint=/ jogamp07/system/debian7_01
+ # Skip: Will fail w/ zfs-initramfs, mount of /var is too late
+ # Skip: zfs create jogamp07/system/debian7_01/var
+
+ - zfs create -o mountpoint=/home jogamp07/users
+ - zfs create -o mountpoint=/root jogamp07/users/root
+ - zfs create -o mountpoint=/data jogamp07/data
+ - zfs create -o mountpoint=/srv jogamp07/services
+
+ Below is scripted in './zfs03-export_import.sh' (using jogamp07 as pool name)
+
+ - Set zfs pool bootfs
+ - zpool set bootfs=jogamp07/system/debian7_01 jogamp07
+
+ - Ensure zpool.cache exists:
+ - zpool set cachefile=/etc/zfs/zpool.cache jogamp07
+
+ - Export zfs pool
+ - zpool export jogamp07
+
+ - Import zfs pool
+ - zpool import -f -R /mnt/new jogamp07
+
+ - Copy zpool.cache:
+ - mkdir -p /mnt/new/etc/zfs
+ - cp -a /etc/zfs/zpool.cache /mnt/new/etc/zfs
+
+ 2.5 Populate ZFS rootfs
+ Below is scripted in './zfs04-system-populate.sh'
+
+ - See [C1]
+ - apt-get install debootstrap
+ - debootstrap --arch amd64 stable /mnt/new ftp://ftp.de.debian.org/debian/
+
+ - Setup /mnt/new/etc/network/interfaces
+ - In case you use same /etc/network/interfaces (scripted):
+ mv /mnt/new/etc/network/interfaces /mnt/new/etc/network/interfaces.orig
+ cp -a /etc/network/interfaces /mnt/new/etc/network/interfaces
+
+ - Or redo 1.1.1 (Mind that you do it for rootfs on /mnt/new)
+
+ - Redo: 2.1 Fix /etc/apt/sources.list (probably just the servers)
+ -In case you use same apt sources (scripted):
+ mv /mnt/new/etc/apt/source.list /mnt/new/etc/apt/sources.list.orig
+ cp -a /etc/apt/sources.list /mnt/new/etc/apt/source.list
+ - Or redo 2.1
+
+ 2.6 Chroot ZFS rootfs
+ - Mount essentials # './chroot-mount.sh':
+ mount --bind /dev /mnt/new/dev
+ mount --bind /proc /mnt/new/proc
+ mount --bind /sys /mnt/new/sys
+ - chroot /mnt/new /bin/bash # './chroot-chroot.sh'
+
+ 2.7 Refine / Config System
+ - Root passord: passwd
+
+ - apt-get update
+ - apt-get upgrade
+
+ - apt-get install vim locales
+ - dpkg-reconfigure locales tzdata
+ LANG: en_US.UTF-8, LANGUAGE=en_US:en
+ TZ: your choice
+
+ - apt-get install ssh ntp
+
+ 2.8 ZFS on new System
+ - Redo: 2.2 Install ZFS on USB drive (Script './apt-install-zfs_kernel_etc.sh')
+
+ - Edit /mnt/new/etc/default/zfs
+ - ZFS_MOUNT='no'
+ + ZFS_MOUNT='yes'
+
+ - Fix /usr/share/initramfs-tools/scripts/zfs issues:
+ --- /usr/share/initramfs-tools/scripts/zfs 2013-03-27 04:14:41.000000000 +0100
+ +++ initramfs-tools.scripts.zfs 2013-06-04 04:20:23.278131866 +0200
+ @@ -104,7 +104,7 @@
+ echo ""
+ echo "Manually import the root pool at the command prompt and then exit."
+ echo "Hint: Try: zpool import -f -R / -N $ZFS_RPOOL"
+ - /bin/sh
+ + # /bin/sh
+ fi
+
+ if [ -z "$ZFS_BOOTFS" ]
+
+ - ARC Mem config (assume 32GB ram)
+ # ARC: 512MB - 12 GB
+ echo options zfs zfs_arc_min=536870912 zfs_arc_max=12884901888 >> /etc/modprobe.d/zfs.conf
+
+ 2.9 Leave New System / Final Touches
+ - Mount USB rootfs in new system
+ - mkdir -p /mnt/usbroot
+ - Use extra boot partition on USB stick (-> 1.0)
+ - Edit /etc/fstab, i.e.:
+ UUID=187bf74d-d4c3-4138-a61a-d4bfb4bc5052 /mnt/usbroot ext4 errors=remount-ro 0 2
+ - rm -rf /boot
+ - ln -s /mnt/usbboot/boot /boot
+
+ - Exit from chroot
+ - umount proc/dev/sys './chroot-umount.sh'
+ - zfs export jogamp07
+ - zfs import -N jogamp07
+ - zpool set cachefile=/etc/zfs/zpool.cache jogamp07
+ - update-initramfs -u -k all
+ -
+
+ 3.0 Grub on USB
+ - cp grub_custom.cfg /boot/grub/custom.cfg
+ - edit /boot/grub/custom.cfg to match your partitions / UUID, e.g.:
+ menuentry "zfs 01" {
+ load_video
+ insmod gzio
+ insmod part_msdos
+ insmod ext2
+ set root='(hd2,msdos1)'
+ search --no-floppy --fs-uuid --set=root 187bf74d-d4c3-4138-a61a-d4bfb4bc5052
+ linux /boot/vmlinuz-3.2.0-4-amd64 boot=zfs rpool=jogamp07 bootfs=jogamp07/system/debian7_01 ro
+ initrd /boot/initrd.img-3.2.0-4-amd64
+ }
+ grub-install --no-floppy /dev/sdc (the USB device!)
+
+ 3.0 Launch new system via grub on USB
+ 3.1 Grub / Boot
+ - apt-get install gdisk gptsync parted
+ - apt-get install grub2
+ - Don't install grub on any device!
+ -
+
+ X.1 Skip: Grub 2.00 Derivates / Boot
+ Note: All failed detecting ZFS rootfs properly!
+
+ - Manually build grub 2.00 (ZFS support) [C2]
+ - dpkg -P grub2 grub-pc grub-common grub-pc-bin grub2-common
+ - Build Grub
+ - apt-get install bzr
+ - apt-get install gettext bison flex libdevmapper-dev
+ - apt-get install python autoconf automake autogen
+
+ Do the following from a user account:
+
+ - Skip: Grub 2.00 (not working .. zfs 'unknown filesystem')
+ wget ftp://ftp.gnu.org/gnu/grub/grub-2.00.tar.gz
+ tar xzf grub-2.00.tar.gz
+ cd grub-2.00
+
+ - Skip Using bazar repo revno: 5022
+ bzr branch http://bzr.savannah.gnu.org/r/grub/trunk/grub
+ git clone --branch snapshot/ubuntu/raring https://github.com/zfsonlinux/grub.git zfs-grub
+ cd grub
+ ./autogen.sh
+ ./configure --disable-werror --enable-libzfs --enable-device-mapper --enable-efiemu
+ make
+ sudo make install
+
+ - Skip Using zfs-grub (or ubuntu grub)
+ git clone --branch snapshot/ubuntu/raring https://github.com/zfsonlinux/grub.git zfs-grub
+ cd zfs-grub
+
+ for i in `cat debian/patches/series`; do patch -p1 < debian/patches/$i 2>&1 | tee -a patch.log ; done
+ ./autogen.sh
+ ./configure --disable-werror --enable-libzfs --enable-device-mapper --enable-efiemu
+ make
+ sudo make install
+
+ - Install ..
+ update-initramfs -u -k all
+ grub-install --no-floppy /dev/sdc (the USB device!)
+
+ +++
+ set timeout=3
+ set default=0
+
+ # Funtoo
+ menuentry "JogAmp 01" {
+ insmod zfs
+ linux /vmlinuz-3.2.0-4-rt-amd64 root=jogamp07/system/debian7_01
+ initrd /initrd.img-3.2.0-4-rt-amd64
+ }
+ +++
+
+
+References:
+
+[A1] https://en.wikipedia.org/wiki/ZFS
+[A2] http://wiki.illumos.org/display/illumos/ZFS
+[A3] http://docs.huihoo.com/opensolaris/solaris-zfs-administration-guide/html/index.html
+[A4] http://cuddletech.com/ZFSNinja-Slides.pdf
+[A5] http://www.solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide
+[A6] http://www.solarisinternals.com/wiki/index.php/ZFS_Evil_Tuning_Guide
+[A7] http://www.cuddletech.com/blog/pivot/entry.php?id=983 (ZFS Compression)
+[A8] https://blogs.oracle.com/dap/entry/zfs_compression
+
+[B1] http://zfsonlinux.org/
+[B2] http://pthree.org/2012/04/17/install-zfs-on-debian-gnulinux/
+[B3] https://wiki.freebsd.org/ZFSTuningGuide
+[B4] http://stoneyforest.net/~chris/blog/freebsd/zfs/maint.html
+[B5] http://www.funtoo.org/wiki/ZFS_Install_Guide
+
+[C1] http://www.howtoforge.com/installing-debian-wheezy-testing-with-debootstrap-from-a-grml-live-linux-p2
+[C2] http://www.gnu.org/software/grub/manual/grub.html
+
+[_1] http://wiki.debian.org/AptPreferences#Pinning
diff --git a/server/setup/zfs_linux_bringup/apt-install-zfs_kernel_etc.sh b/server/setup/zfs_linux_bringup/apt-install-zfs_kernel_etc.sh
new file mode 100644
index 0000000..7c43ed2
--- /dev/null
+++ b/server/setup/zfs_linux_bringup/apt-install-zfs_kernel_etc.sh
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+wget http://archive.zfsonlinux.org/debian/pool/main/z/zfsonlinux/zfsonlinux_1%7Ewheezy_all.deb
+dpkg -i zfsonlinux_1~wheezy_all.deb
+apt-get update
+apt-get upgrade
+apt-get install linux-base linux-image-amd64 linux-headers-amd64 util-linux
+apt-get install debian-zfs libzfs-dev
+apt-get install zfs-initramfs
+apt-get install vim
+
diff --git a/server/setup/zfs_linux_bringup/apt-sources.list b/server/setup/zfs_linux_bringup/apt-sources.list
new file mode 100644
index 0000000..b7d90e2
--- /dev/null
+++ b/server/setup/zfs_linux_bringup/apt-sources.list
@@ -0,0 +1,15 @@
+#
+
+# deb cdrom:[Debian GNU/Linux 7.0.0 _Wheezy_ - Official amd64 DVD Binary-1 20130504-14:44]/ wheezy contrib main
+
+# deb cdrom:[Debian GNU/Linux 7.0.0 _Wheezy_ - Official amd64 DVD Binary-1 20130504-14:44]/ wheezy contrib main
+
+deb http://ftp.debian.org/debian/ wheezy main contrib non-free
+deb-src http://ftp.debian.org/debian/ wheezy main contrib non-free
+
+deb http://security.debian.org/ wheezy/updates main contrib
+deb-src http://security.debian.org/ wheezy/updates main contrib
+
+# wheezy-updates, previously known as 'volatile'
+deb http://ftp.de.debian.org/debian/ wheezy-updates main contrib non-free
+deb-src http://ftp.de.debian.org/debian/ wheezy-updates main contrib non-free
diff --git a/server/setup/zfs_linux_bringup/chroot-chroot.sh b/server/setup/zfs_linux_bringup/chroot-chroot.sh
new file mode 100644
index 0000000..2786bca
--- /dev/null
+++ b/server/setup/zfs_linux_bringup/chroot-chroot.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+chroot /mnt/new /bin/bash
+
diff --git a/server/setup/zfs_linux_bringup/chroot-mount.sh b/server/setup/zfs_linux_bringup/chroot-mount.sh
new file mode 100644
index 0000000..a719301
--- /dev/null
+++ b/server/setup/zfs_linux_bringup/chroot-mount.sh
@@ -0,0 +1,5 @@
+#! /bin/sh
+mount --bind /dev /mnt/new/dev
+mount --bind /proc /mnt/new/proc
+mount --bind /sys /mnt/new/sys
+
diff --git a/server/setup/zfs_linux_bringup/chroot-umount.sh b/server/setup/zfs_linux_bringup/chroot-umount.sh
new file mode 100644
index 0000000..f53d3b9
--- /dev/null
+++ b/server/setup/zfs_linux_bringup/chroot-umount.sh
@@ -0,0 +1,5 @@
+#! /bin/sh
+umount /mnt/new/dev
+umount /mnt/new/proc
+umount /mnt/new/sys
+
diff --git a/server/setup/zfs_linux_bringup/etc_fstab.txt b/server/setup/zfs_linux_bringup/etc_fstab.txt
new file mode 100644
index 0000000..8f5f16f
--- /dev/null
+++ b/server/setup/zfs_linux_bringup/etc_fstab.txt
@@ -0,0 +1,3 @@
+
+UUID=187bf74d-d4c3-4138-a61a-d4bfb4bc5052 /mnt/usbroot ext4 errors=remount-ro 0 2
+
diff --git a/server/setup/zfs_linux_bringup/grub_custom.cfg b/server/setup/zfs_linux_bringup/grub_custom.cfg
new file mode 100644
index 0000000..6317145
--- /dev/null
+++ b/server/setup/zfs_linux_bringup/grub_custom.cfg
@@ -0,0 +1,27 @@
+menuentry "zfs 01" {
+ load_video
+ insmod gzio
+ insmod part_msdos
+ insmod ext2
+ set root='(hd2,msdos1)'
+ search --no-floppy --fs-uuid --set=root 187bf74d-d4c3-4138-a61a-d4bfb4bc5052
+ echo 'Loading Linux ZFS 3.2.0-4-amd64 ...'
+ linux /boot/vmlinuz-3.2.0-4-amd64 boot=zfs rpool=jogamp07 bootfs=jogamp07/system/debian7_01 ro
+ echo 'Loading initial ramdisk ...'
+ initrd /boot/initrd.img-3.2.0-4-amd64
+}
+
+menuentry "zfs 02" {
+ load_video
+ insmod gzio
+ insmod part_msdos
+ insmod ext2
+ set root='(hd2,msdos1)'
+ search --no-floppy --fs-uuid --set=root 187bf74d-d4c3-4138-a61a-d4bfb4bc5052
+ echo 'Loading Linux ZFS 3.2.0-4-amd64 ...'
+ linux /boot/vmlinuz-3.2.0-4-amd64 boot=zfs rpool=jogamp07 bootfs=jogamp07/system/debian7_01 root=jogamp07/system/debian7_01 ro
+ #linux /boot/vmlinuz-3.2.0-4-amd64 boot=zfs rpool=jogamp07 bootfs=jogamp07/system/debian7_01 root=UUID=4ce28099-2c66-4c86-a13f-61376d823e69 ro
+ echo 'Loading initial ramdisk ...'
+ initrd /boot/initrd.img-3.2.0-4-amd64
+}
+
diff --git a/server/setup/zfs_linux_bringup/initramfs-tools.scripts.zfs b/server/setup/zfs_linux_bringup/initramfs-tools.scripts.zfs
new file mode 100644
index 0000000..328cfca
--- /dev/null
+++ b/server/setup/zfs_linux_bringup/initramfs-tools.scripts.zfs
@@ -0,0 +1,163 @@
+# ZFS boot stub for initramfs-tools.
+#
+# In the initramfs environment, the /init script sources this stub to
+# override the default functions in the /scripts/local script.
+#
+# Enable this by passing boot=zfs on the kernel command line.
+#
+
+
+pre_mountroot()
+{
+ [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top"
+ run_scripts /scripts/local-top
+ [ "$quiet" != "y" ] && log_end_msg
+
+ if [ -r '/etc/default/zfs' ]
+ then
+ . '/etc/default/zfs'
+ if [ "$ZFS_INITRD_PRE_MOUNTROOT_SLEEP" -gt '0' ]
+ then
+ [ "$quiet" != "y" ] && log_begin_msg "Sleeping for $ZFS_INITRD_PRE_MOUNTROOT_SLEEP seconds..."
+ sleep "$ZFS_INITRD_PRE_MOUNTROOT_SLEEP"
+ [ "$quiet" != "y" ] && log_end_msg
+ fi
+ fi
+}
+
+# Duplicates the functionality found under try_failure_hooks in functions
+# but invoking that would be inappropriate here.
+disable_plymouth()
+{
+ if [ -x /bin/plymouth ] && /bin/plymouth --ping
+ then
+ /bin/plymouth hide-splash >/dev/null 2>&1
+ fi
+}
+
+mountroot()
+{
+ pre_mountroot
+
+ [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount"
+ run_scripts /scripts/local-premount
+ [ "$quiet" != "y" ] && log_end_msg
+
+ # Wait for all of the /dev/{hd,sd}[a-z] device nodes to appear.
+ wait_for_udev
+
+ # Load the module now to get consistent automatic pool import behavior.
+ modprobe zfs
+
+ # Check the kernel command line for overrides.
+ ZFS_RPOOL="${rpool#rpool=}"
+ ZFS_BOOTFS="${bootfs#bootfs=}"
+
+ if [ -z "$ZFS_RPOOL" ]
+ then
+ # Check for the `-B zfs-bootfs=%s/%u,...` kind of parameter.
+ #
+ # The ${zfs-bootfs} variable is set at the kernel commmand
+ # line, usually by GRUB, but it cannot be referenced here
+ # directly because bourne variable names cannot contain a
+ # hyphen.
+ #
+ # Reassign the variable by dumping the environment and
+ # stripping the zfs-bootfs= prefix. Let the shell handle
+ # quoting through the eval command.
+ eval ZFS_RPOOL=$(set | sed -n -e 's,^zfs-bootfs=,,p')
+
+ # Only the pool name is relevant because the ZFS filesystem on
+ # Linux is extrinsic and the userland cannot resolve a ZFS
+ # object number.
+ #
+ # Strip everything after the first slash character.
+ ZFS_RPOOL=$(echo "$ZFS_RPOOL" | sed -e 's,/.*,,')
+ fi
+
+ # Use "rpool" as the default, like on most Solaris systems.
+ [ -z "$ZFS_RPOOL" ] && ZFS_RPOOL='rpool'
+
+ # @FIXME: Forcing the import should not be necessary.
+ #
+ # Consider inhibiting automatic zpool imports in the initramfs
+ # environment and doing a full import in the regular system instead.
+
+ [ "$quiet" != "y" ] && log_begin_msg "Importing ZFS root pool $ZFS_RPOOL"
+ if [ -f /etc/zfs/zpool.cache ]
+ then
+ ZFS_STDERR=$(zpool list "$ZFS_RPOOL" 1>/dev/null 2>&1 \
+ || zpool import -f -N "$ZFS_RPOOL" 2>&1)
+ ZFS_ERROR=$?
+ else
+ ZFS_STDERR=$(zpool import -f -N "$ZFS_RPOOL" 2>&1)
+ ZFS_ERROR=$?
+ fi
+ [ "$quiet" != "y" ] && log_end_msg
+
+ if [ "$ZFS_ERROR" -ne 0 ]
+ then
+ disable_plymouth
+ echo "Command: zpool import -f -N $ZFS_RPOOL"
+ echo "Message: $ZFS_STDERR"
+ echo "Error: $ZFS_ERROR"
+ echo ""
+ echo "Manually import the root pool at the command prompt and then exit."
+ echo "Hint: Try: zpool import -f -R / -N $ZFS_RPOOL"
+ # /bin/sh
+ fi
+
+ if [ -z "$ZFS_BOOTFS" ]
+ then
+ [ "$quiet" != "y" ] && log_begin_msg "Getting ZFS bootfs property"
+ ZFS_BOOTFS=$(zpool list -H -o bootfs "$ZFS_RPOOL")
+ ZFS_ERROR=$?
+ [ "$quiet" != "y" ] && log_end_msg
+ fi
+
+ if [ -z "$ZFS_BOOTFS" ]
+ then
+ disable_plymouth
+ echo "Command: zpool list -H -o bootfs $ZFS_RPOOL"
+ echo "Error: $ZFS_ERROR, unable to get the bootfs property."
+ echo ""
+ echo "Manually mount the root filesystem on $rootmnt and then exit."
+ echo "Hint: Try: mount -t zfs -o zfsutil $ZFS_RPOOL/ROOT/system $rootmnt"
+ /bin/sh
+ fi
+
+ # Force the mountpoint to the only correct value for a root filesystem.
+ [ "$quiet" != "y" ] && log_begin_msg "Setting mountpoint=/ on ZFS filesystem $ZFS_BOOTFS"
+ ZFS_STDERR=$(zfs set mountpoint=/ "$ZFS_BOOTFS" 2>&1)
+ [ "$quiet" != "y" ] && log_end_msg
+
+ # Ideally, the root filesystem would be mounted like this:
+ #
+ # zpool import -R "$rootmnt" -N "$ZFS_RPOOL"
+ # zfs mount -o mountpoint=/ "$ZFS_BOOTFS"
+ #
+ # but the MOUNTPOINT prefix is preserved on descendent filesystem after
+ # the pivot into the regular root, which later breaks things like
+ # `zfs mount -a` and the /etc/mtab refresh.
+
+ [ "$quiet" != "y" ] && log_begin_msg "Mounting ZFS filesystem $ZFS_BOOTFS"
+ ZFS_STDERR=$(mount -t zfs -o zfsutil "$ZFS_BOOTFS" "$rootmnt" 2>&1)
+ ZFS_ERROR=$?
+ [ "$quiet" != "y" ] && log_end_msg
+
+ if [ "$ZFS_ERROR" -ne 0 ]
+ then
+ disable_plymouth
+ echo ""
+ echo "Command: mount -t zfs -o zfsutil $ZFS_BOOTFS $rootmnt"
+ echo "Message: $ZFS_STDERR"
+ echo "Error: $ZFS_ERROR"
+ echo ""
+ echo "Manually mount the root filesystem on $rootmnt and then exit."
+ /bin/sh
+ fi
+
+ [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
+ run_scripts /scripts/local-bottom
+ [ "$quiet" != "y" ] && log_end_msg
+}
diff --git a/server/setup/zfs_linux_bringup/zfs01-create_config-pool.sh b/server/setup/zfs_linux_bringup/zfs01-create_config-pool.sh
new file mode 100644
index 0000000..dc0c80d
--- /dev/null
+++ b/server/setup/zfs_linux_bringup/zfs01-create_config-pool.sh
@@ -0,0 +1,17 @@
+#! /bin/sh
+
+zpool create -f -o ashift=12 jogamp07 mirror /dev/disk/by-id/ata-WDC_WD15EADS-00P8B0_WD-WMAVU0880750 /dev/disk/by-id/ata-WDC_WD20EARS-00S8B1_WD-WCAVY4733652
+
+zpool autoexpand=on jogamp07
+zpool autoreplace=on jogamp07
+zpool listsnapshots=on jogamp07
+
+zfs set dedup=off jogamp07
+zfs set compression=off jogamp07
+zfs set atime=off jogamp07
+zfs set mountpoint=none jogamp07
+
+# Swap ZVOL
+zfs create jogamp07/swap -V 33G -b 4K
+zfs set checksum=off jogamp07/swap
+mkswap -f /dev/zvol/jogamp07/swap
diff --git a/server/setup/zfs_linux_bringup/zfs02-create-datasets.sh b/server/setup/zfs_linux_bringup/zfs02-create-datasets.sh
new file mode 100644
index 0000000..c8a0d3a
--- /dev/null
+++ b/server/setup/zfs_linux_bringup/zfs02-create-datasets.sh
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+zfs create -o mountpoint=none jogamp07/system
+zfs create -o mountpoint=/ jogamp07/system/debian7_01
+# Will fail w/ zfs-initramfs, mount of /var is too late
+# zfs create jogamp07/system/debian7_01/var
+
+zfs create -o mountpoint=/home jogamp07/users
+zfs create -o mountpoint=/root jogamp07/users/root
+zfs create -o mountpoint=/data jogamp07/data
+zfs create -o mountpoint=/srv jogamp07/services
+
diff --git a/server/setup/zfs_linux_bringup/zfs03-export_import.sh b/server/setup/zfs_linux_bringup/zfs03-export_import.sh
new file mode 100644
index 0000000..9af520a
--- /dev/null
+++ b/server/setup/zfs_linux_bringup/zfs03-export_import.sh
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+zpool set bootfs=jogamp07/system/debian7_01 jogamp07
+
+zpool set cachefile=/etc/zfs/zpool.cache jogamp07
+
+zpool export jogamp07
+zpool import -R /mnt/new jogamp07
+
+mkdir -p /mnt/new/etc/zfs
+cp -a /etc/zfs/zpool.cache /mnt/new/etc/zfs
diff --git a/server/setup/zfs_linux_bringup/zfs04-system-populate.sh b/server/setup/zfs_linux_bringup/zfs04-system-populate.sh
new file mode 100644
index 0000000..2781d66
--- /dev/null
+++ b/server/setup/zfs_linux_bringup/zfs04-system-populate.sh
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+apt-get install debootstrap
+debootstrap --arch amd64 stable /mnt/new ftp://ftp.de.debian.org/debian/
+
+touch /mnt/new/etc/network/interfaces
+mv /mnt/new/etc/network/interfaces /mnt/new/etc/network/interfaces.orig
+
+touch /mnt/new/etc/apt/source.list
+mv /mnt/new/etc/apt/source.list /mnt/new/etc/apt/source.list.orig
+cp -a /etc/apt/sources.list /mnt/new/etc/apt/source.list
+
+mkdir -p /mnt/new/mnt/usbroot
+