Recipe: Set up Arch Linux workstation on a physical x86_64
computer
/docs/other/developer-workstation/arch-x86_64/physical/
Note
This recipe assumes you have an x86_64
computer with a disk that will be
completely erased.
Note
This recipe also assumes that the disk comes up at /dev/sda
, like
most SATA disks do. If youd computer uses NVMe, that device may be /dev/nvme0n1
or the like; make the appropriate changes below.
Obtain an Arch Linux image
-
Download an ISO from a mirror listed on https://archlinux.org/download/ (e.g.
archlinux-2024.11.01-x86_64.iso
) -
Write this ISO image to a USB stick, such as by following the instructions here.
Boot your x86_64
computer from the USB stick
-
This may require changing the settings in your computer’s BIOS. Details depends on your particular hardware.
-
Wait until the boot sequence ends and the root shell appears.
Install Arch on the empty disk and configure it
-
Update the bootstrap VM and install some packages we need:
# pacman -Sy # pacman -S archlinux-keyring # pacman -Su # pacman -S btrfs-progs gptfdisk parted dosfstools arch-install-scripts vi
-
Zero out the first bytes on the disk for extra robustness:
# dd if=/dev/zero of=/dev/sda bs=1M count=8 conv=notrunc
-
Clear the partition table:
# sgdisk --clear /dev/sda
-
Create the partitions (UEFI,
/boot
,/
and swap) and change them to the right types:# sgdisk --new=1::+1M /dev/sda # sgdisk --new=2::+512M /dev/sda # sgdisk --new=4::+8G /dev/sda # sgdisk --new=3:: /dev/sda # sgdisk --typecode=1:EF02 /dev/sda # sgdisk --typecode=2:EF00 /dev/sda # sgdisk --typecode=4:8200 /dev/sda
Partition number 4 is the swap partition. Choose a size that is appropriate for your machine. Here we choose 8GB.
-
Make sure changes are in effect:
# sync # partprobe /dev/sda
-
Create filesystems for the `/boot and root partitions:
# mkfs.vfat /dev/sda2 # mkfs.btrfs /dev/sda3
-
Mount the partitions so we can install:
# mount /dev/sda3 /mnt # mkdir /mnt/boot # mount /dev/sda2 /mnt/boot
-
Perform the actual install of the base packages:
# pacstrap /mnt base
-
Generate the right
fstab
:# genfstab -U -p /mnt >> /mnt/etc/fstab
-
Chroot into your future root disk and continue the installation:
# arch-chroot /mnt
-
Install more packages:
# pacman -Sy # pacman -S linux grub mkinitcpio sudo vim btrfs-progs virtualbox-guest-utils \ gdm gnome-console gnome-control-center gnome-session gnome-settings-daemon \ gnome-shell gnome-keyring nautilus
If asked which alternatives to install, choose the defaults.
-
Check that the auto-generated content of
/etc/pacman.d/mirrorlist
makes sense. Edit accordingly. -
Create a ramdisk:
# mkinitcpio -p linux
-
Configure the UEFI boot loader:
# bootctl --path /boot install
-
Configure grub. This is redundant given we also have a UEFI boot loader, but some people prefer a setup in which to boot from legacy BIOS.
# grub-install --target=i386-pc --boot-directory=/boot --recheck /dev/sda # grub-mkconfig -o /boot/grub/grub.cfg
-
Install a locale:
# perl -pi -e 's!#en_US.UTF-8 UTF-8!en_US.UTF-8 UTF-8!' /etc/locale.gen # locale-gen
-
Set up networking:
# echo '[Match]' > /etc/systemd/network/wired.network # echo 'Name=en*' >> /etc/systemd/network/wired.network # echo '' >> /etc/systemd/network/wired.network # echo '[Network]' >> /etc/systemd/network/wired.network # echo 'DHCP=ipv4' >> /etc/systemd/network/wired.network # echo 'IPv4Forwarding=1' >> /etc/systemd/network/wired.network # echo 'IPv6Forwarding=1' >> /etc/systemd/network/wired.network # systemctl enable systemd-networkd systemd-resolved systemd-timesyncd
-
Create a user with the right permissions and a password:
# useradd -m ubosdev # chmod 755 ~ubosdev # passwd ubosdev # echo ubosdev ALL = NOPASSWD: ALL > /etc/sudoers.d/ubosdev # chmod 600 /etc/sudoers.d/ubosdev
-
Set a root password:
# passwd root
-
Exit from the
arch-chroot
shell with^D
.
-
-
Remainder of networking setup:
# rm /mnt/etc/resolv.conf # ln -s /run/systemd/resolve/stub-resolv.conf /mnt/etc/resolv.conf
-
Configure UEFI:
-
Loader configuration:
# echo timeout 4 > /mnt/boot/loader/loader.conf # echo default arch >> /mnt/boot/loader/loader.conf
-
Boot entry configuration:
# echo title Arch > /mnt/boot/loader/entries/arch.conf # echo linux /vmlinuz-linux >> /mnt/boot/loader/entries/arch.conf # echo initrd /initramfs-linux.img >> /mnt/boot/loader/entries/arch.conf # echo options root=PARTUUID=$(lsblk -o PARTUUID /dev/sda3 | tail -1 ) rw >> /mnt/boot/loader/entries/arch.conf
-
-
Power off the machine:
# systemctl poweroff
-
Remove the USB boot stick.
Remaining configuration
-
Start the
x86_64
computer again. -
At the console, log in as
ubosdev
with the password you specified earlier. -
Fix the locale (command won’t run earlier)
% sudo localectl set-locale LANG=en_US.UTF-8
-
Add swap space
% sudo mkswap /dev/sda4 % sudo swapon /dev/sda4 % sudo genfstab -U -p /
In the output of the last command, there is one more line than contained in the
/etc/fstab
file, which activates swap space. Add that line to/etc/fstab
. -
Enable Gnome:
% sudo systemctl enable gdm
-
Power off the virtual machine:
% sudo systemctl poweroff