Difference between revisions of "User:A2WXH3i"

From ArchWiki
Jump to navigation Jump to search
(Connecting to the internet)
(Verify ISO)
 
(69 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Warning| This is a collection of '''unofficial''' Arch Linux installation guides written by myself.
+
= Unofficial Arch Linux Installation Guide =
  
This guide assumes basic knowledge of how to use GNU/Linux, the folder structure of a GNU/Linux system and how to use {{ic|VIM}} or {{ic|nano}} to edit text files.
+
{{Warning| This is an '''unofficial''' Arch Linux installation guide written by myself.
  
Text in ''italics'' means you should replace the text with something appropriate to your install.}}
+
This guides aim is to make it as easy as possible for some who has never used a GNU/Linux system to install Arch Linux.
  
= Unofficial Arch Linux Installation Guide =
+
{{ic|nano}} should be used to edit text files, however {{ic|vim}} is also available.
 +
 
 +
Text in ''italics'' means you should replace the text with something appropriate to your install.
 +
}}
  
 
== Prerequisites (Pre-boot) ==
 
== Prerequisites (Pre-boot) ==
Line 13: Line 16:
 
Download [https://www.archlinux.org/download/ Arch Linux].
 
Download [https://www.archlinux.org/download/ Arch Linux].
  
=== Verify ISO ===
+
=== Verify the ISO ===
 +
 
 +
{{Note| These next steps require either a system with GnuPG installed or an Arch Linux derivative.}}
 +
 
 +
Download the PGP signature, {{ic|cd}} to the directory where both the ISO image is saved and the .sig file is saved, and then verify the ISO.
  
{{Note| These next steps require either a system with GnuPG installed or an Arch Linux derivative e.g. Manjaro Linux.}}
+
Example:
  
Download the PGP signature and verify the ISO.
+
$ cd ~/Downloads
  
 
  $ gpg --keyserver pgp.mit.edu --keyserver-options auto-key-retrieve --verify archlinux-''version''-x86_64.iso.sig
 
  $ gpg --keyserver pgp.mit.edu --keyserver-options auto-key-retrieve --verify archlinux-''version''-x86_64.iso.sig
Line 25: Line 32:
 
  $ pacman-key -v archlinux-''version''-x86_64.iso.sig
 
  $ pacman-key -v archlinux-''version''-x86_64.iso.sig
  
=== Copy media to a USB ===
+
=== Copy ISO to a USB ===
  
 
You can use the tool {{ic|dd}} to copy the ISO to the USB via the command line, alternatively you could use [https://www.balena.io/etcher/ Etcher] if you like a GUI.
 
You can use the tool {{ic|dd}} to copy the ISO to the USB via the command line, alternatively you could use [https://www.balena.io/etcher/ Etcher] if you like a GUI.
Line 31: Line 38:
 
Below is an example of how you can use {{ic|dd}} to copy the ISO to a USB.
 
Below is an example of how you can use {{ic|dd}} to copy the ISO to a USB.
  
  # sudo dd if=archlinux-''version''-x86_64.iso of=/dev/sd''X'' status=progress
+
  # dd if=archlinux-''version''-x86_64.iso of=/dev/sd''X'' status=progress
  
 
Once the ISO is copied to the USB boot to it.
 
Once the ISO is copied to the USB boot to it.
Line 39: Line 46:
 
{{Note| Use Shift+PageUp and Shift+PageDown to scroll in the TTY.}}
 
{{Note| Use Shift+PageUp and Shift+PageDown to scroll in the TTY.}}
  
=== Keyboard Layout ===
+
=== Keyboard layout ===
  
 
If you need a keyboard layout that isn't US English use the command below to list possible keymaps.  
 
If you need a keyboard layout that isn't US English use the command below to list possible keymaps.  
Line 69: Line 76:
 
  # ping archlinux.org
 
  # ping archlinux.org
  
=== Changing Mirrors ===
+
=== Changing mirrors ===
  
On another device visit the link below and generate mirror links for your country.
+
On another device visit the link below and generate mirrors for your country.
  
 
https://www.archlinux.org/mirrorlist/
 
https://www.archlinux.org/mirrorlist/
  
Once you have generated mirrors edit the file shown below.
+
Once you have generated mirrors edit {{ic|/etc/pacman.d/mirrorlist}} with the new mirrors.
 
 
/etc/pacman.d/mirrorlist
 
  
 
Sync the newly added mirrors.
 
Sync the newly added mirrors.
Line 97: Line 102:
 
== Partition the disk ==
 
== Partition the disk ==
  
{{Warning| The first thing to do is to list the disks in your system, you could have an NVME drive in your PC which could effect this guide. This guide will be using /dev/sd''X''. If you are using NVME it should be /dev/nvme0n1. Please make sure you are targeting the correct drive as loss of data will occur.}}
+
{{Warning| The first thing to do is to list the disks in your system. This guide will be using /dev/sd''X''. Please make sure you are targeting the correct drive as loss of data will occur.}}
  
 
Use the command below to list the disks in your system.
 
Use the command below to list the disks in your system.
Line 107: Line 112:
 
  # fdisk /dev/sd''X''
 
  # fdisk /dev/sd''X''
  
=== EFI Partition ===
+
=== EFI partition ===
  
 
Use {{ic|g}} to create a GUID partition table as opposed to a Master boot record.
 
Use {{ic|g}} to create a GUID partition table as opposed to a Master boot record.
 
g
 
  
 
Use {{ic|n}} to create a new partition.
 
Use {{ic|n}} to create a new partition.
  
n
+
Skip the partition number with {{ic|ENTER}}.
 
 
Skip the partition number.
 
 
 
ENTER
 
  
Skip the first sector resizing.
+
Skip the first sector resizing with {{ic|ENTER}}.
  
ENTER
+
Next make the size of the partition 512MB big with {{ic|+512M}}. This will be used for UEFI.
 
 
Next make the size of the partition 512MB big, this will be used for UEFI.
 
 
 
+512M
 
  
 
Use {{ic|t}} to change the type of the partition.
 
Use {{ic|t}} to change the type of the partition.
  
t
+
It will automatically select the partition as it is the only partition on the disk.
  
This will select the partition number, you could just press enter.
+
Use {{ic|1}} to set the partition to EFI.
  
1
+
=== Root partition ===
  
This will set the partition to EFI.
+
Now create the root partition where Arch Linux will be installed with {{ic|n}}.
  
1
+
Keep this partition as number 2 with {{ic|ENTER}}.
  
=== Root Partition ===
+
Skip the first sector resizing .
  
Now create the root partition where Arch Linux will be installed.
+
Skip second sector resizing with {{ic|ENTER}}, so the rest of the disk is used.
  
n
+
Finally write all these changes to the disk with {{ic|w}}.
 
 
Keep this partition as number 2.
 
 
 
ENTER
 
 
 
Skip the first sector resizing.
 
 
 
ENTER
 
 
 
Skip second sector resizing so the rest of the disk is used.
 
 
 
ENTER
 
 
 
Finally write all these changes to the disk.
 
 
 
w
 
  
 
{{Note| You should check the partition layout with {{ic|p}} before writing the changes.}}
 
{{Note| You should check the partition layout with {{ic|p}} before writing the changes.}}
  
=== Example Layout ===
+
=== Example layout ===
  
 
Your drive should look like something below.
 
Your drive should look like something below.
Line 174: Line 153:
 
| /mnt/boot ||/dev/sd''X''1 || EFI (FAT32) || 512M
 
| /mnt/boot ||/dev/sd''X''1 || EFI (FAT32) || 512M
 
|-
 
|-
| /mnt ||/dev/sd''X''2 || Linux FS (ext4) || 120G
+
| /mnt ||/dev/sd''X''2 || Linux FS (ext4) || 7.5G
 
|}
 
|}
  
 
== Format partitions ==
 
== Format partitions ==
  
Format the EFI partition.
+
Format the EFI partition to FAT32.
  
 
  # mkfs.fat -F32 /dev/sd''X''1
 
  # mkfs.fat -F32 /dev/sd''X''1
  
Format root partition.
+
Format root partition to ext4.
  
 
  # mkfs.ext4 /dev/sd''X''2
 
  # mkfs.ext4 /dev/sd''X''2
Line 189: Line 168:
 
== Mount partitions ==
 
== Mount partitions ==
  
Next mount the partitions so you can install Arch Linux.
+
Next mount the partitions.
  
 
  # mount /dev/sd''X''2 /mnt
 
  # mount /dev/sd''X''2 /mnt
Line 230: Line 209:
  
 
== Configuring GRUB ==
 
== Configuring GRUB ==
 +
 +
{{Tip| This guide will use GRUB as it's choice of boot loader. [https://wiki.archlinux.org/index.php/Arch_boot_process#Boot_loader Take a look at this wiki page for more boot loaders.]}}
  
 
=== Mount EFI partition ===
 
=== Mount EFI partition ===
Line 263: Line 244:
 
  # grub-mkconfig -o /boot/grub/grub.cfg
 
  # grub-mkconfig -o /boot/grub/grub.cfg
  
== Standard UEFI Finished ==
+
== Installation Finished ==
  
{{Tip| It is recommend you follow the post-installation guide for a more complete system.}}
+
{{Tip| It is recommended you follow the [[#Post-Installation]] guide for a more complete system.}}
  
 
= Post-Installation =
 
= Post-Installation =
  
== Create swap file ==
+
== Creating a swap file ==
  
 
{{Tip| It is better to create a swap file rather than a swap partition because they are easier to manage.}}
 
{{Tip| It is better to create a swap file rather than a swap partition because they are easier to manage.}}
  
This will create a file which is 4GB in size that is located in the root of our install.
+
This will create a file which is 4GB in size that is located in the root of your install:
  
 
  # fallocate -l 4G /swapfile
 
  # fallocate -l 4G /swapfile
  
Next set it so only root can manipulate the file.
+
Next set it so only root can manipulate the file:
  
 
  # chmod 600 /swapfile
 
  # chmod 600 /swapfile
  
This makes the file a swapfile.
+
This makes the file a swap file:
  
 
  # mkswap /swapfile
 
  # mkswap /swapfile
  
Then add it to the fstab so it loads when we boot into our system.
+
Finally configure fstab so the swap file is loaded on system boot:
  
# echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab`
+
{{hc|/etc/fstab|
 +
/swapfile none swap defaults 0 0
 +
}}
  
 
== Set the locale ==
 
== Set the locale ==
  
Uncomment {{ic|en_US.UTF-8 UTF-8}} and any other needed locales e.g. {{ic|en_GB.UTF-8 UTF-8}}
+
Edit {{ic|/etc/locale.gen}} and uncomment {{ic|en_US.UTF-8 UTF-8}} and any other needed locales e.g. {{ic|''en_GB.UTF-8 UTF-8''}}
 
 
/etc/locale.gen
 
  
Generate the locales.
+
Generate the locales with:
  
 
  # locale-gen
 
  # locale-gen
  
Next edit {{ic|/etc/locale.conf}} so it looks like something below.
+
Next edit {{ic|/etc/locale.conf}} with the locale you will use on your system:
  
 
{{hc|1=/etc/locale.conf|2=
 
{{hc|1=/etc/locale.conf|2=
Line 313: Line 294:
 
== Set the time zone ==
 
== Set the time zone ==
  
Use the command below which will use systemd's  '''N'''etwork '''T'''ime '''P'''rotocol service to sync the clock with a server.
+
Use the command below which will use systemd's  '''N'''etwork '''T'''ime '''P'''rotocol service to sync the clock with a server:
  
 
  # timedatectl set-ntp true
 
  # timedatectl set-ntp true
Line 327: Line 308:
 
Lastly set the hardware clock from the system clock.
 
Lastly set the hardware clock from the system clock.
  
  # hwclock --systohc`
+
  # hwclock --systohc
  
 
== Set the hostname ==
 
== Set the hostname ==
  
Add your desired hostname
+
Create {{ic|/etc/hostname}} and add a desired hostname:
  
 
{{hc|1=/etc/hostname|2=
 
{{hc|1=/etc/hostname|2=
Line 339: Line 320:
 
== User management ==
 
== User management ==
  
Set the root password.
+
Set the root password:
  
  # passwd
+
  # passwd root
  
This will create a user and it will also create a directory for them in /home.
+
This will create a user and it will also create a directory for them in /home:
  
 
  # useradd -m ''user''
 
  # useradd -m ''user''
  
Set the password for the new user.
+
Set the password for the new user:
  
 
  # passwd ''user''
 
  # passwd ''user''
  
== User privileges ==
+
== Adding user(s) to the sudo file ==
 +
 
 +
This step will show you how to add your newly created user to the {{ic|/etc/sudoers}} file.
 +
 
 +
{{warning| You should only use {{ic|visudo}} on this file as it saves edits to a temporary file and helps prevent syntax errors before it is saved.}}
 +
 
 +
=== Single user ===
 +
 
 +
Open the {{ic|/etc/sudoers}} file.
 +
 
 +
# visudo /etc/sudoers
 +
 
 +
Tap {{ic|ESC}} on your keyboard and then {{ic|/}} and start typing "User privilege specification" you should see '''root ALL=(ALL) ALL'''
 +
 
 +
Now tap {{ic|ESC}} on your keyboard and then double tap {{ic|d}}, after this press {{ic|p}} twice.
 +
 
 +
This part of the file should now look like something below:
 +
 
 +
{{hc|1=/etc/sudoers|2=
 +
root ALL=(ALL) ALL
 +
root ALL=(ALL) ALL
 +
}}
  
You should only use {{ic|visudo}} on this file, editing this with another editor may make {{ic|sudo}} unuseable.
+
Edit the bottom one and add the username of the user created in the last step.
  
  # /etc/sudoers
+
Example:
 +
{{hc|1=/etc/sudoers|2=
 +
root ALL=(ALL) ALL
 +
''user'' ALL=(ALL) ALL
 +
}}
 +
 
 +
=== Allowing users in a group ===
 +
 
 +
{{Note| I'm using the {{ic|sudo}} group for this example.}}
 +
 
 +
Open the {{ic|/etc/sudoers}} file.
 +
 
 +
  # visudo /etc/sudoers
 +
 
 +
Tap {{ic|ESC}} on your keyboard and then {{ic|/}} and start typing "# %" and press {{ic|enter}}, then press {{ic|n}} twice and it should take you to the needed line in the file. You should see '''%sudo ALL=(ALL) ALL'''
 +
 
 +
This part of the file should now look like something below:
 +
 
 +
{{hc|1=/etc/sudoers|2=
 +
# %sudo ALL=(ALL) ALL
 +
}}
 +
 
 +
Simply remove the hash to uncomment the line.
 +
 
 +
Example:
 +
{{hc|1=/etc/sudoers|2=
 +
%sudo ALL=(ALL) ALL
 +
}}
  
 
== Enabling multilib repositories ==
 
== Enabling multilib repositories ==

Latest revision as of 12:25, 24 June 2019

Unofficial Arch Linux Installation Guide

Warning: This is an unofficial Arch Linux installation guide written by myself.

This guides aim is to make it as easy as possible for some who has never used a GNU/Linux system to install Arch Linux.

nano should be used to edit text files, however vim is also available.

Text in italics means you should replace the text with something appropriate to your install.

Prerequisites (Pre-boot)

Note: Regardless of the installation you will be attempting these steps need to be followed.

Download Arch Linux.

Verify the ISO

Note: These next steps require either a system with GnuPG installed or an Arch Linux derivative.

Download the PGP signature, cd to the directory where both the ISO image is saved and the .sig file is saved, and then verify the ISO.

Example:

$ cd ~/Downloads
$ gpg --keyserver pgp.mit.edu --keyserver-options auto-key-retrieve --verify archlinux-version-x86_64.iso.sig

The following command can be used if using an Arch Linux derivative:

$ pacman-key -v archlinux-version-x86_64.iso.sig

Copy ISO to a USB

You can use the tool dd to copy the ISO to the USB via the command line, alternatively you could use Etcher if you like a GUI.

Below is an example of how you can use dd to copy the ISO to a USB.

# dd if=archlinux-version-x86_64.iso of=/dev/sdX status=progress

Once the ISO is copied to the USB boot to it.

Prerequisites (Live USB)

Note: Use Shift+PageUp and Shift+PageDown to scroll in the TTY.

Keyboard layout

If you need a keyboard layout that isn't US English use the command below to list possible keymaps.

# ls /usr/share/kbd/keymaps/**/*.map.gz

Set the keymap.

# loadkeys uk

Verifying boot mode

# ls /sys/firmware/efi/efivars
Warning: If nothing is listed here, you are NOT in EFI mode.

Connecting to the internet

If using Wi-Fi use the command below.

# wifi-menu

If you are on a wired connection you should connect to the network automatically, if you don't use the command below.

# dhcpcd

Verifying internet connection.

# ping archlinux.org

Changing mirrors

On another device visit the link below and generate mirrors for your country.

https://www.archlinux.org/mirrorlist/

Once you have generated mirrors edit /etc/pacman.d/mirrorlist with the new mirrors.

Sync the newly added mirrors.

# pacman -Syyy

Syncing the clock

Use the command below which will use systemd's Network Time Protocol service to sync the clock with a server.

# timedatectl set-ntp true

Verify the clock synced.

# timedatectl status

Standard UEFI Install

Partition the disk

Warning: The first thing to do is to list the disks in your system. This guide will be using /dev/sdX. Please make sure you are targeting the correct drive as loss of data will occur.

Use the command below to list the disks in your system.

# fdisk -l

Target the disk you will be using for installation.

# fdisk /dev/sdX

EFI partition

Use g to create a GUID partition table as opposed to a Master boot record.

Use n to create a new partition.

Skip the partition number with ENTER.

Skip the first sector resizing with ENTER.

Next make the size of the partition 512MB big with +512M. This will be used for UEFI.

Use t to change the type of the partition.

It will automatically select the partition as it is the only partition on the disk.

Use 1 to set the partition to EFI.

Root partition

Now create the root partition where Arch Linux will be installed with n.

Keep this partition as number 2 with ENTER.

Skip the first sector resizing .

Skip second sector resizing with ENTER, so the rest of the disk is used.

Finally write all these changes to the disk with w.

Note: You should check the partition layout with p before writing the changes.

Example layout

Your drive should look like something below.

Mount point Partition Type Size
/mnt/boot /dev/sdX1 EFI (FAT32) 512M
/mnt /dev/sdX2 Linux FS (ext4) 7.5G

Format partitions

Format the EFI partition to FAT32.

# mkfs.fat -F32 /dev/sdX1

Format root partition to ext4.

# mkfs.ext4 /dev/sdX2

Mount partitions

Next mount the partitions.

# mount /dev/sdX2 /mnt

Make a directory before mounting the boot partition otherwise it will fail.

# mkdir /mtn/boot

Now mount the boot partition.

# mount /dev/sdX1 /mnt/boot

Install the base system

Next install the base system along with base-devel and the linux-headers package.

Note: You can add more packages here if you would like.
# pacstrap -i /mnt base base-devel linux-headers

Generate fstab file

Generate a fstab file so Arch Linux knows how to boot properly.

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

Chroot into the system

This will transfer you from the live USB to your new Arch Linux install.

# arch-chroot /mnt

Install packages

Note: Microcode packages should be installed for your CPU.

The Intel package is intel-ucode

The AMD package is amd-ucode
# pacman -S grub efibootmgr dosfstools os-prober mtools vim bash-completion

Configuring GRUB

Tip: This guide will use GRUB as it's choice of boot loader. Take a look at this wiki page for more boot loaders.

Mount EFI partition

Create the folder below as the partition won't mount.

# mkdir /boot/EFI

Now mount the partition.

# mount /dev/sdX1 /boot/EFI

Install GRUB

Warning: The --efi-directory flag is crucial as GRUB will fail to install.
Note: The --bootloader-id flag can also be changed to your liking.
# grub-install --target=x86_64-efi --efi-directory=/boot/EFI --bootloader-id=Arch_Linux --recheck

English locale file

Copy english locale file for grub.

# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

Generating GRUB config file

You need to generate a config file for GRUB so the system boots.

Note: The microcode packages installed earlier will be included in this config.
# grub-mkconfig -o /boot/grub/grub.cfg

Installation Finished

Tip: It is recommended you follow the #Post-Installation guide for a more complete system.

Post-Installation

Creating a swap file

Tip: It is better to create a swap file rather than a swap partition because they are easier to manage.

This will create a file which is 4GB in size that is located in the root of your install:

# fallocate -l 4G /swapfile

Next set it so only root can manipulate the file:

# chmod 600 /swapfile

This makes the file a swap file:

# mkswap /swapfile

Finally configure fstab so the swap file is loaded on system boot:

/etc/fstab
/swapfile none swap defaults 0 0

Set the locale

Edit /etc/locale.gen and uncomment en_US.UTF-8 UTF-8 and any other needed locales e.g. en_GB.UTF-8 UTF-8

Generate the locales with:

# locale-gen

Next edit /etc/locale.conf with the locale you will use on your system:

/etc/locale.conf
LANG=en_GB.UTF-8

Next do the same for /etc/vconsole.conf so you get the preferred keyboard layout in the TTY.

/etc/vconsole.conf
KEYMAP=uk

Set the time zone

Use the command below which will use systemd's Network Time Protocol service to sync the clock with a server:

# timedatectl set-ntp true

Verify the clock synced.

# timedatectl status

Make a link with your timezone so the clock can adjust accordingly.

# ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime

Lastly set the hardware clock from the system clock.

# hwclock --systohc

Set the hostname

Create /etc/hostname and add a desired hostname:

/etc/hostname
hostname

User management

Set the root password:

# passwd root

This will create a user and it will also create a directory for them in /home:

# useradd -m user

Set the password for the new user:

# passwd user

Adding user(s) to the sudo file

This step will show you how to add your newly created user to the /etc/sudoers file.

Warning: You should only use visudo on this file as it saves edits to a temporary file and helps prevent syntax errors before it is saved.

Single user

Open the /etc/sudoers file.

# visudo /etc/sudoers

Tap ESC on your keyboard and then / and start typing "User privilege specification" you should see root ALL=(ALL) ALL

Now tap ESC on your keyboard and then double tap d, after this press p twice.

This part of the file should now look like something below:

/etc/sudoers
root ALL=(ALL) ALL
root ALL=(ALL) ALL

Edit the bottom one and add the username of the user created in the last step.

Example:

/etc/sudoers
root ALL=(ALL) ALL
user ALL=(ALL) ALL

Allowing users in a group

Note: I'm using the sudo group for this example.

Open the /etc/sudoers file.

# visudo /etc/sudoers

Tap ESC on your keyboard and then / and start typing "# %" and press enter, then press n twice and it should take you to the needed line in the file. You should see %sudo ALL=(ALL) ALL

This part of the file should now look like something below:

/etc/sudoers
# %sudo ALL=(ALL) ALL

Simply remove the hash to uncomment the line.

Example:

/etc/sudoers
%sudo ALL=(ALL) ALL

Enabling multilib repositories

You will need to edit /etc/pacman.conf and uncomment the multilib section.

/etc/pacman.conf
[multilib]
Include = /etc/pacman.d/mirrorlist