ubuntu-16.04 – 在Hetzner专用服务器上的ZFS根目录上获取Ubuntu 16.04

前端之家收集整理的这篇文章主要介绍了ubuntu-16.04 – 在Hetzner专用服务器上的ZFS根目录上获取Ubuntu 16.04前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
到目前为止,很有可能在ZFS root-fs上运行Ubuntu 16.04. Ubuntu 16.04在默认的包管理器中有ZFS,而像 this这样的指南,它并不难开始.

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

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

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

基本的想法是将Ubuntu安装在硬盘驱动器上的一个小分区上,对硬盘驱动器进行分区以使用剩余的空间用于ZFS,然后将安装复制过来.我主要使用 this guide指令如何做到这一点.

懒惰,和Ansible一起经历?我写了一小堆脚本来自动执行这些步骤.它们可在:https://github.com/tijszwinkels/hetzner-ubuntu-16.04-zfs-root-ansible/blob/master/hetzner-ubuntu-16.04.yml获得
请注意,这些脚本假设主机已启动进入Hetzner救援系统,他们将首先擦除您的驱动器.使用风险自负!

  1. # SSH into the host.
  2.  
  3. # Wipe the drives. Assuming SSDs on 'sda' and 'sdb'.
  4. /sbin/blkdiscard /dev/sda
  5. /sbin/blkdiscard /dev/sdb
  6.  
  7. # Install Ubuntu 16.04 on a 4G partition using the Hetzner 'installimage' script
  8. /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
  9.  
  10. # Reboot the system.
  11. /sbin/shutdown -r now
  12.  
  13. # Wait for the host to come back up,and SSH in.
  14.  
  15. # Install the 'parted' parition editor
  16. apt-get update && apt-get install -y parted
  17.  
  18. # Run parted on the first drive,create a partition in all remaining space. (UNTESTED!)
  19. sudo parted /dev/sda
  20. (parted) mkpart primary 4097MB -1s
  21. (parted) quit
  22.  
  23. # Run parted on the second drive,create a partition in all remaining space. (UNTESTED!)
  24. sudo parted /dev/sdb
  25. (parted) mkpart primary 4097MB -1s
  26. (parted) quit
  27.  
  28. # Install required ZFS packages
  29. apt-get install -y zfs-dkms zfs-initramfs
  30.  
  31. # Create a ZFS pool named 'tank'
  32. # Please note that I'm using the /dev/disk/by-id interface. This is more resilient than /dev/sda and /dev/sdb
  33. zpool create -f -o ashift=13 -O atime=off -O dedup=off -O compression=lz4 tank mirror `ls /dev/disk/by-id/ata-*-part2`
  34.  
  35. # Create OS partiton
  36. zfs create tank/os
  37.  
  38. # Rsync the current system to the new partition.
  39. rsync -a --one-file-system / /tank/os/
  40.  
  41. # Chroot into the system
  42. cd /tank/os
  43. mount --bind /dev dev
  44. mount --bind /proc proc
  45. mount --bind /sys sys
  46. mount --bind /run run
  47. chroot .
  48.  
  49. # Install GRUB into the drives
  50. export ZPOOL_VDEV_NAME_PATH=YES
  51. update-grub
  52. grub-install /dev/sda
  53. grub-install /dev/sdb

现在,您应该拥有一个Hetzner专用服务器,可以使用ZFS根fs快乐地引导到Ubuntu 16.04.祝好运!

猜你在找的Ubuntu相关文章