Thursday | 21 NOV 2024
[ previous ]
[ next ]

Installing Arch Linux

Title:
Date: 2023-09-23
Tags:  installation

I have a desktop with an Nvidia card that I want to dual boot Windows and Linux. I decided to go with Arch because it's been awhile since I last used it and I think it would be fun to use.

The goal is to set everything up and ultimately do a lot more hacking of random stuff in my environment. Not sure what yet but I'm sure I'll get to something once I have everything set up.

Preparing Windows

The first step is to shrink Windows. I used the MiniTool Partition Wizard to resize my C: so that I could get some space to install Arch.

MiniTool Partition Wizard

I resized the C directory and so this required my computer to reboot and then minitool ran the partitioning function. It was very strange to see my computer get into a weird intermediate state of half booted up but running code.

During this step if you can increase the size of efi boot area you definitely should. I had already started so I wasn't able to do that and now I have my Linux grub set up in a different place than the efi boot stuff.

The effect of that is now I need to use my boot priority directly to boot into Windows. If I had increased the efi size I think I would have been able to select Windows or Linux from the grub boot manager.

Installing Arch Linux

Get the installation iso:

Arch Linux Downloads

I used the following link:

Canada Waterloo Mirror

Use Rufus to create the bootable usb.

Rufus Download

Restart your computer and change the boot priority to use usb first. This way you should be able to start your computer and boot into the Arch Linux installer.

Connect to the Internet

Next we need to connect to the internet. This step isn't really required as it looks like arch will automatically use dhcp to get an ip address.

You can do ip link to check the interfaces:

ip link

Test if you can reach the arch site:

ping archlinux.org

Update the clock:

timedatectl

Create Partitions

Now we can use cfdisk to create the arch partition. I have an nvme harddrive and this required a bit of fiddling for cfdisk to actually pick it up.

Use lsblk to see all the blocks available:

lsblk

By default cfdisk only sees regular hard drives, I had to specify the nvme device from lsblk:

cfdisk /dev/nvme0n1

We need to create a / root partition that will be the bulk.

mkfs.ext4 /dev/nvme0n1p5
mount /dev/nvme01n1p5 /mnt

Due to my efi being too small I was unable to follow the arch instructions. Instead I created an /efi directory and mounted the efi there.

mkdir /mnt/efi

Mount the efi directory:

mount /dev/nvme0n1p1 /mnt/efi

Install Arch Linux

Next we install arch:

pacstrap -K /mnt base linux linux-firmware

Configure Arch Linux

Once installed:

genfstab -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt
ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
hwclock --systohc

Set up the localization

Uncomment en_US.UTF-8 from /etc/locale.gen

locale-gen

Create /etc/locale.conf

LANG=en_US.UTF-8

Set the hostname/etc/hostname

perseus

Set Up the Boot Loader

We need to install the grub booter manager and efi boot manager for windows.

pacman -S grub efibootmgr

Now we can generate the grub configuration.

grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg

Set a root passwd as you will need it to log in when we reboot:

passwd

Install vim:

pacman -Sy vim

Reboot the system:

reboot

Once the system comes back up we should be able to select Arch Linux as our OS.

Post Installation Steps

Now we should have a working arch system. The next steps will be set up networking, a user and then get nvidia drivers and sway working.

Network Connectivity

I couldn't get netctl working so I used systemd-network.

Enable systemd-network:

systemctl enable systemd-networkd.service

Create the below file:

touch /etc/systemd/network/20-wired.network

Add the following:

[Match]
Name=enp3s0

[Network]
Address=192.168.3.13/24
Gateway=192.168.3.1
DNS=1.1.1.1

You may need to reboot to get everything working.

Install nvidia drivers

Before we can get a desktop environment, we need to first set up the nvidia graphic cards.

Get the latest drivers.

pacman -Sy nvidia

Remove kms from the HOOKS array /etc/mkinitcpio.conf.

We then regenerate the the initramfs.

mkinitcpio -P

We also need to make sure nvidia can see all the monitors. This involves update the grub bootloader.

Update /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet nvidia-drm.modeset=1"

Regenerate grub:

grub-mkconfig -o /boot/grub/grub.cfg

Reboot

reboot

Install Sway

Now that we have nvidia set up, I should be able to just install sway and run it.

pacman -Sy sway

Type sway to start up.

sway

To exit sway, press the keys:

Windows Logo + Shift + E

This will show an orange bar at the top asking if you want to exit sway. Sway yes as we currently don't have the foot terminal install yet.

Use the Awesome Wayland repo to find useful utilities.

Awesome Wayland

I use the nwg-displays to manage the displays.

I use tofi to launch programs.

Install Sudo

We need to install the sudo package:

pacman -Sy sudo

We then update /etc/sudoers and uncomment the wheel line:

%wheel ALL=(ALL:ALL) ALL

Now we can create a user and add them to the wheel group so we can run things with sudo. This should let us stop using root to do everything.

Create a User

Now we can create a user:

useradd -m -G wheel -s /bin/bash username
passwd username

We should now be able to log in as the newly created user.

Install Foot

We need to install the foot terminal so we can use the Windows Logo + Enter to open a terminal in sway.

sudo pacman -Sy foot

Copy the foot config file:

mkdir -p ~/.config/foot/
cp /etc/xdg/foot/foot.ini ~/.config/foot/foot.init 

I updated my foot.ini file to have a larger font size and a black background.

font=monospace:size=16
...
background=000000

Setting Up Sway

I also wanted to add gaps to sway.

For this I needed to copy over the sway config:

mkdir -p ~/.config/sway
cp /etc/sway/config ~/.config/sway/config

I then added the following line to the config:

gaps inner 10

At this point I have a pretty usable system.

References

Arch Installation Guide

Dual Boot Arch Linux and Windows 10

Nvidia - Arch Linux Wiki