21 Jan 2013

Install Arch Linux in 34 easy steps

What is Arch Linux?

Arch Linux is an independently developed, i686/x86-64 general purpose GNU/Linux distribution versatile enough to suit any role. Development focuses on simplicity, minimalism, and code elegance. Arch is installed as a minimal base system, configured by the user upon which their own ideal environment is assembled by installing only what is required or desired for their unique purposes.

arch linux on Twitpic

GUI configuration utilities are not officially provided, and most system configuration is performed from the shell and a text editor. Based on a rolling-release model, Arch strives to stay bleeding edge, and typically offers the latest stable versions of most software.

Should i install Arch Linux?

If you wish to embrace the 'do-it-yourself' approach and require or desire a simple, elegant, highly customizable, bleeding edge, general purpose GNU/Linux distribution you should install Arch Linux.

Who shouldn't install Arch Linux?

If you do not have the ability/time/desire for a 'do-it-yourself' GNU/Linux distribution.
If you believe an operating system should configure itself, run out of the box, and include a complete default set of software and desktop environment on the installation media then DO NOT INSTALL Arch Linux.

Let's do it!

Okay now that you have decided to take the plunge and install Arch Linux just follow this guide closely and you'll have a working Arch Linux in no time.
The first thing you will have to do is prepare your hard disk for the Arch install. You will need at least one free partition on your hard disk. You can create the partition during Arch installation but it will be much easier and safer to use Gparted. You can get get Gpated live cd from here

http://gparted.sourceforge.net/livecd.php

Gparted has excellent documentation on how to resize, delete, create, modify hard disk partitions. You can read the documentation here

http://gparted.sourceforge.net/display-doc.php?name=gparted-live-manual#gparted-live-using-gparted-application

After you have created the partition to install Arch it is time to get the install media. Arch ISO is dual arch meaning you can install either 32 bit or 64 bit version of Arch using the same media. Here's the link to get your Arch ISO

https://www.archlinux.org/download/

Okey-dokey now that you have downloaded the ISO you need to burn it on CD. There are many apps to do this and if you don't know how to burn ISO you should stop right here cause Arch ain't for you my friend, not yet anyway.

Boot your Arch CD and at first prompt choose the Arch version you want to install. Remember that  i686 means 32 bit and x86-64 naturally means 64 bit. After the booting process finishes you will end up at command prompt. Run the following command to get the info of your current partition layout
fdisk -l
Make note of the partition you want to install Arch on. For this article we are gonna assume that it is sda1. Now we need to mount the root partition. If you plan to use a separate home partition then you'll have to mount that partition too. To mount root partition run the following command
mount /dev/sda1 /mnt
Now it's time to install the base by issuing this command
pacstrap -i /mnt base base-devel
After the base install finishes create fstab by
 genfstab -U -p /mnt >> /mnt/etc/fstab
Let's now chroot in to our Arch base
 arch-chroot /mnt
Time to set the Locale. By default every entry in locale.gen file is commented out and we need to uncomment the languages we want. To do so run
nano /etc/locale.gen
 Here I'm going to remove # from  #en_US.UTF-8 line as I'm going to use US English as my language. You can uncomment more than one entry. After you are finished hit Ctrl+X to exit, then Y and Enter to save your changes. Now we need to generate the locale file by issuing the command
locale-gen
We also need to generate a file called locale.conf the command I'm gonna run is for US English you need to change it according to your language
 echo LANG=en_US.UTF-8 > /etc/locale.conf
 export LANG=en_US.UTF-8
It's time to set the Time Zone. To view the available zones
ls /usr/share/zoneinfo/
Make note of your zone. Mine is Asia. Let's find out the subzone of Asia
 ls /usr/share/zoneinfo/Asia
Okay my subzone is Kolkata. Make note of the subzone that belongs to you and run the following command to set Time Zone. Don't forget to replace Asia & Kolkata with your relevant zone and subzone
ln -s /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
Now we are going to set hardware clock. If you are planning to use Arch without Windows run the following command
 hwclock --systohc --utc
But if you are using or planning to use Arch with any versions of Windows then you need to issue the following command
 hwclock --systohc --localtime
Let's now configure network. If you are on a desktop PC and are using a wired network
systemctl enable dhcpcd@eth0.service
But if you have a laptop and are planning to use wifi then run the following commands to install the wifi tools and enable wireless service
 pacman -S wireless_tools wpa_supplicant wpa_actiond dialog
 wifi-menu
 systemctl enable net-auto-wireless.service
Okay we are getting close to finishing the installation. Let's create the password for the root account
 passwd
Enter your desired password for the root account. Now let's create a normal user account
 useradd -m -g users -G wheel -s /bin/bash hakerdefo
Obviously replace hakerdefo in the above command with your username. Now create password for hakerdefo aka normal user
 passwd hakerdefo
Let's now install and configure sudo
 pacman -S sudo
Now we need to add our user to sudoers file and to do so the simplest method is to uncomment the wheel group in sudoers file
 EDITOR=nano visudo
Uncomment the following line
 %wheel ALL=(ALL) ALL
And as we did earlier with our locale.gen file hit Ctrl+X to exit, then Y and Enter to save your changes. You can skip the next step which is to install bootloader grub2  if you already have a Linux like Ubuntu or any other distro running on your PC if you don't then install grub2 by following command and don't forget to replace 'sda' with your relevant hard disk
 pacman -S grub-bios
 grub-install --target=i386-pc --recheck /dev/sda
 cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo
Now install os-prober
 pacman -S os-prober
Time to configure grub
 grub-mkconfig -o /boot/grub/grub.cfg
If you have decided to skip the grub installation and are planning to add the arch to your grub menu via let's say grub of Ubuntu then there are chances that even if your Ubuntu grub detects the Arch but it will fail to boot Arch. It happens due to limitations of os-prober script. In that case add the following in your grub 40_custom  file. Replace the hdd-partition in setroot according to your setup.
menuentry "Arch" {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
/boot/vmlinuz-linux
/boot/initramfs-linux.img
}
Now if you have installed 64 bit Arch we need to add the multilib repo to pacman's repo list. Here's how you do it
 nano /etc/pacman.conf
Go to "Repositories" section of the configuration file and add the following at the bottom
 [multilib]
 Include = /etc/pacman.d/mirrorlist
Ctrl+X, then Y and Enter. Nano is a good little editor. Okay it's time to exit from the chroot
exit
Unmount the root partition 
umount /mnt
And reboot
reboot
Remove your Arch CD and select Arch from grub menu. Login with your username and password. Let's now install a basic x window system
 sudo pacman -S xorg-server xorg-xinit xorg-server-utils
And
 sudo pacman -S xorg-twm xorg-xclock xterm
Life without sound is boring, ain't it?
 sudo pacman -S alsa-utils
Now comes the moment of truth. If everything has gone okay and you have followed the steps in the guide correctly you should see xterm window with a clock and should be able to use your mouse by issuing the command
startx
Well guys that's about it from me. From here on you need to install a DE and/or a window manager of your choice and there are far too many possible choices out there writing about them is beyond the scope of this guide and beyond my knowledge.


EDIT: the install step 'systemctl enable dhcpcd@eth0.service'  will not have the correct effect. There is a combination of factors which keep it from working.  First, systemd now renames network interfaces on boot. It does this so that network interfaces will have predictable, and never changing, names.  Second, the above command will create a service file that has "eth0" hardwired into it no matter what interface you use when you enable the service. The combination of these two, a network interface that will never be "eth0" and a service that always specifies "eth0", means that on reboot the user will not have network access.
The solution to this is to do (including executing the original non-working command to create the link to modify in a few steps):
in a terminal to get your particular networking card name
iplink
For example, mine is "enp2s0". Then, go to
/etc/systemd/system/multi-user.target.wants/
and you will see
dhcpcd@eth0.service
Rename that to the correct interface name as "ip link" gave you above. In my case the command is
sudo mv dhcpcd@eth0.service dhcpcd\@enp2s0.service
Obviously replace 'enp2s0' in the above command with your output of iplink. I really want to thank Bill Pickett aka headkase for pointing out this in arch forums and providing the above solution.


To know more about the available desktop environments and how to install them go here

https://wiki.archlinux.org/index.php/Desktop_Environment

To configure pacman and it's mirrors go here

https://wiki.archlinux.org/index.php/Pacman

What is arch without AUR?!? Know more about it here

https://wiki.archlinux.org/index.php/AUR

A great list of apps

https://wiki.archlinux.org/index.php/List_of_Applications

And if you missed something here in this guide or need some extra information or help Arch has a more in depth albeit a bit confusing  installation guide to help you

https://wiki.archlinux.org/index.php/Beginners'_Guide 

And for any other question or assistance i suggest you Arch forums

https://bbs.archlinux.org/

I hope you will have a great time using Arch Linux. Cheers!!!

No comments: