Arch Linux Installation : Part 3

Arch Linux Installation : Part 3

28 Oct 2020, 06:45pm TZ +05:30
linux, Arch
Software, tips

Continuing where we left off in part 2

This is the Part 3 in the series. In this part we prepare initial bootstrap, create file structure and perform basic setup to get a working command line based install.

Part 1 | Part 2 | Part 3



Stage : Bootstrap Installation [BS] #

Before we can start the next steps we would need to install some basic tools into the Arch Linux drive. This would enable to edit configuration files and more importantly chroot into the installation.

Now chroot is a big topic. Once can find more detail here . In short its like emulating the Arch Linux in actual disk before the install is completed. Yes, that how it goes. This is also used to repair or modify existing Arch Linux installations. Using this tool even though we are still booted on to the Arch Linux media we are emulating the installed version. I can’t make it any more complex.


BS Step-1. Install the Basic Dependencies #

We would at least need the following to be able to do the installation.

  • Linux Kernel - well without it we have nothing.
  • Device Firmware needed to run the low level stuff even below the Kernel.
    Really not sure about this stuff but without it you can’t see any cat videos and stuff.
  • An editor : Vim - I have moved up from nano to Vim its a bit better or far worse.
    Not very sure - The Choice is Yours!
  • U-code or Micro-code which is needed by the processors these days.
    Or you get bitten by Spectre, Meltdown, mosquito and what not..

In Arch Linux we use the command pacstrap. More detail on that here .

Bootstrap the Installation on a AMD Processor based Computer #

pacstrap /mnt base linux-lts linux-firmware vim amd-ucode

Here we are specifically looking at the LTS kernel. Its the most stable, trust me its much better this way.

You get a free run to curse the kernel if any thing goes wrong.

Bootstrap the Installation on a Intel Processor based Computer #

pacstrap /mnt base linux-lts linux-firmware vim intel-ucode

BS Step-2. Configure the File System Table #

For the new installation we would need to configure the File System Table or fstab. This is essential since the OS would not know what to use when booting. We had mounted all the partition in Part 2 . So all we need to do now is define this is the fstab file that resides in /etc/fstab location any Arch Linux install. In our case since the root directory is mounted to /mnt the path would become /mnt/etc/fstab.

Generating fstab the File System configuration #

Here is how we can generate this.

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


Stage : Configure Installation [CI] #

Now that we have loaded our Arch Linux install with basic pieces we are ready to configure. In this stage we would configure our target system with correct parameters. Also we would be installing some basic packages to further enhance our installation. And finally make it usable as a Command line based Linux install.


CI Step-1. Enter the Dragon : CHROOT into our Target installation #

Yes, thats true. We would be using the wonderful chroot that we talked about earlier.

And its as simple as:

arch-chroot /mnt

Of course its arch-chroot we are doing Arch Linux install.


CI Step-2. Configure the Time-Zone #

Upon start-up the timezone defaults to UTC. And we don’t live on a ship so let’s fix this.

Configure the TimeZone for भारत - Bharat(India) #

1
2
ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
hwclock --systohc --utc

First line links the correct timezone as Local time. Then we configure our hardware clock back to UTC. Since many processes depend on the hardware clock its always UTC.

Finding other TimeZones #

timedatectl list-timezones | grep Kolkata

Verifying TimeZone Setting #

timedatectl status

CI Step-3. Setup System Locale #

This is needed to tell the Arch Linux Installation to use the correct language and way or representation.

1. Add Languages #

We need to edit the file /etc/locale.gen to enable specific languages.

Here are two command that can do it without actually opening the file in Vim.

sed -i 's/#en_US.U/en_US.U/1' /etc/locale.gen	# For Normal English Use
sed -i 's/#en_IN/en_IN/1' /etc/locale.gen     	# For भारत - Bharat(India) Use

2. Add Keymap #

We need to create / edit the file /etc/vconsole.conf

Its much simpler to just print the layout directly to this file.

echo "KEYMAP=us" > /etc/vconsole.conf

3. Configure and Generate Locale #

We would need to create the Locale configuration file /etc/locale.conf.

Here is what we need in that /etc/locale.conf file :

LANG=en_US.UTF-8
LC_ADDRESS=en_IN
LC_IDENTIFICATION=en_IN
LC_MEASUREMENT=en_IN
LC_MONETARY=en_IN
LC_NAME=en_IN
LC_NUMERIC=en_IN
LC_PAPER=en_IN
LC_TELEPHONE=en_IN
LC_TIME=en_IN

Make sure the save the file. This configures the system local needed for भारत - Bharat(India) use.

Finally we can generate the Locale using the command:

locale-gen

CI Step-4. Network Host Name and IP Configuration #

We now need to configure our network for the install. For this we would first need to define the host name and mention it in another configuration file.

Create the Host name for the Computer #

echo -n "MYPC1" > /etc/hostname

The Host name MYPC1 is created by actually writing it to the file /etc/hostname

Configuring the Local Network #

For this we need to edit the /etc/hosts file.

Initially this fine would have comments.

Just add the following configuration below those comments:

    127.0.0.1   localhost
	::1         localhost
	127.0.1.1   MYPC1.localdomain MYPC1

Note all separators here are actually Tabs \t and not spaces.

Make sure to change MYPC1 in the above to whatever name you choose for the Host name.


CI Step-5. Setup the Root Password #

Let’s add a password to the root user:

passwd

This is needed to secure the installation. Also its a good practice to have a different password than the normal user.


CI Step-6. Installing some basic packages #

Even for a command line we need some packages to make life easier.

Installation of basic packages #

pacman -S grub efibootmgr reflector \
	ntfs-3g mtools dosfstools exfatprogs bash-completion \
	networkmanager network-manager-applet dialog wpa_supplicant \
	base-devel linux-headers git wget bat nano terminus-font \
	bluez bluez-utils cups \
	xdg-utils xdg-user-dirs \
	alsa-utils pulseaudio pulseaudio-bluetooth

For BIOS / MBR system don’t need the efibootmgr package.


CI Step-7. Configure the Linux Kernel images #

mkinitcpio -P

This is important to make sure we have all the Linux kernel images ready for bootloader installation.


CI Step-8. Install Bootloader #

Base on what type selected at the beginning of the partitioning step we now need to install the Bootloader accordingly.

Install GRUB Bootloader for UEFI Systems #

1
2
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ARCHX
grub-mkconfig -o /boot/grub/grub.cfg

Here ARCHX is just a name we chose it can be any max 8 character alphaNumeric value.

Install GRUB Bootloader for BIOS or MBR Systems #

1
2
grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

CI Step-9. Create the User #

Let’s go through the standard user creation process and the same can be followed for any number of users of the computer.

Create a SUDO or Admin privileged user #

useradd -m -g users \
	-G wheel,storage,rfkill,power,lp,lock,uucp \
	-s /bin/bash \
    boseji

Here you can change the username boseji or you can allow me to be admin on your computer.

The Groups added here are a more than whats normally needed. Typically only wheel,lock,power are needed.

The wheel group is SUDO user group.

For non-privileged user remove the wheel group while creating the user.

Add or Change Password for the User #

passwd boseji

Configure SUDO permissions in the New Installation #

We would need to edit the sudoers file to make sure that the wheel user group has SUDO privilege.

Locate and un-comment the line:

 %wheel ALL=(ALL) ALL

Here is the Edit command to open the sudoers file :

EDITOR=vim visudo

Make sure to save before quitting the editor.


CI Step-10. Enable Services #

Before we go further we need to enable the various services to start a boot-up of our installation.

1
2
3
systemctl enable NetworkManager
systemctl enable bluetooth
systemctl enable cups

CI Step-11. Exit the CHROOT and Un-mount #

Now that we are done with our base installation. We would need to reboot the computer to enter into our Arch Linux Installation.

Exit the CHROOT #

exit

Un-Mount all the Partitions #

umount -a

End of Installation #

Yes, we have reached the End. We now need to remove the Install media and reboot the computer.



Great ! You made strides of progress #

Now you have a functional Arch Linux Installation.

It took me considerable amount of time to figure out the right or the more suitable way to perform this installation.

Hope that this guide can help you in some way on your adventures with grand Arch Linux.

This is the Part 3 in the series. In this part we prepare initial bootstrap, create file structure and perform basic setup to get a working command line based install.

Part 1 | Part 2 | Part 3



Easy Way Out !! #

I have created a much easier version of the this whole installation. It only takes me few minutes setup a full Arch Linux install. Its basically a collection of the above commands in all the 3 parts.

Its a Link text file that can be used to source commands. It would also allow you install XFCE and Graphics drivers. This file is still a work in progress hence use it at your own risk.

After you have completed checking the internet connection as in Part 1 just use the following:

1
2
3
4
curl https://boseji/files/Arch-Install.txt > Arch-Install.txt
source Arch-Install.txt
export DRIVE=/dev/sda
export SWAPSIZEinGiB=8

Now all the commands are loaded into your shell.

Here is a list of the Commands and Stages:

  1. Font Setting
    • i_1_setFont24x32
    • i_1_setFont12x22
    • i_1_terminus_font
  2. Keymap
    • i_2_find_us_Keymap
    • i_2_set_us_Keymap
  3. Wireless Configuration Help = i_3_WirelessConfig
  4. Internet Check = i_4_checkOnline
  5. Configure NTP = i_5_setNTP
  6. Get the Latest Repositories = i_6_UpdateMirrors
  7. Partition:
    • i_7_PartitionDisk_UEFI $DRIVE $SWAPSIZEinGiB
    • i_7_PartitionDisk_NoSwap_UEFI $DRIVE $SWAPSIZEinGiB
    • i_7_PartitionDisk_BIOS $DRIVE $SWAPSIZEinGiB
    • i_7_PartitionDisk_NoSwap_BIOS $DRIVE $SWAPSIZEinGiB
    • Here the $DRIVE need to be Replaced with disk example /dev/sda or export
    • And the $SWAPSIZEinGiB with actual swap size example 8 for 8GB of swap space.
  8. Format Partition:
    • i_8_FormatPartition_UEFI
    • i_8_FormatPartition_NoSwap_UEFI
    • i_8_FormatPartition_BIOS $DRIVE
    • i_8_FormatPartition_NoSwap_BIOS $DRIVE
    • Here the $DRIVE need to be Replaced with disk example /dev/sda or export
  9. Mount Partitions:
    • i_9_MountPartitions_UEFI
    • i_9_MountPartitions_BIOS $DRIVE
    • Here the $DRIVE need to be Replaced with disk example /dev/sda or export
  10. Bootstrap = i_10_BootstrapMount > TODO: Need to fix the AMD and Intel U-code.
  11. Generate fstab file = i_11_Gen_fstab_Mount
  12. Perform CHROOT and Copy the commands file = i_12_EnterMount
  • Since the external environment is not available we need to perform the source commands again
    1
    2
    3
    4
    
    source /Arch-Install.txt
    export DRIVE=/dev/sda
    export SWAPSIZEinGiB=8
    export USERNAME=boseji
    
  1. Set Time-Zone = i_13_SetTimeZone
  2. Setup Locale = i_14_SetLocaleConfig
  3. Network Configuration = i_15_SetHostName
  4. Root Password setting = i_16_SetRootPassword
  5. Install Basic Packages = i_17_InstallBaseSystem
  6. Install Grub
    • i_18_InstallGrub_UEFI $DRIVE
    • i_18_InstallGrub_BIOS $DRIVE
    • Here the $DRIVE need to be Replaced with disk example /dev/sda or export
  7. Enable Services = i_19_EnableBaseServices
  8. Create first privileged User = i_20_CreateUser $USERNAME
    • Here the $USERNAME with the required username or export
  9. Enable the SUDO privilege on wheel user group = i_21_EnableWheel
  10. Exit from the CHROOT = i_22_ExitMount
  11. Un-mount all partitions = i_23_EndInstall

After Completing the First stage you get the Command line Arch Linux ready to use. In the First boot after this the Commands need to be sourced again:

1
2
source /Arch-Install.txt
export DRIVE=/dev/sda

Next Phase of Installation:

  1. Set the Fonts again:
    • c_1_setFont24x32
    • c_1_setFont12x22
    • c_1_terminus_font
  2. Start Wireless network = c_2_ConfigNetwork
  3. Check if we are online = c_3_CheckOnline
  4. Set NTP = c_4_SetNTP
  5. Update Repository for new Installation = c_5_UpdateMirrors
  6. (Optional) Enable SSD Trimmer = c_6_EnableSSD_Trim

Installing Specific Software Packages for GUI:

  • Video Drivers
    • c_p_driver_nVidia
    • c_p_driver_Intel
    • c_p_driver_AMDBuiltInGPU
    • c_p_driver_ATI
    • c_p_driver_OpenSourceNVIDIA
    • c_p_spice_agent for KVM Guest
  • U-Code or Micro Code
    • c_p_ucode_Intel
    • c_p_ucode_AMD
  • XFCE with LightDM = c_p_XFCE
  • Disk Utilities = c_p_disk_utils
  • Networking & Firewall = c_p_netowrk_utils
  • Audio = c_p_audio_utils
  • Video = c_p_video_utils
  • DTP and Word Processing(LibreOffice) = c_p_dtp_utils
  • Development tools = c_p_dev_utils
  • Security Utilities = c_p_security_utils
  • Games = c_p_games
  • Fonts and Emoji support = c_p_fonts
  • Add the Rupee Keyboard = c_p_BharatRupeeKeyboard
  • Arch Linux Wallpapers = c_p_wallpapers
  • Docker = c_p_docker
  • KVM = c_p_kvm
  • Enable KVM Bridge Network = c_p_Enable_KVM_network

Hope that this can quickly get you up an running on the Arch Linux