Many people seemed to be genuinely surprised when they first know that I do not use Windows. I have moved away from Windows for about 3 years now, mainly due to programming work, as well as having to run statistical analysis/machine learning codes (programs, if you prefer) overnight. Using Windows for either purpose has essentially given me an awful experience; more than once, it has rebooted while my program was running overnight, and often throws random permission errors even though I am the only administrator on my laptop. This blog entry is some notes and thoughts while installing Arch Linux on my 5-year-old laptop.
First and foremost, please read the Arch Linux Installation/Beginner’s Guide. It is really helpful. Secondly, download the iso image file, we will need to create a live USB flash drive for the installer. The next step depends on the OS that we are using, but I only know how to do it with Linux systems (apologizing to people using Windows and MacOS). To create a live USB installation medium, prepare a USB flash drive ( 2 GB is more than enough), and plug it into the USB port on the computer.
Creating Live USB Key
Now for Linux system, first ensure that the USB flash drive is detected, and is not mounted. To do this, first enter the following commands into the terminal
fdisk -l. This will show all the drives that are detected by the system. Usually, they are named
/dev/sdb or in case of a hybrid drive (SSD + HDD), it will show up as
lsblk to make sure that the USB key is not mounted.
Now we will assume that the USB drive is name
/dev/sdb for simplicity (in Arch Linux wiki, it is usually denoted with
/dev/sdx instead, in case anyone reads it and wonder what it is). Then open terminal, and type in
dd bs=4M if=/path/to/archlinux.iso of=/dev/sdb status=progress && sync
if option means input file and
of means output file. Now sit back and relax, the computer will do the rest to create a live USB key.
Installing Arch Linux
First plugin the USB key and reboot the computer. Whenever possible (usually at the beginning while booting), press F12 to enter boot menu. There, we should see the live USB flash drive that we have just created as an option, choose this and wait for it to boot.
Before we setup any installation, we need to verify the boot mode. Enter
ls /sys/firmware/efi/efivars and make sure the system is booting in UEFI mode. If the directory does not exists (i.e. nothing shows up upon hitting Enter/Return key), then the system is either booting in BIOS or CSM mode. To check this, press F2 before booting the system (before F12) and we should see the boot mode. The installation process is basically still the same, with BIOS and CSM having an extra step or two. Personally, I have to go through the BIOS installation process.
Connecting to the Internet
To install Arch Linux, we must have an Internet connection, either through Ethernet or WiFi. To check if the Internet is connected, type
ping archlinux.org. If the laptop starts pinging responding, then we are done! Otherwise, we should see something as follows
ping: archlinux.org: Name or service not known
To set up the Internet through WiFi, first type in
wifi-menu -o <interface> where
<interface> can be obtained by either checking
ip link or
iw dev. It often looks something like
wlpxxx replacing the last three x’s appropriately. Here, we will just use
wlan0 as a substitute. Then we are required to select the network and key in the password, and voila! We are now connected to the Internet through WiFi. (Optional: Do
ping archlinux.org again to confirm the computer is actually connected to the Internet. Or not. I am not a police.)
Update System Clock (Optional)
timedatectl set-ntp true into the console. This will set the clock to be in sync with the UTC time (i.e. timezone +00:00). Use
timedatectl status to check that the time is indeed correct. To set timezone, do
timedatectl set-timezone <timezone name> where
<timezone name> can be obtained via
Partitioning the Disks
Check the name of the disks using
fdisk -l. We should see a list of
/dev/sdx followed with
/dev/sdxY for each disks, including the USB flash drive. The
Y here should be a partition number of
/dev/sdx, and there can be multiple of them.
parted, we can partition the disk into different partitions. In my case (BIOS Boot System) , I need 4 partitions:
- BIOS Bootable System (BIOS boot)
- Root directory, i.e.
/(Linux File System)
- Swap partition (Linux Swap)
- Home directory i.e.
~/home(Linux File System)
Note that the partition above is for BIOS boot mode only, where the BIOS bootable system is the first 1007 KB of the disk. There are other partition layouts. For more examples click on this link.
Remark: My swap partition is the size of my RAM, but the actual size can vary. For the root directory, I have about
I used 10 GB 2 GB space allocated to it, which should be more than enough. Usually home directory gets the rest of the space, and in case of a hybrid drive, the root directory and swap space should be on SSD while home directory should be on HDD.
Formatting the Disks
To format the disks, we need to format it according tot he type. Using above example, Linux file systems can be formatted using
mkfs.ext4 /dev/sda1, assuming my
/dev/sda1 has partition type Linux file system. Assuming
/dev/sda3 is of type EFI System, then we need
mkfs.vfat /dev/sda3. For Linux swap, (in my case,
/dev/sda2) we need to first do
mkswap /dev/sda2 and then
swapon /dev/sda2. Details of formatting for each partition type can be found here.
Mounting the Disks
There are several ways to do this, depending on the partitions. For simplicity, assume the following from now onwards:
/dev/sda1is for the partition for root directory
/dev/sda2is the swap partition
/dev/sda3is the partition for home directory
Then we should first mount the root directory partition onto
/mnt. Simply type
mount /dev/sda1 /mnt to do this. Next, we will need to create
/mnt/home for home directory, which we can do by typing
mkdir /mnt/home, and to mount this drive, we need to follow up with
mount /dev/sda3 /mnt/home. To check which directory is mounted and the details, type
Installing the system
Now we can finally install the system. Use
pacstrap /mnt base, or personally, I prefer
pacstrap /mnt base base-devel as it install some of the functionalities that I already am using. Generally speaking, to install a package, simply append to the command with the package name, followed with a space (so to install GRUB just do
pacstrap /mnt base grub. Now we can sit back and relax for a bit, it will take some time to install.
Configuring the system
We need to now generate the fstab file, using UUID or by the labels. So type
genfstab -U /mnt >> /mnt/etc/fstab if UUID is used, otherwise replace
-L instead. Now we need to configure the local system itself. This is very standard. Do
arch-chroot /mnt, and then just follow the Arch Wiki Guide until the last step, where we are required to run the boot loader. In general, run
grub-install --target=i386-pc /dev/sda
Then, we want to do
grub-mkconfig -o /boot/grub/grub.cfg
to allow the microcode to update and configure GRUB appropriately. Now type
exit and reboot the system. Remember to unplug the USB flash drive at this point.
Congratulations! We have now installed Arch Linux on our computer. For some of us, great! Now we can play with our new toy. For others, this is bad news. Basic Arch Linux is running on Command Line Interface (CLI), but do not be afraid! We can configure a desktop environment running on Arch Linux! Read this for some general recommendations on how to manage the system, and [this]9https://wiki.archlinux.org/index.php/List_of_applications) for a list of applications that is useful. I would suggest first adding a user, setting up a desktop environment, and configuring NVIDIA if required.