Boot from USB

Information for people who want to install Arch Linux on an SSD or harddisk

Before booting from a USB stick, you should check your hardware settings. Boot into your hardware settings - BIOS or UEFI. Then check following settings. It can have different names and different keyboard shortcuts to reach it.

  • Disable Secure Boot
  • Disable Launch CSM or Legacy Support
  • Set Boot Mode to UEFI
  • Enable USB Boot
  • Set USB Disk as boot priority

For more information - take a look at this page.

Here are all the articles where we change the settings on our motherboard to be able to boot Linux.

Boot from the iso in VB
The image above is proof that we are booting with EFI enabled in Virtualbox.

Then we have to wait quite a long time before Arch Linux kicks in and boots up. That is normal.

pre-installation
Set the keyboard layout
Arch Linux standard boots into an US keyboard layout. Many of us do not have to do anything. Just check the main keyboard keys and see if they all work.

But others need to change for example from qwerty to azerty.

We follow this link on the wiki to test things out:

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

We have used this command to have a list of all possible keyboards out there.

find /usr/share/kbd/keymaps/ -type f | more

Finally I will use this code to have my Belgian azerty keyboard. You choose your keyboard layout.

loadkeys be-latin1
VErify the boot mode
It is not really necessary IF you saw the first image on this page. It tells you the Arch Linux usb stick is booting into UEFI.

You can get confirmation with this code :

ls /sys/firmware/efi/efivars

or

efivar -l

If you get a bunch of lines, all is well.

Connect to the internet
Normally you will be connected to the internet out of the box.

On virtualbox you will ALWAYS be connected IF your host computer has internet.

We test our internet connection via

ping -c 4 archlinux.org

I added “-c 4”. Now it will only ping 4 times.

We can ask also some more information about our interface with

ifconfig

The name of your ethernet (or wifi) interface is important to know. In my case enp0s3.
You will need it later in conkies etc.

Your DHCP server (mostly a router) has provided you with all the information you need to go on the net :

  • Ipaddress for your pc
  • Subnetmask
  • Gateway ipaddress
  • Nameserver to resolve the names into an ipaddress
UPDATE THE SYSTEM CLOCK
We tell our computer to sync the date and time. At this point we do NOT say what timezone we are in.
timedatectl set-ntp true
Partition the disks
This is the most dreaded part and it is also the topic of much debate online.
What tool to use?
What partitions to make?
In what order?
What size?

We will use a minimal partition in order not to complicate things.

  • EFI System partition /dev/sda1 with 550MB, FAT32 format
  • Swap partition /dev/sda2 with 2XRAM recommended size, swap on
  • Root partition /dev/sda3 with at least 20GB or the rest of the space in ext4 format

Since I made only a 30GB harddisk in my virtualbox, I will only take 10GB for my swap partition. Rule of thumb is twice your RAM for the size of your swap.

With the commands fdisk -l or lsblk we discover that our harddisk is named /dev/sda.

That is all we need to know to get started.

cfdisk
Then we start cfdisk to partition our harddisk. You can also use fdisk, gdisk or parted. I choose to go with this more or less graphical partitioning tool.

We have choosen to install UEFI or EFI so we choose now GPT.

On a virtualbox and on a freshly bought ssd or harddisk you will get the same image.
However if you are reusing a harddisk, you will see lines (partitions) on there.
Delete all the partitions untill you have the same view like image beneath.

Notice the words Label: gpt in the third line.

If that is not the case, first type this in a terminal.

wipefs -a /dev/sda

If that is not working for you, you can try this one as well:

sgdisk -Z /dev/sda
Use the arrow keys to move around cfdisk.
Press enter on the New menu and type 550MB and press Enter.
Select the type from the bottom menu and choose EFI SYSTEM partition type.
That will result in this layout.
Now that the EFI partition is created. Let us create the swap partition.
As a rule of thumb it must be twice the RAM. In my case that would be 32 GB and I have only 30GB in my virtualbox. I will take 10GB for SWAP in this exercise.
Move the selection to Free space.
Move the selection to New and press Enter.
Type in the amount of Swap you want to use – 10 GB in this case and press enter
Move the selection to Type and choose Linux swap.
We will stick to 3 partitions.

We can make more partitions if you want. More info about partitions here.

Move the selection to Free space.
Move the selection to New and press Enter.
Take the rest of the amount for your root partition or / and press enter
Move the selection to Type and choose Linux filesystem. (already a Linux filesystem)
Move the selection to Write.
And type “yes” and press enter.
When you typed yes and confirmed it with an Enter you can select quit.

When typing lsblk things must be changed. We have now 3 partitions.

The partitioning information in the video about either

  • 4 primary partitions or
  • 3 primary partitions and one extended partion with many logical partitions

applies on an MBR setup. It might seem out of place here but I thought I pass that knowledge along here already.

In regards to EFI I find information that we can go till 128 primary partitions not that we will need as much ever. Link for more info.

Format the partitions

We have sliced our harddisk into 3 pieces but we did not format them yet.
That is what we will do now with these commands.

Formatting the EFI partition

mkfs.fat -F32 /dev/sda1

Formatting the swap partition and activating it

mkswap /dev/sda2
swapon /dev/sda2

Formatting the root partition.

mkfs.ext4 /dev/sda3
mkfs.fat -F32 /dev/sda1
mkswap /dev/sda2
swapon /dev/sda2
mkfs.ext4 /dev/sda3
Mount the file systems

 We need to mount our created partitions into our linux hierarchy. First we need to mount sda3 (root) into /mnt.

Then we create /mnt/boot/efi in which we will mount /dev/sda1.

This may differ with older videos.

mount /dev/sda3 /mnt
mkdir /mnt/boot
mkdir /mnt/boot/efi
mount /dev/sda1 /mnt/boot/efi
INSTALLATION
Select the mirrors
You can select the mirrors that are closest to you geographically BUT it does not mean they will be the fastest. Normally I will change nothing until the speed is not satisfactory. As an example I changed some of the settings with nano and showed you how to save it then.

Read the info about mirror servers as this is quite important.

In nano use left shift and arrows to select lines (white background and black letters) and then delete those lines with left alt and delete button.

nano /etc/pacman.d/mirrorlist
Install the base and base-devel packages

We are going to install the base and base-devel packages on our mounted partition in /mnt now. This will become our Linux system later on. Content of base package changed 10/2019.

Vi is available by default. We will need to edit files later on with nano.

visudo is needed later on. Installing base-devel will install the sudo package to be able edit visudo later on.

pacstrap /mnt base base-devel linux linux-firmware nano
CONFIGURE THE SYTEM
Fstab

Let us use the script genfstab to generate a fstab file so linux will know what partitions we have like root and swap.

If the text underneath shows “>” again we actually mean “>“.

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

You should have 2 partitions when you open the file with

nano /mnt/etc/fstab
CHROOT
Let us now move inside your future linux system and change elements there.
With exit you can exit this chroot environment should you want it.

I can only recommend you read the article about chroot. It helped me fix a broken Arch Linux system in the past.

arch-chroot /mnt
Time zone

Here we are going to set our timezone aka where do you live according to Linux.

We investigate all the possibilities by navigating to the folder zoneinfo.

ln -sf /usr/share/zoneinfo/RegionCity /etc/localtime

In my case I used

ln -sf /usr/share/zoneinfo/Europe/Brussels /etc/localtime

Then we set the hardware clock from the systemclock with this command.

hwclock --systohc
LOCALE

In the locale we are going to set your localization.

What language do you want the system to be in?

You can investigate by using this command and uncomment the language or languages you prefer.

In my case I used en_US.UTF-8 and deleted the hashtag in front of it. Use the Page up and Page down key to navigate throught the list. You need to find out your language.

Belgium -Dutch would be nl_BE.UTF-8.

nano /etc/locale.gen

Then we save the file and generate the locale by running this command

locale-gen

We will also set the variable LANG or language to reflect the same choice.

We will use the shorter version at the bottom.

nano /etc/locale.conf

And type in this file

LANG=en_US.UTF-8

and save it.

IF you changed the keyboard layout like me you should do this too.
Let us make sure Arch Linux remembers to use my azerty keyboard after rebooting.

nano /etc/vconsole.conf

and add this line to it and save it afterwards

KEYMAP=be-latin1

If the text underneath shows “>” again we actually mean “>“.

Shorter alternative

echo LANG=en_US.UTF-8 > /etc/locale.conf
echo KEYMAP=be-latin1 > /etc/vconsole.conf
HOSTNAME

We need to give our computer a name. Best is to choose one with no special characters and no spaces.

There is the longer way where you use nano and the shorter way. Up to you to decide. The result will be the same

nano /etc/hostname

Write the name you have choosen for your computer.

Then we save the file with CTRL + X.

We did the shorter alternative in the video this time.

Ps. I mixed up the hostname file between tutorials Arch Linux, Archlinux and ArchErik. Just take one unique name.

If the text underneath shows “>” again we actually mean “>“.

Shorter alternative

echo Archlinux > /etc/hostname

Then we edit our /etc/hosts file so it reflects this code. Use the TAB to align them.

nano /etc/hosts
127.0.0.1	localhost
::1 localhost
127.0.0.1 Archlinux.localdomain Archlinux
NETWORK CONFIGURATION
We will use the application NetworkManager afterwards in any of our desktops we would like to install. Therefore it makes sense to install and activate this application right now.

Make sure you type NetworkManager in the second line. It is case sensitve.You will get 3 symlink lines as a result. When we boot we will have internet on board.

pacman -S networkmanager
systemctl enable NetworkManager

Watch out for typos – capital letters are a must in “NetworkManager”
Do not get 3 lines – you made an error

Initramfs

Creating a new intramfs is not required according to the wiki as result I will not create one with the command mkinitcpio -p linux.

Nothing to do here!

Root Password
We add a password to our root account with this command. Choose your password wisely.
passwd
Boot loader

To install grub to our system in order to be able to boot later on we need to pass these commands (you can add os-prober to the installation line if you multi-boot):

This may differ from the videos.

We have create a directory /boot/efi and mounted /dev/sda1 in it. So we need to refer now to that directory.

pacman -S grub efibootmgr
grub-install --target=x86_64-efi --efi-directory=/boot/efi

Sometimes you see people add –recheck as extra check. It does not seem necessary.
We still need to make the grub configuration file with this command in order to be able to boot.

grub-mkconfig -o /boot/grub/grub.cfg

NOT a part of the standard installation

What if you are planning to switch ssds with a ssd bay like in this article?

This may be different on other hardware.
I need to create an extra directory and copy and rename a file in order to pop out one ssd and reboot another.

Only do if you need this.

mkdir /boot/efi/EFI/boot
cp /boot/efi/EFI/arch/grubx64.efi /boot/efi/EFI/boot/bootx64.efi

If I do not do this and still switch ssd, I will get this message

Reboot and Select proper Boot device
or Insert Boot Media in selected Boot device and press a key

What if you now see this message from above?

Arch Linux can ALWAYS be repaired. That is what this article is trying to tell you.

Reboot
Rebooting

Now we can think about rebooting the system.
Type exit to get out of the chroot environment.

exit

We can optionally unmount our disks with

umount -R /mnt

Then we can reboot with

reboot

And log back in with root as user and his/hers password.

The image beneath is proof that grub has been installed correcly.

exit
umount -R /mnt
reboot
Reboot after shutdown of virtualbox

We assume you have Arch Linux installed on Virtual Box and that you shutdown the virtual machine.

When you restart Virtual Box you will be presented with this screen underneath.
Select storage and make sure the iso of Arch Linux is deselected from IDE Secondary Master.

Then we start our Arch Linux and we will boot into grub.