Skip to content

Instantly share code, notes, and snippets.

@andrequeiroz
Last active October 12, 2019 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrequeiroz/ebc5886be262b14b165b18024cdfff6c to your computer and use it in GitHub Desktop.
Save andrequeiroz/ebc5886be262b14b165b18024cdfff6c to your computer and use it in GitHub Desktop.
Install Arch Linux on VirtualBox over UEFI
#!/usr/bin/env bash
# if host is Arch install virtualbox-guest-utils-nox virtualbox-guest-modules-arch on guest, otherwise mount guest additions CD image after install and run ./VBoxLinuxAdditions.run
echo "Minimal Arch Linux on VirtualBox UEFI"
sleep 3s
# Keyboard layout
echo -n "Keyboard layout......."
loadkeys br-abnt2
sleep 1s
echo "ok"
# Partitioning
echo -n "Partitioning.........."
parted --script /dev/sda \
mklabel gpt \
unit mib \
mkpart primary fat32 1 257 \
mkpart primary ext4 257 2305 \
name 1 boot \
set 1 boot on \
name 2 arch
sleep 3s
echo "ok"
# Formatting
echo -n "Formatting............"
mkfs.fat -F32 /dev/sda1 > /dev/null
mkfs.ext4 -q /dev/sda2 > /dev/null
sleep 2s
echo "ok"
# Mounting partitions
echo -n "Mounting partitions..."
mount /dev/sda2 /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
echo "ok"
# Setting mirror
echo -n "Setting mirror........"
echo 'Server = http://archlinux.c3sl.ufpr.br/$repo/os/$arch' > /etc/pacman.d/mirrorlist
echo "ok"
# Installing system
echo -n "Installation.........."
pacman -Sy > /dev/null
pacstrap /mnt base dhcpcd gcc linux linux-headers make netctl perl vi > /dev/null
genfstab /mnt >> /mnt/etc/fstab
echo "ok"
# chroot script
cat << EOF > post.sh
#!/usr/bin/env bash
echo -n "Configs..."
ln -sf /usr/share/zoneinfo/Brazil/East /etc/localtime
echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen
locale-gen > /dev/null
echo 'LANG=en_US.UTF-8' > /etc/locale.conf
echo 'KEYMAP=br-abnt2' > /etc/vconsole.conf
echo 'arch' > /etc/hostname
echo '127.0.0.1 arch.linux arch localhost' > /etc/hosts
echo '::1 localhost' >> /etc/hosts
cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/Ethernet
sed -i s/eth0/enp0s3/ /etc/netctl/Ethernet
netctl enable Ethernet > /dev/null
bootctl install > /dev/null
echo 'title Arch Linux' > /boot/loader/entries/arch.conf
echo 'linux /vmlinuz-linux' >> /boot/loader/entries/arch.conf
echo 'initrd /initramfs-linux.img' >> /boot/loader/entries/arch.conf
echo 'options root=/dev/sda2 rw' >> /boot/loader/entries/arch.conf
echo 'default arch' > /boot/loader/loader.conf
echo 'timeout 10' >> /boot/loader/loader.conf
EOF
# chroot
cp post.sh /mnt
chmod +x /mnt/post.sh
arch-chroot /mnt ./post.sh > /dev/null
rm /mnt/post.sh
echo "ok"
umount -R /mnt
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment