mirror of https://github.com/Chizi123/Scripts.git

Joel Grunbaum
2021-08-31 91849229d535bc15f7bc165afcf2c0f963db9909
commit | author | age
3b93d4 1 #!/bin/bash
10ca25 2 # Basic install script for an archlinux VM
JG 3 # To use as a basic hardware install script, remove qemu-guest-agent from pacstrap's arguments and qemu-ga from systemctl
4 # Can comment out my repository if you like, I tend to use it for my VMs
3b93d4 5
JG 6 HOSTNAME=VM
7 RPASS=root
2d9860 8 DISK=/dev/vda
JG 9 PARTNO=1
10 LOCALE=en_US.UTF-8
10ca25 11 TIMEZONE=UTC # location in zoneinfo, e.g. Australia/Melbourne
3b93d4 12
10ca25 13 # Partition disk will create a new partition on the rest of the empty free space
d5dc58 14 printf "n\np\n\n\n\nw\n" | fdisk $DISK
6840e6 15 mkfs.btrfs "$DISK$PARTNO"
3b93d4 16
JG 17 # Mount and install
6840e6 18 mount -o compress=zstd "$DISK$PARTNO" /mnt
afe40b 19 pacstrap /mnt base linux linux-firmware grub dhcpcd vim qemu-guest-agent btrfs-progs
3b93d4 20 genfstab -U /mnt >> /mnt/etc/fstab
JG 21
2d9860 22 # Setup locale
10ca25 23 arch-chroot /mnt ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
2d9860 24 sed -i -e "s/#$LOCALE/$LOCALE/" /mnt/etc/locale.gen
JG 25 arch-chroot /mnt locale-gen
26 echo "LANG=$LOCALE" > /mnt/etc/locale.conf
d5dc58 27
JG 28 # Set hostname and make hosts file
2d9860 29 echo $HOSTNAME > /mnt/etc/hostname
JG 30 printf "127.0.0.1\tlocalhost\n::1\t\tlocalhost\n127.0.1.1\t$HOSTNAME.localdomain $HOSTNAME" > /mnt/etc/hosts
d5dc58 31
JG 32 # Enable networking on boot and qemu guest agent
2d9860 33 arch-chroot /mnt systemctl enable dhcpcd qemu-ga
d5dc58 34
JG 35 # Make boot files and setup grub
2d9860 36 arch-chroot /mnt mkinitcpio -P
JG 37 arch-chroot /mnt sh -c "echo root:$RPASS | chpasswd"
4f2641 38 sed -i "s/GRUB_TIMEOUT=\d*/GRUB_TIMEOUT=\"0\"/" /mnt/etc/default/grub
2d9860 39 arch-chroot /mnt grub-install $DISK
JG 40 arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
3b93d4 41
d5dc58 42 # Add my repo to pacman.conf
JG 43 printf "[Chizi123]\nSigLevel = Optional TrustAll\nServer = https://repo.joelg.cf/x86_64\n" >> /mnt/etc/pacman.conf
44
3b93d4 45 reboot