Last active
February 7, 2022 13:00
-
-
Save tvidal-net/2c2409306720ba291e2dc61be5b14d2c to your computer and use it in GitHub Desktop.
archlinux min install for private use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eo pipefail | |
# create swap and linux partitions and set bootable flag | |
sfdisk /dev/vda <<EOF | |
label: dos | |
, 1G, swap | |
,, linux, * | |
EOF | |
# format partitions | |
mkswap -L swap /dev/vda1 | |
mkfs.ext4 -L linux /dev/vda2 | |
# use/mount partitions | |
swapon /dev/vda1 | |
mount /dev/vda2 /mnt | |
# grab fastest mirrors | |
reflector -c GB -f 2 -p https \ | |
--save /etc/pacman.d/mirrorlist | |
# install basic packages | |
pacstrap /mnt \ | |
base base-devel \ | |
linux linux-firmware \ | |
devtools dhcpcd syslinux \ | |
vim || true | |
# generate fstab with uuids | |
genfstab -U /mnt | tee -a /mnt/etc/fstab | |
# replace image mirrorlist | |
cp -vf /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist | |
# into chroot: | |
arch-chroot /mnt | |
# basic config | |
locale-gen | |
echo 'LANG=en_GB.UTF-8' > /etc/locale.conf | |
echo 'archlinux' > /etc/hostname | |
ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime | |
# dev user | |
groupadd -r -g 10 sudo | |
useradd -m -u 1000 -g users -G sudo dev | |
passwd -d dev | |
# enable sudo | |
sed -i.old -E 's!(#.)?%sudo(.*)ALL!%sudo\2NOPASSWD:ALL!gi' /etc/sudoers | |
# enable network | |
systemctl enable dhcpcd | |
# create a new initramfs | |
mkinitcpio -P | |
# fix bootloader drive | |
sed -i.old -E \ | |
-e 's:/dev/sda3:/dev/vda2 console=ttyS0:' \ | |
-e 's:(TIMEOUT ).*$:\110:' \ | |
/boot/syslinux/syslinux.cfg | |
# leave chroot | |
exit | |
# install bootloader | |
syslinux-install_update -ami -c /mnt | |
# finish | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment