-
-
Save researcx/e3b0476f2f75165f004773f8add4a7ad to your computer and use it in GitHub Desktop.
Minimal instructions for installing Arch Linux on GPT or MBR on UEFI or Legacy BIOS
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
# Download an Arch ISO from https://www.archlinux.org and copy it to a USB drive: | |
sudo dd bs=4M if=archlinux-2019.01.01-x86_64.iso of=/dev/sdb status=progress oflag=sync | |
# then plug it into the device of your preference, boot it and start the installation process. | |
# Installation process: | |
# Set UK keymap | |
loadkeys uk | |
# Set up partitions (MBR) | |
parted /dev/sdX mklabel msdos | |
cfdisk /dev/sdX | |
# 1 - 1G primary partition, set the bootable flag | |
# 2 - 100% primary partition | |
# OR | |
# Set up partitions (GPT) | |
cgdisk /dev/sdX | |
# 1 - [ EFI: 100M | Legacy: 1G ] partition # Hex code: [ EFI: ef00 | Legacy: ef02 ] | |
# 2 - 250M partition # Hex code 8300 ( Not needed for a legacy install, if you chose not to make this partition, /dev/sdX3 becomes /dev/sdX2 in this guide! ) | |
# 3 - 100% partiton # Hex code 8300 | |
# May need to reboot here if any of the next commands fail with an error! | |
# reboot | |
# Set the filesystems | |
#Legacy: | |
mkfs.ext2 /dev/sdX1 | |
#OR | |
#EFI: | |
mkfs.vfat -F32 /dev/sdX1 | |
mkfs.ext2 /dev/sdX2 | |
# Create the encryptied partitions | |
cryptsetup luksFormat --type luks2 --cipher aes-xts-plain64 --key-size 512 --hash sha256 /dev/sdX3 | |
cryptsetup luksOpen /dev/sdX3 sysroot | |
# Set up LVM | |
pvcreate /dev/mapper/sysroot | |
vgcreate arch /dev/mapper/sysroot | |
lvcreate --size 2G arch --name swap | |
lvcreate -l +100%FREE arch --name root | |
# Set the filesystems | |
mkfs.xfs /dev/mapper/arch-root | |
mkswap /dev/mapper/arch-swap | |
# Mount the new filesystem | |
mount /dev/mapper/arch-root /mnt | |
swapon /dev/mapper/arch-swap | |
mkdir /mnt/boot | |
# Legacy: | |
mount /dev/sdX1 /mnt/boot | |
# OR | |
# EFI: | |
mount /dev/sdX2 /mnt/boot | |
mkdir /mnt/boot/efi | |
mount /dev/sdX1 /mnt/boot/efi | |
# Enable wifi if required | |
wifi-menu | |
# Install the system and necessary/favorable utilities, make sure to change this! | |
pacstrap /mnt base base-devel fish nano vim git efibootmgr grub grub-efi-x86_64 dialog wpa_supplicant lsb-release | |
# Set up fstab | |
genfstab -pU /mnt >> /mnt/etc/fstab | |
# Edit fstab if using an SSD: change relatime on all non-boot partitions to noatime and add discard | |
nano /mnt/etc/fstab | |
# Chroot into the newly installed arch system | |
arch-chroot /mnt /bin/fish | |
# Setup system clock (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) | |
ln -sf /usr/share/zoneinfo/Europe/Jersey /etc/localtime | |
hwclock --systohc --utc | |
# Set hostname | |
echo somehostname > /etc/hostname | |
# Update locales | |
nano /etc/locale.gen # uncomment the line containing en_US.UTF-8 UTF-8 | |
echo LANG=en_US.UTF-8 >> /etc/locale.conf | |
locale-gen | |
# Set root password | |
passwd | |
# Add a new user (remove -s /bin/fish if you want bash instead) | |
useradd -m -g users -G wheel -s /bin/fish MYUSERNAME | |
passwd MYUSERNAME | |
# Configure suders | |
nano /etc/sudoers | |
# Uncomment the line containing %wheel ALL=(ALL) ALL | |
# Configure mkinitcpio | |
nano /etc/mkinitcpio.conf | |
# Add 'keymap encrypt lvm2 resume' to HOOKS just before 'filesystems' | |
# Set up a bootloader (choose between legacy and EFI): | |
# Legacy (grub) | |
grub-install --target=i386-pc /dev/sdX | |
# If you encounter "WARNING: Device /dev/xxx not initialized in udev database even after waiting 10000000 microseconds." you may need to provide /run/lvm/ access to the chroot environment using: | |
exit # exit out of the chroot for the time being | |
mkdir /mnt/hostlvm | |
mount --bind /run/lvm /mnt/hostlvm | |
arch-chroot /mnt /bin/fish | |
ln -s /hostlvm /run/lvm | |
# You will need to re-run the "grub-install" command as instructed above after this. | |
nano /etc/default/grub | |
# Set GRUB_CMDLINE_LINUX as "cryptdevice=/dev/sdX3:luks root=/dev/mapper/arch-root resume=/dev/mapper/arch-swap" | |
# and uncomment the line containing GRUB_ENABLE_CRYPTODISK=y | |
grub-mkconfig -o /boot/grub/grub.cfg | |
# OR | |
# EFI (grub) | |
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ArchLinux | |
nano /etc/default/grub | |
# Set GRUB_CMDLINE_LINUX as "cryptdevice=/dev/sdX3:luks root=/dev/mapper/arch-root resume=/dev/mapper/arch-swap" | |
# and uncomment the line containing GRUB_ENABLE_CRYPTODISK=y | |
# OR | |
# EFI (systemd-boot) | |
bootctl --path=/boot/efi install | |
nano /boot/efi/loader/entries/arch.conf | |
# Set options as follows: | |
#title Arch Linux | |
#linux /vmlinuz-linux | |
#initrd /initramfs-linux.img | |
#initrd /initramfs-linux-fallback.img | |
#options cryptdevice=/dev/sdX3:lvm root=/dev/mapper/arch-root resume=/dev/mapper/arch-swap rw | |
# Regenerate initrd image | |
mkinitcpio -p linux | |
# Exit the chroot | |
exit | |
# Unmount all partitions | |
umount -R /mnt | |
swapoff -a | |
# Reboot into your new Arch Linux install. | |
reboot | |
# If at any time you need to get back into chroot via installation media: | |
cryptsetup luksOpen /dev/sdX3 sysroot | |
mount /dev/mapper/arch-root /mnt | |
# Legacy: | |
mount /dev/sdX1 /mnt/boot | |
# OR | |
# EFI: | |
mount /dev/sdX2 /mnt/boot | |
mount /dev/sdX1 /mnt/boot/efi | |
arch-chroot /mnt /bin/fish |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment