December 12, 2015

Arch Linux Day 1: Installation

  1. Disclaimer
  2. The Process
    1. The Installation Media
    2. Booting Up
      1. Partitioning
      2. Formatting the Partitions
      3. Installation of the Base System
      4. Configure Network
      5. Install the Boot-Loader
      6. Setting root Password
      7. Exiting and Rebooting
    3. First Login
    4. Creating a User
  3. A Whole New World

Disclaimer

This is by no means a tutorial or a guide to installing Arch Linux - it is just how I did my things. Everything that I do should be taken as (at the most) advice. Everything written here should be taken with a grain of salt, as I am going off of my memory of what I have done, and may have forgotten things, even if it was only a few days since I have actually done the deed. I don't remember every command that I execute.

The Process

The Installation Media

You won't believe me when I tell you that the most difficult part of this day was to burn the image to the disk. But let me tell you: it was.

The main tool I used was ImgBurn on Windows 10. I downloaded the ISO image, which was around 600MB. I then proceeded to insert a blank DVD into my disk drive, and started up ImgBurn. I finished burning the image onto my disk, but the problem came when ImgBurn started verifying my disk. At the 20% mark, verification errors began popping up for no reason. I know because I tried burning it on my Ubuntu laptop, and was successful (which is why I am using Arch right now). Some research showed me that it was not ImgBurn's problem, but a combined problem between old hardware and new software/drivers. Mind you that my main laptop is almost 6 years old (as of writing this).

Booting Up

After that fiasco, I booted my disk, and boy did it load up fast.

Partitioning

The first thing I did was (re)partitioning my disk. Since I did not have multiple hard drives, I had to partition my disk. Unfortunately for me, Windows 10 has already partitioned my disk into 3 parts: the boot-loader, my main C:\ drive, and a recovery partition, making 3 primary partitions. As you may or may not know, you can only have 4 partitions on 1 disk at the same time. I saw that my previous Fedora 20 distribution got around this by making a logical partition.

Using cfdisk, I deleted my Fedora partitions, then created a large logical partition (with the remaining space) and pushed my root, boot, swap, and home partitions on there. I gave every partition type ext4 (default) except swap (Linux swap/Solaris). I then saved and exited.

Formatting the Partitions

After all the partitioning, I used fdisk -l to list out all the available partitions. I then tried to format my swap partition with the commands:

mkswap /dev/sda7
swapon /dev/sda7

This failed miserably with an error. I then found out that my beloved Fedora 20 installation formatted every partition it touched with lvm. I removed them all with lvremove -r /dev/mapping/fedora and tried formatting again. It worked.

mkfs.ext4 /dev/sda5     # Root
mkfs.ext4 /dev/sda6     # Boot
mkfs.ext4 /dev/sda8     # Home (doesn't rhyme with 'oot')

Installation of the Base System

With formatting done and out of the way, next comes installation of base packages. The instructions say that I have to install the packages to the root partition, and that's what I did.

# Mount everything
mkdir /mnt/home /mnt/boot
mount /dev/sda5 /mnt
mount /dev/sda6 /mnt/boot
mount /dev/sda8 /mnt/home

# Install the base package
pacstrap /mnt base

One thing that I need to do before chroot-ing into the new system is to generate an fstab file:

genfstab -p /mnt >> /mnt/etc/fstab
arch-chroot /mnt    # Change root

Configure Network

I wanted a working ethernet connection, so I did systemctl enable [email protected] to enable the ethernet service for my machine. You may have a different device name, like eth0.

Install the Boot-Loader

I've been using GRUB before, and didn't want to change, so I ran pacman -S grub os-prober to install GRUB and a module called os-prober that detects my Windows OS so that GRUB recognizes it and allows me to boot from that as well.

To configure and install GRUB:

grub-mkconfig -o /boot/grub/grub.cfg    # Create config file
grub-install --recheck /dev/sda         # Install GRUB

Setting root Password

One of the last things that you should do is to set the password for root user for the next/first time you login. A simple passwd does it.

Exiting and Rebooting

I exited the chroot with exit (Ctrl+D also works). Afterwards, I unmounted all the mounted partitions with unmount -R /mnt, the -R being recursive to unmount everything recursively. Apparently, unmounting also checks for problems with fuser. I rebooted the machine with reboot.

First Login

At last, it was time for me to login for the first time! GRUB loaded correctly, and defaulted to Arch Linux. The loading-up was very fast, as I had nearly nothing to load. I successfully logged in with my root account, and was greeted with a very nice shell prompt.

Creating a User

Creating a user is very essential - I don't want to be logging in as the root user every time because if I screw something up, I lose everything.

useradd -m cheukyin699  # Create the user
passwd cheukyin699      # Change the password

pacman -S sudo          # Install sudo
visudo                  # Edit sudoers file to add user
reboot

A Whole New World

After rebooting, it's time to login a second time as a normal user and start installing stuff. But I thought that what I did was good enough for the day.

Tags: installation linux