23 Jun 2016

Installing Arch Linux. Part 1

Arch Linux is often rather challenging or scary when it comes to a newbie's first Linux experience. Some reasons you may want to go with Arch would be the Pacman package handler, or the fact that it comes with no bloat software that will allow you to truly make it your own. In the installation process, there is no GUI or "Press Next to Continue" to hold your hand. This usually drives people away. I also found the forums to have lots of impatient people who expect you to magically know what you're doing. Here I will try to provide an in depth guide on how to install and setup your own Arch Linux computer.

To start off we need to download the Arch ISO. The ISO is the packaged version of the OS which will allow you to burn it on a USB drive and then also install packages from it. To do so, go to archlinux.org/download and select the download closest to your country. I will be using http://mirrors.aggregate.org/archlinux/iso/2016.06.01/ and will download the file entitled archlinux-2016.06.01-dual.iso

Next, we need to prepare a USB device. There are a few ways to do this but if you are on Windows I would recommend Win32 disc imager from SourceForge. On SourceForge there is a video you can watch instructing you how to properly install the ISO to the USB drive. If you are on Linux you can do a GUI install with the gnome-disks package. There are others ways to do it but these are the most convenient.

Now you need to boot from the USB drive by entering your BIOS. Every computer has a unique way of entering the BIOS. Typically you mash the delete key when powering on your PC. Once in your BIOS you will need to find a boot priority setting and move the USB drive to the top of the list. Now that you have booted from the USB drive we are ready to enter the installation process.

Once you've booted with your USB device through the BIOS, you should be confronted with this screen:

Now that you’re here, you need to decide if you want a 64 bit installation (Boot Arch Linux x86_64) or a 32 bit installation (Boot Arch Linux i686). I will be using the 64 bit version and after you select your choice you will end up with this:


For the rest of the installation connect to Ethernet. Using Ethernet is significantly easier than connecting to the internet wirelessly during this time. Go ahead and type
ping -c 3 google.com
This will tell you if you are connected to the internet by checking your connection with Google. Assuming you are we will move on.
Now we want to locate a drive for the installation. To do so run
fdisk -l
We see that Disk /dev/sda is a clean 30GB drive ready for installation. Now we are going to mount our drive. To do so run
mkdir /mnt
and then perform
mount /dev/sda /mnt
If you encounter an error indicating that the drive is in a read-only mode, chances are you need to format (completely erase) the drive. By doing so you will lose all data so be aware of that. To do this type
mkfs.ext4 /dev/sda
then mount /dev/sda with the above command.

Next we need to specify a mirrorlist to download packages. Go ahead and run
nano /etc/pacman.d/mirrorlist
and you should see this:

Now you need to pick a server from the list. I'll be using the US server Server = http://arch.localmsp.org/arch/$repo/os/$arch Simply type this at the top of the list and exit by pressing Control X. Now run
pacman –Sy
This will update your package list and allow you to install the most updated software.

Next we want to install the system. This step is very easy. Simply execute
pacstrap -i /mnt base base-devel
In this command it is required to install the base package, base-devel is optional however. I am going to install it as it provides some packages I might need later down the road. Just press enter to select the packages and the installation process will begin.

Depending on your Internet connection speed this could go very quickly or quite slowly. In my case the file's size is roughly 800 MB so this could take some time. During the installation it will likely suggest 'recommended' packages for the ones it is downloading. You are not required to download any of them but do note that for some software you may download later these recommended package may contain necessary files to later implement a feature.

Now we need to create our File System table, or Fstab. This file is very important and instructs the computer on how to run your partitions and drives. To create this file run
genfstab -U -p /mnt >> /mnt/etc/fstab
It is usually not necessary, but in the future you can edit this file with nano /mnt/etc/fstab but please know it should be ready to go and not require any additional setup.

If you get a Locale error while performing the pacstrap command do not worry. A locale error pertains to your operating system’s encoding and language. To get started we need to run
arch-chroot /mnt
which allows us to start actually editing our new system. Now, go ahead and create our locale files by issuing
nano /etc/locale.gen
Once in the file you should see a long list of locales which looks something like this:

In this case I will be using the ,en_US.UTF-8 locale which requires you to scroll down and remove the ‘#’ in front of the locale. The ‘#’ tells the computer to ignore this line of code.

Continue by pressing Control X to save the changes. If, for example, your primary language is English and you live in the United States, then you should create a locale.conf file (the following commands will place it in the correct location) with these commands
echo LANG=en_US.UTF-8 > /etc/locale.conf
and then
export LANG=en_US.UTF-8
If you speak a different language change this command with your locale of choice. You may also need to run locale-gen if the error persists but it might not be necessary for you.

Now we are also going to set the time/timezone. Run
ls /usr/share/zoneinfo>
to see a list of available times. Since I live in America, I will execute
ls /usr/share/zoneinfo/America
I live in Los Angeles so I will be selecting the Los_Angeles option. To do this run
ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
Then set the clock to your timezone with
hwclock -–systohc –-utc
This creates a system link to your system's time and you should be ready to go.

Now we are going to enable our networking service. This process is fairly simple and works really well. We will use systemctl to enable and add the process to startup for us. Simply run
systemctl enable dhcpcd.service
Now we are going to configure Pacman, the tool you’ll be using to install all your packages. Run
nano /etc/pacman.conf
and look around. If you want to install Skype at one point enable the multilib repository.

Now press Control X again to save. If you are into easter-eggs, add IloveCandy under the above [options] field. This will make Pacman appear instead of a bunch of #'s when installing a package. Finish this up by running
pacman –Sy
and you're done with Pacman.

You probably don't want to continuously use the root account so now we are going to create a user with sudo permissions. The sudo command allows a normal user to execute software with root permission. First change/set the root user’s password by running
passwd
Please note that your password will not appear while entering it so do not worry. This is a standard Linux security feature created to protect your passwords.

Now we want to create a typical user. I will create the user alex by running
useradd -m -g users -G wheel,storage,power -s /bin/bash alex
then I will set my password with
passwd alex
With our new user we want the ability to run root commands. We are now going to install and configure sudo. To install sudo, run
pacman -S sudo
Now we want to edit the sudo file by running
EDITOR=nano visudo
Scroll down until you find the wheel group.

Control X to leave and you now have sudo available for your users.
Now we want to add a bootloader. I am going to use Grub as it’s my favorite and easy to setup. Install Grub with
pacman -S grub-bios
Now to install it run
grub-install –-target=i386-pc –-recheck /dev/sda
in some cases you may need to add -force in the grub install otherwise it may fail. Next specify the locale doing
cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo
If you have another Operating system, run
pacman -S os-prober
to get a boot entry in grub. Finally, run
grub-mkconfig -o /boot/grub/grub.cfg
Finally leave the chroot by typing
exit
then unmount your drive with
umount /mnt
Now go ahead and reboot. At this point remove your USB device.

Continued in the 2nd part.


by Alex Gaudino, Owner of HTML High 5

3 comments:

  1. wifi-menu does a perfect 'cli' job for wireless connection install.
    The frase:'Using Ethernet is significantly easier,' is nonsense.

    ReplyDelete
    Replies
    1. Yeah sorry about that. Unfortunately I don't own any wireless devices or a wireless adapter. That sentence really just applies to me. Thank you for your suggestion. I appreciate it.

      Delete
  2. Don't take this too personally but this is good first attempt but poor quality results Arch Linux installation guide. Lots of redundant installing steps, just installing gnome after the display driver would have pulled X and most if the rest of your separate installations as dependencies. You also didn't link to the official arch install wiki, beginners install wiki and general recommendations wiki all well written and complete unlike this guide. For instance, I assume you are running on an Intel CPU or your readers do. Processors may have faulty behavior, which the kernel can correct by updating the microcode on startup. Nowhere in this guide do you address this and you and your readers who follow this guide instead of the official ones may end up with systems running with faulty behavior and are then unleashed into the world or to arch support forums or other Linux or computer support forums looking for help with their faulty systems or simply just come away with the impression Arch is faulty or crap OS on their system. And yaourt? Seriously? No walk through of how to easy install an aur package using the manual process is that aur helpers automate or linking to the official arch wiki page on aur helpers so the user can choose between many better yaourt alternatives? Grub without saying why or linking to the official arch wiki page to help your EUFI users, systemd-boot, or other bootloaders mentioned in the official arch wiki? What about frequency scaling support and power management for your laptop users so they don't see their laptops running full bore running through their batteries and higher temperatures in no time at all, missing this information in this guide will make those users run back to Windows or OtherOS to gain back battery life and cooler running because you didn't mention it or link to the official arch wiki pages which does as a further reading exercise for the users of your guide. It isn't difficult to add the instructions to install Intel graphics, AMD graphics or even VirtualBox graphics which would cover off the majority of the reader base. Or even mention the different choices between open source and closed source video drivers and their relative performance to guide readers. Going outside the various official arch install wiki pages is like the xkcd comic about 14 competing standards so someone makes the 15th except that with respect to this guide as it stands now people end up with a partially-properly built and configured system and end up with behaviors and issues associated with systems built that way. Maybe you should have just focused on installing it on a virtual machine instance so users could play and learn more or perhaps you should have taught your guides readers the single command to remove all packages except base and base-devel packages so users of your guide can "pop" off all the packages installed after that point in the installation and as good practice rebuild again and again without everything from scratch or pop and build out KDE system or pop and build out plasma or pop and build cinnamon, xfce, lxqt, etc. Very easy to get a lot of very good practice in with a very flexible Linux distribution such as Arch.

    ReplyDelete