在Hetzner专用服务器上的ZFS根上获取Ubuntu 16.04

到目前为止,很可能在ZFS root-fs上运行Ubuntu 16.04。 Ubuntu 16.04在默认的包pipe理器中有ZFS,而像这样的指南,开始并不难。

不过,我所见过的所有指南都需要能够从Ubuntu安装映像启动。 对于Hetzner专用服务器,这是一种罕见的安装过程,因为它需要工程师访问服务器并插入远程KVM。

默认情况下,专用服务器启动到救援系统,允许通过其“installiamge”脚本安装各种Linux发行版。 但是,这个脚本还不支持ZFS。

如何获得在ZFS根目录上运行的Hetzner专用服务器?

其基本思想是将Ubuntu安装在硬盘上的一个小分区上,对硬盘进行分区,以便将剩余的空间用于ZFS,然后复制安装。 我主要使用这个指南如何做到这一点。

懒惰,和Ansible的经验? 我写了一小堆脚本来自动执行这些步骤。 他们是可用的: https : //github.com/tijszwinkels/hetzner-ubuntu-16.04-zfs-root-ansible/blob/master/hetzner-ubuntu-16.04.yml小心,这些脚本假定主机启动到Hetzner救援系统,他们将把你的驱动器作为第一步。 使用风险自负!

# SSH into the host. # Wipe the drives. Assuming SSDs on 'sda' and 'sdb'. /sbin/blkdiscard /dev/sda /sbin/blkdiscard /dev/sdb # Install Ubuntu 16.04 on a 4G partition using the Hetzner 'installimage' script /root/.oldroot/nfs/install/installimage -a -n my-hostname -r yes -l 1 -p /:ext4:4G -K /root/.ssh/robot_user_keys -i /root/.oldroot/nfs/install/../images/Ubuntu-1604-xenial-64-minimal.tar.gz # Reboot the system /sbin/shutdown -r now # Wait for the host to come back up, and ssh in. # Install the 'parted' parition editor apt-get update && apt-get install -y parted # run parted on the first drive, create a partition in all remaining space. (UNTESTED!) sudo parted /dev/sda (parted) mkpart primary 4097MB -1s (parted) quit # run parted on the first drive, create a partition in all remaining space. (UNTESTED!) sudo parted /dev/sdb (parted) mkpart primary 4097MB -1s (parted) quit # Create a ZFS pool named 'tank' # Please note that I'm using the /dev/disk/by-id interface. This is more resilient than /dev/sda and /dev/sdb zpool create -f -o ashift=13 -O atime=off -O dedup=off -O compression=lz4 tank mirror `ls /dev/disk/by-id/ata-*-part2` # Create OS partiton zfs create tank/os # Rsync the current system to the new partition. rsync -a --one-file-system / /tank/os/ # Make the system bootable cd /tank/os && mount --bind /dev dev && mount --bind /proc proc && mount --bind /sys sys && mount --bind /run run && /usr/sbin/chroot . /bin/bash -c "export ZPOOL_VDEV_NAME_PATH=YES && /usr/sbin/update-grub && /usr/sbin/grub-install /dev/sda && /usr/sbin/grub-install /dev/sdb" 

现在,你应该有一个hetzner专用的服务器,快乐地引导到Ubuntu 16.04与ZFS根FS。 祝你好运!