Fix for virtualbox

UEFI or EFI on VirtualBox is said to be still experimental. When phase 1 is complete and you reboot, grub will load Arch Linux. BUT if you shutdown virtualbox, you will not be able to boot into Arch Linux anymore. Fortunately I found a workaround. If you have found a “nicer and easier” solution, let us know. Solution is at the bottom of the page.

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

Before booting from an usb stick you better check your hardware settings. Boot into your hardware settings or BIOS or UEFI settings. 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

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.

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

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 :

or

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

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

We can ask also some more information about our interface with

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.

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.

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.

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

Formatting the swap partition and activating it

Formatting the root partition.

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 in which we will mount /dev/sda1.
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.

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 lateron.

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, efi and swap.

You should have 3 partitions when you open the file with
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.

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.

In my case I used

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

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 would be nl_BE.UTF-8.

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

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

And type in this file

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.

and add this line to it and save it afterwards

Shorter Alternative

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

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 ArchLinux, Archlinux and ArchErik. Just take one unique name.

Shorter Alternative

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

I have choosen ArchErik as hostname for my computer. You change it to your name.

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.

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.

But on ArcoLinux we made an article about the ugly lines when you shutdown. In that article we edit /etc/mkinitcpio.conf and add shutdown to the hooks. We will first experiment with the standard configuration and see what we get.

I show you in the video where you can add this “shutdown” if we need it lateron.

Re-edit after shutdown: we see these “ugly” lines upon shutdown as well on Arch Linux. We can do the fix later. It is just for cosmetic reasons.

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

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

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 lateron.

Fix for virtualbox
We only need to do this fix IF WE ARE ON VIRTUALBOX. You can reboot with VirtualBox and end up in the grub but you can NOT shutdown. You will end up in the boot screen from the iso.

We need to copy and rename a specific file to solve the issue.

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

We can optionally unmount our disks with

Then we can reboot with

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

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

Reboot after shutdown of virtualbox
We assume you have ArchLinux installed on Virtual Box and that you shutdown the virtual machine.

We also assume you followed the steps above in Fix for Virtual Box.

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.
This will work because of the efi file we copy/pasted and renamed earlier on in the Fix for VirtualBox.