💾 Archived View for sbg.one › gemlog › 2019 › 08-24-Arch-Linux-Install-Tutorial.gmi captured on 2021-12-04 at 18:04:22. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
August 24, 2019
In this tutorial I'll walk you through, step by step, on how to install Arch Linux on a computer. These steps can also be done in a virtual machine as well in case you want to practice first, which is recommended.
I used these very steps myself on a new build PC earlier today. The very same PC I'm using to write this tutorial on, in fact.
You'll want to get the latest ISO file from the Arch Linux wiki here:
https://www.archlinux.org/download/
Be very careful with this command. dd is sometimes called disk destroyer because it will wipe everything on the target disk you specify. Ensure you know what you're doing before executing this command.
dd bs=4M if=path/to/archlinux.iso of=/dev/sdx status="progress" oflag=sync
Once your portable USB installer is ready plug it into the computer where you want to install Arch Linux. Turn the computer on and make sure you can boot to the USB drive. You may need to press F2, F12 or DEL to get to the BIOS/UEFI settings to set the boot order. Check your motherboard documentation on which button to press at startup.
Once you are booted to the Arch Linux USB drive you will be greeted with a a command prompt.
Check if you have a BIOS or UEFI system. This tutorial will cover installing on a BIOS, which is usually recommended over the newer UEFI.
ls /sys/firmware/efi/efivars
If you get nothing in response to the above command, then you probably have a BIOS. If you get a bunch of files listed, then you have a UEFI. Some motherboards allow you to change how to boot an OS. If you want or need to change the boot process, check your motherboard's documentation for how to do that.
You will need Internet connectivity for this installation. The easiest way to to do that is connect an Ethernet cable to the computer. Using WiFi is also possible but requires the use of the following command.
wifi-menu
Check your Internet connection.
ping -c 3 archlinux.org
If you get responses back then the connection is good.
Set the computer clock.
timedatectl set-ntp true
Check your drive partitions
lsblk
Drives are named and partitioned similarly, but not always exactly the same. Each machine and configuration may be different depending on what drives are in them. Generally speaking a HDD or SSD are named sda for the first one, sdb for the second one and so on. This will also include your portable USB installer in the list. Some SSD's will be labeled nvme in the list which signifies their type of SSD, m.2 nvme.
You may also notice for example, sda, sda1, sda2, and sda3 in the list. sda is the main HDD/SSD. sda1, sda2, and sda3 are partitions of the main drive sda. The same will hold true for a drive named sdb, sdc or nvme.
WARNING: Be sure you know, understand and remember which drive is which during the partitioning process. If you're working on a computer with multiple drives and one of them contains an operating system or a storage drive where you keep all of your data, and you format the wrong drive it is possible to lose everything. Always, backup your data before starting this process.
For this example we will create 4 partitions which is typical for a Linux setup. We will have a boot partition, a swap partition, a root parition and a home partition. There is debate on whether a swap partition is needed or not anymore, but it doesn't hurt to have one and is useful for putting computers to sleep or in hibernation mode as well as during use of heavy workloads.
We will also create seperate partitions for the root and home. This isn't a necessary step and if you desire to, you can make both the root and home in the same partition. We will create them seperately here because by doing so, you can protect your home partition and its data from the root partition in case your Arch Linux OS install needs to be redone. You can reinstall Arch Linux to the root partition while leaving the home partition alone and preserving your files. If the whole HDD/SSD fails, then it wouldn't matter about the partitions because they'd all be lost. Make sure to always keep current backups of your data.
Run fdisk on the drive you wish to partition and format. In this example we will work with a drive called sda.
fdisk /dev/sda
Check the partition table of sda
p
If there is a partition defined here, delete it.
d
Check the partition again to see that it is deleted.
p
Create a new partition. This will be the boot partition.
n
Set the partition type.
p
Set the partition number.
1
Set the first sector. The default is fine.
press enter
Set the last sector. Since this is the boot partition is doesn't need to be very large. The GRUB menu and other OS loading stuff will be here later on. 200 MB is typical for a boot partition.
+200M
If you get a warning about the partition contaninig an ext4 signature, say yes to remove it and create the new partition.
y
Create a new partition. This will be the swap partition.
n
Set the partition type.
p
Set the partition number.
2
Set the first sector. The default is fine.
press enter
Set the last sector. The typical rule of thumb is to make the swap partition about 150% of the amount of RAM you computer has. So if you have 8 GB of RAM, make the swap size 12 GB.
+12G
Create a new partition. This will be the root partition.
n
Set the partition type.
p
Set the partition number.
3
Set the first sector. The default is fine.
press enter
Set the last sector. This is where Arch Linux and all the programs you will later install will reside. A good minimum size for the root partition is 25 GB. If you have a large HDD/SSD and think you might install a lot of large programs, then create this partition to a larger size that fits your needs.
+25G
Create a new partition. This will be the home partition.
n
Set the partition type.
p
Set the partition number.
4
Set the first sector. The default is fine.
press enter
Set the last sector. The default is fine here because this will take up the remaining disk space. This is where all of your personal data will be stored.
press enter
Print the partition table you just created to ensure you have it the way you want it done.
p
Now all of your partitions are setup. However they are not confirmed and need to be written to become permanent.
WARNING: The following command will now write your new partition table to disk and you will lose anything that may be on there. Ensure that you are working on the correct drive that you want to install Arch Linux on.
w
The next step is to setup the file systems for Arch Linux. List the drives and partitions again.
lsblk
Create a file system on the boot partition.
mkfs.ext4 /dev/sda1
Create a file system on the root partition.
mkfs.ext4 /dev/sda3
Create a file system on the home partition.
mkfs.ext4 /dev/sda4
Setup the swap partition.
mkswap /dev/sda2
Turn the swap partition on.
swapon /dev/sda2
Make and mount the new partitions. This is where we will tell the new partitions to be mounted for use.
Mount the root partition.
mount /dev/sda3 /mnt
Make a directory for the home partition.
mkdir /mnt/home
Make a boot directory.
mkdir /mnt/boot
Mount the boot partition.
mount /dev/sda1 /mnt/boot
Mount the home partition.
mount /dev/sda4 /mnt/home
Ensure you've mounted the partitions correctly.
lsblk
Choosing the closest locations for downloads. This will help you install Arch Linux a little faster by finding the mirrors with the fastest download speeds for your location.
First, back up the default mirror list.
cp -vf /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
Syncronize the package databases.
pacman -Syy
Install Reflector.
pacman -S reflector
Confirm you want to install the reflector package.
y
Sort the 5 best mirrors for your location
reflector --verbose -l 5 --sort rate --save /etc/pacman.d/mirrorlist
Syncronize the databases again.
pacman -Syy
Now it's time to install Arch Linux to your computer. Here all you really need is "base". That will install the most minimal Arch Linux you can do. However, you'll really want to install a few other things as well. "base-devel" installs some developer tools and really, some necessary tools you need to help configure Arch Linux. "vim" is a terminal based text editor. It is not necessary unless you want it, and know how to use it. It can always be added later if you want it. By default, Arch Linux comes with the text editor Nano. Nano is usually easier to use for beginners. If you want to use Nano instead of Vim for this tutorial, replace "vim" with "nano" (minus the quotes) in the commands Vim appears in. I like Vim better so that is what I am going to use here.
pacstrap /mnt base base-devel vim
Generate the fstab file, this is the file system table file.
genfstab -U /mnt >> /mnt/etc/fstab
Now we're going to change from operating from the portable USB drive to operating from the newly installed Arch Linux OS on your HDD/SSD to do some final steps in configuring Arch Linux.
arch-chroot /mnt
pacman -S networkmanager
Confirm you want to install the package.
y
Enable the network manager to run at startup. Capitalization of commands in Linux is important because it makes a difference whether something will work or not.
systemctl enable NetworkManager
Install a boot loader.
pacman -S grub
Confirm you want to install the package.
y
Install GRUB on the boot partition.
grub-install --target=i386-pc /dev/sda
Make the GRUB configuration file.
grub-mkconfig -o /boot/grub/grub.cfg
Set the root password for your Arch Linux installation.
passwd
Type in your desired password and then type it again when asked to confirm it.
Setup your locale and region information so the computer knows what timezone you are in. I'll be using UTF-8 and United States English. If you need different settings, you will need to look them up.
sed -i 's/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale. gen
Generate the locale
locale-gen
Generate language config file.
echo LANG=en_US.UTF-8 > /etc/locale.conf
Export the locale.
export LANG=en_US.UTF-8
Create a symbolic link for the desired timezone.
ln -sf /usr/share/zoneinfo/America/Detroit /etc/localtime
Set the hardware clock to UTC.
hwclock --systohc --utc
Set the desired hostname. This is the name of your computer.
echo MyComputer > /etc/hostname
Add a system user. This should be your normal user account that you will use daily.
useradd -m -g users -G wheel,games,power,optical,storage,scanner,lp,audio,video -s /bin/bash username
Set the system user password. It is advisable to make this a different password than the root password you set earlier for security purposes.
passwd username
Type in your desired password and then type it again when asked to confirm it.
Install sudo. This will allow your system user to elevate privlesges to root to install packages and run commands.
pacman -S sudo
Confirm you want to install the package.
y
Allow the system user to use the sudo command.
EDITOR=vim visudo
Press / and type wheel, then uncomment the following line by removing the # symbol at the start of the line.
#%wheel ALL=(ALL) ALL
To remove the #, press i for insert mode in vim then highlight # and press delete. Then press ESC to exit insert mode. Press : to enter a vim command and then enter wq and press enter. w writes the file changes and q quits vim.
Exit the operational drive of your Arch Linux installation back to the Arch Linux portable USB drive.
exit
Unmount the drives recursively.
umount -R /mnt
Reboot your machine to boot into your new Arch Linux installation.
reboot
Remove the portable USB drive before the computer tries to boot it again.
You should now have a command prompt where you can log in as your new system user. You are ready to install all the programs you want to use including a desktop environment like Gnome, KDE, XFCE or Plasma. You can also install a window manager instead of a desktop environment if you are a more advanced user and like a minimal working interface.
Before we get to installing a DE (desktop environment), let's do a quick customization of pacman, the Arch Linux package manager we've been using all along.
We'll add a touch of color to it and enable some extra options as well as a bit of nostalgic gaming eye candy.
sudo vim /etc/pacman.conf
Uncomment these lines.
color TotalDownload VerbosePkgLists
Add this line to get a PacMan icon for installing packages.
ILoveCandy
Here we will install the desktop environment, a graphical login screen and some other optional packages to get you up and running to a usable desktop.
sudo pacman -S mesa xorg-server xorg-apps xorg-xinit xorg-twm xorg-xclock xterm compton lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings xfce4 xfce4-goodies gvfs
Enable the logon manager service.
sudo systemctl enable lightdm.service
Here are some optional packages to install. Pick and choose which ones you would like.
sudo pacman -S libreoffice-fresh firefox zathura zathura-pdf-poppler ranger newsboat filezilla weechat syncthing neofetch htop joplin nextcloud keepass network-manager-applet nm-connection-editor speedtest-cli pavucontrol pulseaudio conky
At this point you should have a lot of what you need to get going in a functional DE. Time to reboot the computer and get to the graphical logon where you'll enter your username and password you created earlier.
reboot
Now you can join in the meme and say "btw, I use Arch."
To learn more, find answers to questions and find more packages to install, be sure to read the well-written and extensive Arch Wiki.