Quantcast
Channel: CodeSection,代码区,Linux操作系统:Ubuntu_Centos_Debian - CodeSec
Viewing all articles
Browse latest Browse all 11063

Installing Arch Linux. Part 1

$
0
0

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:


Installing Arch Linux. Part 1

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:


Installing Arch Linux. Part 1

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
Installing Arch Linux. Part 1

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:


Installing Arch Linux. Part 1

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.


Installing Arch Linux. Part 1

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:


Installing Arch Linux. Part 1

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.


Installing Arch Linux. Part 1

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
Installing Arch Linux. Part 1

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.


Installing Arch Linux. Part 1

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
Installing Arch Linux. Part 1

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.


Installing Arch Linux. Part 1
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.


Installing Arch Linux. Part 1

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.


Installing Arch Linux. Part 1

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.

To be continued...

by Alex Gaudino, Owner of HTML High 5

Viewing all articles
Browse latest Browse all 11063

Trending Articles