Skip to content

amirk1998/Arch-Linux-Installation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arch Linux Installation as a Virtual Machine

  1. First set boot to UEFI

    UEFI

we can verify the boot using the following command

ls /sys/firmware/efi/efivars
  1. Set a good font for high resolution screens
setfont ter-132b
  1. Then Set password for root user to able to connect through SSH using Termianl
passwd
  1. Connect to the Arch Live using SSH
ssh root@IP
  1. Ping to ensure network works fine
ping -c 3 archlinux.org
  1. Set Time and date to ensure work correctly
timedatectl set-ntp true
timedatectl status
  1. Then see what partitions do we have
lsblk

Also we can use this command

fdisk -l

Imagine that the partition we want to create on /dev/sda

  1. Now we start the partitioning
cfdisk /dev/sda

Cfdisk

we use GPT for UEFI boot .

Now we want 3 partitions

  • /dev/sda1 # choose 512Mb of space (UEFI)
  • /dev/sda2 # choose 2GB to 4GB for Swap (Swap)
  • /dev/sda3 # choose at least 10 GB of space (root)

Partition

The first partition is the UEFI partition. It needs to be formatted with a FAT file system:

mkfs.fat -F32 /dev/sda1

For Swap Partition we use this command to format:

mkswap /dev/sda2

And then use this command to mount the swap partition:

swapon /dev/sda2

For root partition we use this command to format :

mkfs.ext4 /dev/sda3

8-A) [OPTIONAL] Configure the Mirrors

The installer comes with Reflector, a Python script written for retrieving the latest mirror list the Arch Linux Mirror Status page. To print out the latest mirror list, simply execute the following command:

reflector

If you have a slow internet connection, you may encounter an error message as follows:

failed to rate http(s) download (https://arch.jensgutermuth.de/community/os/x86_64/community.db): Download timed out after 5 second(s).

This happens when the default timeout (5 seconds) is lower than the actual time it's taking to download the information.

You can remedy to this problem by using the --download-timeout option:

reflector --download-timeout 60

Now reflector will wait for a whole minute before starting to scream. A long list of mirrors should show up on your screen:

Going through the entire list to find nearby mirrors would be a pain. That's why reflector can do that for you.

Reflector can generate a list of mirrors based on a plethora of given constraints. For example, I want a list of mirrors that were synchronized within the last 12 hours and that are located either in India or Singapore (these two are closest to my location), and sort the mirrors by download speed.

Turns out, reflector can do that:

reflector --download-timeout 60 --country Germany --age 12 --protocol https --sort rate

Printing out a mirror list like this is not enough. You'll have to persist the list in the /etc/pacman.d/mirrorlist location. Pacman, the default package manager for Arch Linux, uses this file to learn about the mirrors.

Before overwriting the default mirror list, make a copy of it:

cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak

Now execute the reflector command with the --save option as follows:

reflector --download-timeout 60 --country Germany --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist

Source :

The Arch Linux Handbook – Learn Arch Linux for Beginners

  1. Install Arch Linux

First, sync the Pacman repository so that you can download and install any software:

pacman -Syy

Now that you've created and formatted your partitions, you're ready mount them. You can use the mount command with appropriate mount points to mount any partition: We must mount the root partition (“/dev/sda3“) to the “/mnt” directory before we can perform any installation.

# mount <device> <mount point>

mount /dev/sda3 /mnt

With root mounted, it’s time to install all the necessary packages. Use the pacstrap command to install Arch Linux required packages:

pacstrap -K /mnt base linux linux-firmware sudo nano vim
  1. Configure the Installed Arch System

After the installation completes, generate a “/etc/fstab” file for your new Arch Linux system by issuing the following command:

genfstab -U /mnt >> /mnt/etc/fstab

Now that we have installed Arch Linux, we need to switch to the physically installed root partition using the **arch-chroot** command.

arch-chroot /mnt

Set Time Zone

Next, let’s configure the timezone. To find your timezone, you can list (ls -l) the contents of the “/usr/share/zoneinfo/” directory.

Find your preferred timezone (“/usr/share/zoneinfo/Zone/SubZone“) where “Zone/SubZone” is your selection, such as “America/New_York,” “Europe/Paris,” “*Asia/Bangkok*,” and so on. You got the idea. For example we choose “ Asia/Tehran

ln -sf /usr/share/zoneinfo/Asia/Tehran /etc/localtime

Set Locale

Now we need to set up the locale. The file “/etc/locale.gen” contains locale settings and system languages and is commented on by default. We must open this file using a text editor and uncomment the line which contains the desired locale.

vim /etc/locale.gen

Uncomnent “en_US.UTF-8 UTF-8” and “en_US ISO-8859-1” (by removing the “#” sign), and any other needed locales in “/etc/locale.gen.” Then, press “Ctrl+O” followed by “Enter” to save, and finally, “Ctrl+X” to exit the editor.

locale.gen

vim /etc/hosts

Now generate the locale config file using the below commands one by one:

locale-gen

Run the command below to synchronize the hardware clock, automatically creating a “/etc/adjtime” file containing descriptive information about the hardware mode clock setting and clock drift factor.

hwclock --systohc

Now we will move ahead and set the hostname. A hostname is the computer’s name. So let’s name it, for example, “archvbox”. Use the following command:

echo archvbox > /etc/hostname

Add this name to the “/etc/hosts” file also. Edit the file with Nano editor and add the following lines (replace “archvbox” with the hostname you chose earlier).

vim /etc/hosts
127.0.0.1      localhost
::1            localhost
127.0.1.1      archvbox.localdomain   archvbox

Remember to set the password for the root account using the passwd command:

passwd

Create User

Now we create new user (Change USER_NAME ):

useradd -m USER_NAME

And then set password for this user

passwd USER_NAME

And then add user to the wheel group

usermod -aG wheel,audio,video,optical,storage USER_NAME

Finally, you'll have to enable sudo privilege for this new user. To do so, open the /etc/sudoers file using nano. Once open, locate the following line and uncomment it:

visudo

And then uncomment this line :

%wheel ALL=(ALL) ALL

11 ) Install GRUB Bootloader on Arch Linux

Now we install the boot loader for Arch to boot up after restart. The default boot loader for Linux distributions and Arch Linux also is represented by the GRUB package.

Install the GRUB bootloader and EFI boot manager packages:

pacman -S grub efibootmgr os-prober dosfstools mtools

Then create the mount point for “/dev/sda1” and mount it.

mkdir /boot/EFI
mount /dev/sda1 /boot/EFI

Now let’s install our boot loader.

grub-install --target=x86_64-efi --bootloader-id=grub_uefi --recheck
# Output
# Installing for x86_64-efi platform.
# Installation finished. No error reported.

Finally, generate the “/boot/grub/grub.cfg” file.

grub-mkconfig -o /boot/grub/grub.cfg
  1. Configure the Network Manager

Configuring a network manually in any Linux distribution can be tricky. That's why I advised you to install the networkmanager package during the system installation. If you did as I said, you're good to go. Otherwise, use pacman to install the package now:

pacman -S networkmanager vim git
systemctl enable NetworkManager
systemctl status NetworkManager
  1. Final Step

First we should exit from chroot

exit

Then unmount /mnt

umount -R /mnt

And reboot

reboot
  1. [OPTIONAL] X-Org Configuration

Install X window system and audio

Our Arch Linux currently contains only the essential software packages needed to manage the system from the command line, with no GUI (Graphical User Interface).

Arch Linux supports a wide range of desktop environments. I will install GNOME as a desktop environment example.

The first step is to install the X environment. Type the below command to install the Xorg as a display server.

pacman -S xorg-server xorg-apps

Or

pacman -S pulseaudio pulseaudio-alsa xorg xorg-xinit xorg-server

Releases

No releases published

Packages

No packages published