Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOL | fdisk /dev/sda
- o
- n
- p
- 1
- t
- bf
- a
- p
- w
- q
- EOL
- 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
- zfs create -o mountpoint=none -o canmount=off rpool/ROOT
- zfs create -o mountpoint=/ -o canmount=noauto rpool/ROOT/ubuntu
- zfs mount rpool/ROOT/ubuntu
- zfs create -o mountpoint=/home -o setuid=off rpool/home
- zfs create -o mountpoint=/root -o setuid=off rpool/root
- zfs create -o mountpoint=none -o canmount=off -o setuid=off -o exec=off rpool/var
- zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false rpool/var/cache
- zfs create -o mountpoint=legacy rpool/var/log
- zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false -o exec=on rpool/var/tmp
- zfs create -o mountpoint=/srv rpool/srv
- zfs create -V 4G -b $(getconf PAGESIZE) -o compression=zle \
- -o logbias=throughput -o sync=always \
- -o primarycache=metadata -o secondarycache=none \
- -o com.sun:auto-snapshot=false rpool/swap
- mkdir /mnt/var
- mkdir /mnt/var/cache
- mkdir /mnt/var/log
- mkdir /mnt/var/tmp
- mount -t zfs rpool/var/cache /mnt/var/cache
- mount -t zfs rpool/var/log /mnt/var/log
- mount -t zfs rpool/var/tmp /mnt/var/tmp
- chmod 1777 /mnt/var/tmp
- debootstrap xenial /mnt
- zfs set devices=off rpool
- echo ubuntu > /mnt/etc/hostname
- cat <<EOL > /mnt/etc/hosts
- 127.0.0.1 localhost
- 127.0.1.1 ubuntu
- # The following lines are desirable for IPv6 capable hosts
- ::1 ip6-localhost ip6-loopback
- fe00::0 ip6-localnet
- ff00::0 ip6-mcastprefix
- ff02::1 ip6-allnodes
- ff02::2 ip6-allrouters
- EOL
- cat <<EOL > /mnt/etc/apt/sources.list
- # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
- # newer versions of the distribution.
- deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
- # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
- ## Major bug fix updates produced after the final release of the
- ## distribution.
- deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
- # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
- ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
- ## team. Also, please note that software in universe WILL NOT receive any
- ## review or updates from the Ubuntu security team.
- deb http://us.archive.ubuntu.com/ubuntu/ xenial universe
- # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe
- deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
- # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
- ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
- ## team, and may not be under a free licence. Please satisfy yourself as to
- ## your rights to use the software. Also, please note that software in
- ## multiverse WILL NOT receive any review or updates from the Ubuntu
- ## security team.
- deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
- # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
- deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
- # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
- ## N.B. software from this repository may not have been tested as
- ## extensively as that contained in the main release, although it includes
- ## newer versions of some applications which may provide useful features.
- ## Also, please note that software in backports WILL NOT receive any review
- ## or updates from the Ubuntu security team.
- deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
- # deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
- ## Uncomment the following two lines to add software from Canonical's
- ## 'partner' repository.
- ## This software is not part of Ubuntu, but is offered by Canonical and the
- ## respective vendors as a service to Ubuntu users.
- # deb http://archive.canonical.com/ubuntu xenial partner
- # deb-src http://archive.canonical.com/ubuntu xenial partner
- deb http://security.ubuntu.com/ubuntu xenial-security main restricted
- # deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
- deb http://security.ubuntu.com/ubuntu xenial-security universe
- # deb-src http://security.ubuntu.com/ubuntu xenial-security universe
- deb http://security.ubuntu.com/ubuntu xenial-security multiverse
- # deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse
- EOL
- mount --types proc /proc /mnt/proc
- mount --rbind /sys /mnt/sys
- mount --make-rslave /mnt/sys
- mount --rbind /dev /mnt/dev
- mount --make-rslave /mnt/dev
- cat <<EOL > /mnt/etc/fstab
- # /etc/fstab: static file system information.
- #
- # Use 'blkid' to print the universally unique identifier for a
- # device; this may be used with UUID= as a more robust way to name devices
- # that works even if disks are added and removed. See fstab(5).
- #
- # <file system> <mount point> <type> <options> <dump> <pass>
- rpool/var/cache /var/cache zfs defaults 0 0
- rpool/var/log /var/log zfs defaults 0 0
- rpool/var/tmp /var/tmp zfs defaults 0 0
- /dev/zvol/rpool/swap none swap defaults 0 0
- EOL
- mkswap /dev/zvol/rpool/swap
- cat <<EOL > /mnt/install.sh
- #! /bin/bash
- locale-gen en_US.UTF-8
- echo LANG=en_US.UTF-8 > /etc/default/locale
- dpkg-reconfigure tzdata
- ln -s /proc/self/mounts /etc/mtab
- apt update
- apt --yes dist-upgrade
- apt install --yes ubuntu-desktop
- apt install --yes --no-install-recommends linux-image-generic
- apt install --yes zfs-initramfs
- apt install --yes grub-pc
- passwd -dl root
- update-initramfs -c -k all
- update-grub
- useradd -m -c "Local Administrator,,," -s /bin/bash local
- passwd local <<EOF
- <password here>
- <password here>
- EOF
- usermod -a -G adm,cdrom,dip,plugdev,sudo local
- apt install --yes ifenslave vlan bridge-utils screen openssh-server policykit-1
- EOL
- chmod +x /mnt/install.sh
- chroot /mnt /install.sh
- rm /mnt/install.sh
- cat <<'EOL' > /mnt/etc/default/grub
- # If you change this file, run 'update-grub' afterwards to update
- # /boot/grub/grub.cfg.
- # For full documentation of the options in this file, see:
- # info -f grub -n 'Simple configuration'
- GRUB_DEFAULT=0
- #GRUB_HIDDEN_TIMEOUT=0
- GRUB_HIDDEN_TIMEOUT_QUIET=true
- GRUB_TIMEOUT=2
- GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
- GRUB_CMDLINE_LINUX_DEFAULT=""
- GRUB_CMDLINE_LINUX=""
- # Uncomment to enable BadRAM filtering, modify to suit your needs
- # This works with Linux (no patch required) and with any kernel that obtains
- # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
- #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
- # Uncomment to disable graphical terminal (grub-pc only)
- #GRUB_TERMINAL=console
- # The resolution used on graphical terminal
- # note that you can use only modes which your graphic card supports via VBE
- # you can see them in real GRUB with the command `vbeinfo'
- #GRUB_GFXMODE=640x480
- # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
- #GRUB_DISABLE_LINUX_UUID=true
- # Uncomment to disable generation of recovery mode menu entries
- #GRUB_DISABLE_RECOVERY="true"
- # Uncomment to get a beep at grub start
- #GRUB_INIT_TUNE="480 440 1"
- EOL
- chroot /mnt /usr/sbin/update-grub
- zfs snap -r rpool@base
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement