Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.23 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOL | fdisk /dev/sda
  4. o
  5. n
  6. p
  7. 1
  8.  
  9.  
  10. t
  11. bf
  12. a
  13. p
  14. w
  15. q
  16. EOL
  17.  
  18. zpool create -o ashift=12 -O atime=off -O canmount=off -O compression=lz4 -O normalization=formD -O mountpoint=none -R /mnt rpool /dev/sda1
  19.  
  20. zfs create -o mountpoint=none -o canmount=off rpool/ROOT
  21. zfs create -o mountpoint=/ -o canmount=noauto rpool/ROOT/ubuntu
  22. zfs mount rpool/ROOT/ubuntu
  23.  
  24. zfs create -o mountpoint=/home -o setuid=off rpool/home
  25. zfs create -o mountpoint=/root -o setuid=off rpool/root
  26.  
  27. zfs create -o mountpoint=none -o canmount=off -o setuid=off -o exec=off rpool/var
  28. zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false rpool/var/cache
  29. zfs create -o mountpoint=legacy rpool/var/log
  30. zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false -o exec=on rpool/var/tmp
  31.  
  32. zfs create -o mountpoint=/srv rpool/srv
  33.  
  34. zfs create -V 4G -b $(getconf PAGESIZE) -o compression=zle \
  35. -o logbias=throughput -o sync=always \
  36. -o primarycache=metadata -o secondarycache=none \
  37. -o com.sun:auto-snapshot=false rpool/swap
  38.  
  39. mkdir /mnt/var
  40. mkdir /mnt/var/cache
  41. mkdir /mnt/var/log
  42. mkdir /mnt/var/tmp
  43.  
  44. mount -t zfs rpool/var/cache /mnt/var/cache
  45. mount -t zfs rpool/var/log /mnt/var/log
  46. mount -t zfs rpool/var/tmp /mnt/var/tmp
  47.  
  48. chmod 1777 /mnt/var/tmp
  49. debootstrap xenial /mnt
  50. zfs set devices=off rpool
  51.  
  52. echo ubuntu > /mnt/etc/hostname
  53.  
  54. cat <<EOL > /mnt/etc/hosts
  55. 127.0.0.1 localhost
  56. 127.0.1.1 ubuntu
  57.  
  58. # The following lines are desirable for IPv6 capable hosts
  59. ::1 ip6-localhost ip6-loopback
  60. fe00::0 ip6-localnet
  61. ff00::0 ip6-mcastprefix
  62. ff02::1 ip6-allnodes
  63. ff02::2 ip6-allrouters
  64. EOL
  65.  
  66. cat <<EOL > /mnt/etc/apt/sources.list
  67. # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
  68. # newer versions of the distribution.
  69. deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
  70. # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
  71.  
  72. ## Major bug fix updates produced after the final release of the
  73. ## distribution.
  74. deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
  75. # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
  76.  
  77. ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
  78. ## team. Also, please note that software in universe WILL NOT receive any
  79. ## review or updates from the Ubuntu security team.
  80. deb http://us.archive.ubuntu.com/ubuntu/ xenial universe
  81. # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe
  82. deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
  83. # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
  84.  
  85. ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
  86. ## team, and may not be under a free licence. Please satisfy yourself as to
  87. ## your rights to use the software. Also, please note that software in
  88. ## multiverse WILL NOT receive any review or updates from the Ubuntu
  89. ## security team.
  90. deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
  91. # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
  92. deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
  93. # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
  94.  
  95. ## N.B. software from this repository may not have been tested as
  96. ## extensively as that contained in the main release, although it includes
  97. ## newer versions of some applications which may provide useful features.
  98. ## Also, please note that software in backports WILL NOT receive any review
  99. ## or updates from the Ubuntu security team.
  100. deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
  101. # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
  102.  
  103. ## Uncomment the following two lines to add software from Canonical's
  104. ## 'partner' repository.
  105. ## This software is not part of Ubuntu, but is offered by Canonical and the
  106. ## respective vendors as a service to Ubuntu users.
  107. # deb http://archive.canonical.com/ubuntu xenial partner
  108. # deb-src http://archive.canonical.com/ubuntu xenial partner
  109.  
  110. deb http://security.ubuntu.com/ubuntu xenial-security main restricted
  111. # deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
  112. deb http://security.ubuntu.com/ubuntu xenial-security universe
  113. # deb-src http://security.ubuntu.com/ubuntu xenial-security universe
  114. deb http://security.ubuntu.com/ubuntu xenial-security multiverse
  115. # deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse
  116. EOL
  117.  
  118. mount --types proc /proc /mnt/proc
  119. mount --rbind /sys /mnt/sys
  120. mount --make-rslave /mnt/sys
  121. mount --rbind /dev /mnt/dev
  122. mount --make-rslave /mnt/dev
  123.  
  124. cat <<EOL > /mnt/etc/fstab
  125. # /etc/fstab: static file system information.
  126. #
  127. # Use 'blkid' to print the universally unique identifier for a
  128. # device; this may be used with UUID= as a more robust way to name devices
  129. # that works even if disks are added and removed. See fstab(5).
  130. #
  131. # <file system> <mount point> <type> <options> <dump> <pass>
  132. rpool/var/cache /var/cache zfs defaults 0 0
  133. rpool/var/log /var/log zfs defaults 0 0
  134. rpool/var/tmp /var/tmp zfs defaults 0 0
  135. /dev/zvol/rpool/swap none swap defaults 0 0
  136. EOL
  137.  
  138. mkswap /dev/zvol/rpool/swap
  139.  
  140. cat <<EOL > /mnt/install.sh
  141. #! /bin/bash
  142. locale-gen en_US.UTF-8
  143. echo LANG=en_US.UTF-8 > /etc/default/locale
  144. dpkg-reconfigure tzdata
  145. ln -s /proc/self/mounts /etc/mtab
  146. apt update
  147. apt --yes dist-upgrade
  148. apt install --yes ubuntu-desktop
  149. apt install --yes --no-install-recommends linux-image-generic
  150. apt install --yes zfs-initramfs
  151. apt install --yes grub-pc
  152. passwd -dl root
  153. update-initramfs -c -k all
  154. update-grub
  155. useradd -m -c "Local Administrator,,," -s /bin/bash local
  156. passwd local <<EOF
  157. <password here>
  158. <password here>
  159. EOF
  160. usermod -a -G adm,cdrom,dip,plugdev,sudo local
  161. apt install --yes ifenslave vlan bridge-utils screen openssh-server policykit-1
  162. EOL
  163.  
  164. chmod +x /mnt/install.sh
  165. chroot /mnt /install.sh
  166. rm /mnt/install.sh
  167.  
  168. cat <<'EOL' > /mnt/etc/default/grub
  169. # If you change this file, run 'update-grub' afterwards to update
  170. # /boot/grub/grub.cfg.
  171. # For full documentation of the options in this file, see:
  172. # info -f grub -n 'Simple configuration'
  173.  
  174. GRUB_DEFAULT=0
  175. #GRUB_HIDDEN_TIMEOUT=0
  176. GRUB_HIDDEN_TIMEOUT_QUIET=true
  177. GRUB_TIMEOUT=2
  178. GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
  179. GRUB_CMDLINE_LINUX_DEFAULT=""
  180. GRUB_CMDLINE_LINUX=""
  181.  
  182. # Uncomment to enable BadRAM filtering, modify to suit your needs
  183. # This works with Linux (no patch required) and with any kernel that obtains
  184. # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
  185. #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
  186.  
  187. # Uncomment to disable graphical terminal (grub-pc only)
  188. #GRUB_TERMINAL=console
  189.  
  190. # The resolution used on graphical terminal
  191. # note that you can use only modes which your graphic card supports via VBE
  192. # you can see them in real GRUB with the command `vbeinfo'
  193. #GRUB_GFXMODE=640x480
  194.  
  195. # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
  196. #GRUB_DISABLE_LINUX_UUID=true
  197.  
  198. # Uncomment to disable generation of recovery mode menu entries
  199. #GRUB_DISABLE_RECOVERY="true"
  200.  
  201. # Uncomment to get a beep at grub start
  202. #GRUB_INIT_TUNE="480 440 1"
  203. EOL
  204.  
  205. chroot /mnt /usr/sbin/update-grub
  206.  
  207. zfs snap -r rpool@base
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement