Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # PULCZ SERVER
- #
- export LANG=C
- sgdisk --clear -Z \
- -n9:-8M:0 -t9:bf07 -c9:sda9-Reserved \
- -n1::+1M -t 1:ef02 -c 1:"BIOS Boot Partition" \
- -n2::+512M -t1:EF00 -c2:'EFI-SDA2' \
- -n3::+200G -t2:bf01 -c3:'sda3-zfs root filesystem' \
- -n4:0:0 -t2:bf01 -c4:'sda4-zfs data' \
- /dev/sda
- sgdisk -t 1:ef02 /dev/sda
- sgdisk --clear -Z \
- -n9:-8M:0 -t9:bf07 -c9:sdb9-Reserved \
- -n1::+1M --typecode=1:ef02 --change-name=1:'sdb1 - BIOS boot partition' \
- -n2::+512M -t1:EF00 -c2:'EFI-SDB2' \
- -n3::+200G -t2:bf01 -c3:'sdb2-zfs root filesystem' \
- -n4:0:0 -t2:bf01 -c4:'sdb3-zfs data' \
- /dev/sdb
- sgdisk -t 1:ef02 /dev/sdb
- sgdisk --clear -Z \
- -n9:-8M:0 -t9:bf07 -c9:sdc9-Reserved \
- -n1::+1M --typecode=1:ef02 --change-name=1:'sdc1 - BIOS boot partition' \
- -n2::+512M -t1:EF00 -c2:'EFI-SDC2' \
- -n3::+200G -t2:bf01 -c3:'sdc3-zfs root filesystem' \
- -n4:0:0 -t2:bf01 -c4:'sdc4-zfs data' \
- /dev/sdc
- sgdisk -t 1:ef02 /dev/sdc
- sgdisk --clear -Z \
- -n9:-8M:0 -t9:bf07 -c9:sdd9-Reserved \
- -n1::+1M --typecode=1:ef02 --change-name=1:'sdd1 - BIOS boot partition' \
- -n2::+512M -t1:EF00 -c2:'EFI-SDD2' \
- -n3::+200G -t2:bf01 -c3:'sdd3-zfs root filesystem' \
- -n4:0:0 -t2:bf01 -c4:'sdd4-zfs data' \
- /dev/sdd
- sgdisk -t 1:ef02 /dev/sdd
- cat /proc/partitions
- ls -lh /dev/disk/by-partlabel
- apt update
- apt -y install zfsutils-linux
- mkdir -p /target
- zpool create -f -O recordsize=64K -o ashift=12 -O atime=off -O canmount=off -O compression=lz4 -O normalization=formD -O mountpoint=/ -R /target systempool mirror /dev/sda3 /dev/sdb3
- zpool create systempool spare /dev/sdc3 /dev/sdd3
- zpool create -f matrixdatas -o ashift=12 -O atime=off -O canmount=off -O compression=lz4 -O normalization=formD \
- -O mountpoint=/srv/matrixdatas mirror /dev/sda4 /dev/sdb4
- zpool create matrixdatas spare /dev/sdc4 /dev/sdd4
- zpool status
- zfs create -o canmount=off -o mountpoint=none systempool/ROOT
- zfs create -o canmount=noauto -o mountpoint=/ -o exec=on -o setuid=on -o devices=on systempool/ROOT/ubuntu
- zfs mount systempool/ROOT/ubuntu
- zpool set bootfs=systempool/ROOT/ubuntu systempool
- zfs set exec=off systempool
- zfs set setuid=off systempool
- zfs set devices=off systempool
- zfs create -o canmount=off systempool/var
- ## zfs create -o canmount=off mountpoint=systempool/var
- #cannot create 'mountpoint=systempool/var': invalid character '=' in name
- zfs create -o canmount=off systempool/var/lib
- zfs create systempool/var/lib/apt
- zfs create -o exec=on systempool/var/lib/dpkg
- zfs create systempool/var/log
- zfs create -o com.sun:auto-snapshot=false systempool/var/tmp
- zfs create -o com.sun:auto-snapshot=false systempool/var/cache
- zfs create -o com.sun:auto-snapshot=false systempool/var/cache/apt
- zfs create systempool/var/spool
- zfs create systempool/var/mail
- zfs create -o com.sun:auto-snapshot=false -o exec=on systempool/tmp
- zfs create -o exec=on systempool/root
- zfs create -o mountpoint=/home systempool/home
- zfs create -o mountpoint=/srv systempool/srv
- df -h
- zfs list
- chmod 1777 /target/tmp
- chmod 1777 /target/var/tmp
- apt -y install debootstrap
- debootstrap --include=zfsutils-linux bionic /target
- echo matrixcbs > /target/etc/hostname
- echo "127.0.1.1 server.matrixcbs.lan matrixcbs" >> /target/etc/hosts
- cat <<EOF > /target/etc/netplan/00-lan-config.yaml
- # This file is generated from information provided by
- # the datasource. Changes to it will not persist across an instance.
- # To disable cloud-init's network configuration capabilities, write a file
- # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
- # network: {config: disabled}
- network:
- ethernets:
- enp2s0:
- dhcp4: true
- version: 2
- EOF
- cat <<EOF > /target/configure.sh
- #!/bin/bash
- apt update
- apt -y full-upgrade
- apt -y install language-pack-hu
- dpkg-reconfigure locales
- dpkg-reconfigure debconf
- dpkg-reconfigure tzdata
- export LANG=C
- apt install --yes hfsprogs
- apt install -y --no-install-recommends linux-image-generic --force-yes
- apt install -y gdisk dosfstools zfs-initramfs
- apt -y install grub-efi grub-pc mkdosfs
- apt install --yes grub-efi-amd64-signed shim-signed
- grub-install /dev/sda
- grub-install /dev/sdb
- grub-install /dev/sdc
- grub-install /dev/sdd
- grub-install --root-directory=/mnt/main /dev/sda
- grub-install --root-directory=/mnt/main /dev/sdb
- grub-install --root-directory=/mnt/main /dev/sdc
- grub-install --root-directory=/mnt/main /dev/sdd
- update-grub2
- mkdosfs -F 32 -n EFI-SDA2 /dev/sda2
- mkdosfs -F 32 -n EFI-SDB2 /dev/sdb2
- mkdosfs -F 32 -n EFI-SDC2 /dev/sdc2
- mkdosfs -F 32 -n EFI-SDD2 /dev/sdd2
- mkdir /boot/efi
- # olds echo PARTUUID=$(blkid -s PARTUUID -o value /dev/disk/by-partlabel/sda2-EFI) /boot/efi vfat defaults 0 1 >> /etc/fstab
- echo PARTUUID=$(blkid -s PARTUUID -o value /dev/disk/by-partlabel/sda2-EFI) /boot/efi vfat nofail,x-systemd.device-timeout=1 0 1 >> /etc/fstab
- mount /boot/efi
- grub-probe /
- update-initramfs -u -k all
- update-grub
- grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy
- echo '\EFI\ubuntu\grubx64.efi' > /boot/efi/startup.nsh
- ls /boot/grub/*/zfs.mod
- apt -y ssh nano lshw rsync mc lswh ethtool di
- /bin/bash
- EOF
- cat <<EOF >> /etc/apt/sources.list
- deb http://archive.ubuntu.com/ubuntu bionic main
- deb http://archive.ubuntu.com/ubuntu bionic-updates main
- deb http://security.ubuntu.com/ubuntu bionic-security main
- deb http://archive.ubuntu.com/ubuntu/ bionic universe
- deb http://archive.ubuntu.com/ubuntu/ bionic-updates universe
- deb http://security.ubuntu.com/ubuntu bionic-security universe
- EOF
- chmod +x /target/configure.sh
- mount --rbind /dev /target/dev
- mount --rbind /proc /target/proc
- mount --rbind /sys /target/sys
- chroot /target /bin/bash
- ./configure.sh
- umount -Rfl /target/dev
- umount -Rfl /target/sys
- umount -Rfl /target/proc
- umount /target/boot/efi
- zpool export systempool
- echo DONE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement