Advertisement
echoslider

finish_ubuntu_deployment_minbase

Aug 4th, 2021 (edited)
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.96 KB | None | 0 0
  1. sudo su
  2. setxkbmap de
  3.  
  4. apt-get update
  5.  
  6. apt-get install --yes debootstrap
  7.  
  8. blkdiscard /dev/vda
  9. sgdisk --zap-all /dev/vda
  10.  
  11. sgdisk     -n1:1M:+512M   -t1:EF00 /dev/vda
  12. sgdisk     -n2:0:+2G      -t2:BE00 /dev/vda
  13. sgdisk     -n3:0:+6G    -t3:8200 /dev/vda
  14. sgdisk     -n4:0:0        -t4:BF00 /dev/vda
  15.  
  16. mkfs.ext4 /dev/vda4
  17. mount /dev/vda4 /mnt
  18.  
  19. debootstrap \
  20. --arch=amd64 \
  21. --variant=minbase \
  22. focal \
  23. /mnt \
  24. http://us.archive.ubuntu.com/ubuntu/
  25.  
  26. mount -o bind /dev /mnt/dev
  27. mount -o bind /dev/pts /mnt/dev/pts
  28. mount -t sysfs /sys /mnt/sys
  29. mount -t proc /proc /mnt/proc
  30.  
  31. cp /proc/mounts /mnt/etc/mtab
  32. cp /etc/resolv.conf /mnt/etc/resolv.conf
  33. cp /etc/apt/sources.list /mnt/etc/apt/sources.list
  34.  
  35. chroot /mnt
  36.  
  37. echo "DESKTOP-`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 9 | head -n 1`" > /etc/hostname
  38. echo "nameserver 8.8.8.8" >> /etc/resolv.conf
  39.  
  40. apt-get update
  41.  
  42. apt-get install language-pack-de
  43. apt-get install console-setup
  44.  
  45. dpkg-reconfigure tzdata
  46.  
  47. apt install -y --no-install-recommends \
  48.     linux-generic  \
  49.     iputils-ping dnsutils lsof isc-dhcp-client dhcpcd5 iproute2 net-tools netplan.io locales localepurge nano \
  50.     dosfstools vim gdisk
  51.  
  52. cat >> /etc/netplan/01-netcfg.yaml << EOF
  53. network:
  54.   version: 2
  55.   ethernets:
  56.     enp1s0:
  57.       dhcp4: true
  58. EOF
  59.  
  60. mkdosfs -F 32 -s 1 -n EFI /dev/vda1
  61. mkdir /boot/efi1
  62.  
  63.  
  64. echo /dev/disk/by-uuid/$(blkid -s UUID -o value /dev/vda1) \
  65.     /boot/efi1 vfat defaults 0 0 >> /etc/fstab
  66.  
  67. mount /boot/efi1
  68. mkdir /boot/efi1/grub
  69. mkdir /boot/grub1
  70.  
  71. echo /boot/efi1/grub /boot/grub1 none defaults,bind 0 0 >> /etc/fstab
  72.  
  73. mount /boot/grub1
  74.  
  75. apt install --yes \
  76.     grub-efi-amd64 grub-efi-amd64-signed \
  77.     shim-signed
  78.  
  79. passwd
  80.  
  81. mkswap -f /dev/vda3
  82.  
  83. echo /dev/disk/by-uuid/$(blkid -s UUID -o value /dev/vda3) \
  84.     none swap discard 0 0 >> /etc/fstab
  85.  
  86. echo /dev/disk/by-uuid/$(blkid -s UUID -o value /dev/vda4) \
  87.     / ext4 errors=remount-ro 0       1 >> /etc/fstab
  88.  
  89. cp /usr/share/systemd/tmp.mount /etc/systemd/system/
  90. systemctl enable tmp.mount
  91.  
  92. addgroup --system lpadmin
  93. addgroup --system lxd
  94. addgroup --system sambashare
  95.  
  96. apt-get install -y initramfs-tools
  97.  
  98.  
  99. update-initramfs -c -k all
  100.  
  101. cat > /etc/default/grub << EOF
  102. GRUB_DEFAULT=0
  103. GRUB_TIMEOUT=5
  104. GRUB_RECORDFAIL_TIMEOUT=5
  105. GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Ubuntu`
  106. GRUB_CMDLINE_LINUX_DEFAULT=""
  107. GRUB_CMDLINE_LINUX=""
  108. GRUB_TERMINAL=console
  109. EOF
  110.  
  111. update-grub
  112.  
  113. grub-install --target=x86_64-efi --efi-directory=/boot/efi1 \
  114.     --bootloader-id=ubuntu --recheck --no-floppy
  115.  
  116. apt install --yes openssh-server mlocate
  117.  
  118. adduser serveradmin
  119.  
  120. cp -a /etc/skel/. /home/serveradmin
  121. chown -R serveradmin:serveradmin /home/serveradmin
  122. chmod -R o-rwx /home/serveradmin
  123. usermod -a -G adm,cdrom,dip,lpadmin,lxd,plugdev,sambashare serveradmin
  124.  
  125. for file in /etc/logrotate.d/* ; do
  126.     if grep -Eq "(^|[^#y])compress" "$file" ; then
  127.         sed -i -r "s/(^|[^#y])(compress)/\1#\2/" "$file"
  128.     fi
  129. done
  130.  
  131. exit
  132.  
  133. reboot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement