Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -e # Exit on error
- DEVICE=/dev/vda
- release="focal"
- apt-get update
- apt-get install -y \
- debootstrap \
- gdisk \
- gparted \
- dosfstools
- sgdisk --zap-all ${DEVICE}
- sgdisk --clear ${DEVICE}
- sgdisk -n1:0:+2G -t1:ef00 ${DEVICE}
- sgdisk -n2:0:0 -t2:8300 ${DEVICE}
- mkfs.ext4 -F ${DEVICE}2
- mount ${DEVICE}2 /mnt
- debootstrap focal /mnt
- mount -o bind /dev /mnt/dev
- mount -o bind /dev/pts /mnt/dev/pts
- mount -t sysfs /sys /mnt/sys
- mount -t proc /proc /mnt/proc
- mkdosfs -F 32 -s 1 -n EFI /dev/vda1
- mkdir -p /mnt/boot/efi
- cat > /mnt/etc/apt/sources.list << EOFSOURCES
- deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse
- deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
- deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
- deb http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse
- EOFSOURCES
- echo "ubuntu_ai-`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 9 | head -n 1`" > /mnt/etc/hostname
- echo "nameserver 8.8.8.8" > /mnt/etc/resolv.conf
- echo "/dev/disk/by-uuid/$(ls -lha /dev/disk/by-uuid/|grep vda1|awk '{print $9}')" /boot/efi vfat defaults 0 0 >> /mnt/etc/fstab
- mkdir /mnt/boot/efi/grub /mnt/boot/grub
- echo /boot/efi/grub /boot/grub none defaults,bind 0 0 >> /mnt/etc/fstab
- echo "/dev/disk/by-uuid/$(ls -lha /dev/disk/by-uuid/|grep vda2|awk '{print $9}')" / ext4 errors=remount-ro 0 1 >> /mnt/etc/fstab
- modprobe efivarfs
- cat << EOFSUBINSTALL | chroot /mnt
- set -e
- export HOME=/root
- export DEBIAN_FRONTEND=noninteractive
- apt-get update
- apt-get install --yes language-pack-de console-setup tzdata dosfstools efibootmgr
- mount /boot/efi
- mkdir /boot/efi/grub
- mount /boot/grub
- apt install --yes grub-pc linux-image-generic
- apt install --yes \
- grub-efi-amd64 grub-efi-amd64-signed linux-image-generic \
- shim-signed efibootmgr
- apt remove --purge os-prober
- fallocate -l 1G /swapfile
- dd if=/dev/zero of=/swapfile bs=1024 count=1048576
- chmod 600 /swapfile
- mkswap /swapfile
- swapon /swapfile
- echo /swapfile swap swap defaults 0 0 >> /etc/fstab
- grub-probe /boot
- cat > /mnt/etc/apt/sources.list << EOFGRUB
- GRUB_DEFAULT=0
- GRUB_TIMEOUT=5
- GRUB_RECORDFAIL_TIMEOUT=5
- GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Ubuntu`
- GRUB_CMDLINE_LINUX_DEFAULT=""
- GRUB_CMDLINE_LINUX=""
- GRUB_TERMINAL=console
- EOFGRUB
- update-grub
- grub-install --recheck $DEVICE
- grub-install --target=x86_64-efi --efi-directory=/boot/efi \
- --bootloader-id=ubuntu --recheck --no-floppy
- update-initramfs -v -u -t all
- echo 'root:p@ssw0rd'|chpasswd
- apt-get autoremove
- apt clean
- exit
- EOFSUBINSTALL
- echo "Fertig"
- read -p "Press enter to continue"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement