Install Arch on VirtualBox – YouTube

Install Arch on VirtualBox

Seven years ago I wrote two posts related to Arch Linux which are: Arch Linux Installation, and Arch Linux Configuration. I went over them and found that they are very outdated. The process has changed a lot since then. So I decided to create a YouTube video on how to install Arch on VirtualBox. This is the first part of a series on Arch Linux that I gradually release. We start with the installation and further do customization that are better known as ricing.

TLDW; This is the bare minimum installation. We don’t add any desktop environment or additional packages as of now. We just install the base system and then continue the customization further in the upcoming videos.

To make it easy to understand I break the installation process into multiple sections.

Keyboard layout

The first step is to set the system layout. By default, en_us layout is loaded.

To get the list of available layouts run,

$ ls /usr/share/kbd/keymaps/**/*.map.gz  # show available layout

Then pick the keyboard layout you want and set it,

$ loadkeys de-latin1 # sets the layout

Check UEFI

Modern machines are shipped with UEFI unless it’s disabled by default. To ensure that run this command,

$ ls /sys/firmware/efi/efivars

If you get any error means either your machine doesn’t have EFI or it’s disabled.

Note: keep in mind in VirtualBox EFI is disabled by default. So expect to get an error when running the above command.

Checking the internet connection

Since the packages are downloaded from the internet during the installation process, it’s necessary to ensure and have an active internet connection. For that run this command.

$ ip link
$ ping google.com

Enable ntp synchronization

To enable synchronization of date and time using NTP run,

$ timedatectl set-ntp true

Partitioning

Partitioning differs whether you have EFI or not. That’s why I separate it into two subsections.

For VirtualBox, skip to the BIOS section.

EFI

For machines running EFI, most probably you need to create an EFI partition if you don’t have it. If you are dual booting, you should already have the EFI partition. You can check it using,

$ fdisk -l

Then to create partitions run cfdisk and select gptd.

After that create three partitions as follows in the same sequence,

  • EFI # if you don’t already have, otherwise skip it
  • /
  • SWAP (> 512MB)

Note: The size of EFI partition should be between 290MB and 512MB.

Last part is to format and mount the partitions,

$ mkfs.fat -F32 /dev/sdX0 # for efi
$ mkfs.ext4 /dev/sdX1 # for /
$ mkswap /dev/sdX2 && swapon /dev/sdX2 # for swap
$ mount /dev/sdX0 /efi
$ mount /dev/sdX1 /mnt 

BIOS

For BIOS machines, just run cfdisk and then select dos.

After that create the following partitions,

  • /
  • SWAP (> 512MB)

Note: don’t forget to flag / as bootable.

Last part is to format and mount the partitions,

$ mkfs.ext4 /dev/sdX1 # for /
$ mkswap /dev/sdX2 && swapon /dev/sdX2 # for swap
$ mount /dev/sdX1 /mnt 

Installing the base Arch and packages

Now we need to install the packages we need. I recommend the following list based on experience to have the absolute minimum installation,

$ pacstrap /mnt base base-devel linux linux-firmware grub intel-ucode dhcpcd vim sudo

Keep in mind base and linux are mandatory.

Generating fstab

Once all the packages installed, it’s time to generate fstab so at least / and swap will be automounted.

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

Setting timezone

First, chroot to the installation partition,

$ arch-chroot /mnt

Then set the timezone as you wish

$ ln -sf /usr/share/zoneinfo/Region/City /etc/localtime

And sync the hardware clock,

$ hwclock --systohc

Set locale and keyboard layout

To set locale, open /etc/locale.gen and uncomment the locale you want. Then generate the locale,

$ locale-gen

Now we have to set the language env vars,

$ echo "LANG=en_US.UTF-8\nLANGUAGE=en_US" > etc/locale.configuration

Network configuration

Add the hostname to /etc/hostname and then set the static mapping as follows,

$ vim /etc/hosts

Add the following content

127.0.0.1 localhost
::1 localhost 
127.0.1.1 hostname.localdomain hostname  # replace `hostname` with the one you set in the previous step

Finally, enable dhcpcd service on startup in systemd so that the network connection will be established automatically.

$ systemctl enable dhcpcd.service

Grub installation

To install run one of the following command depends whether you have EFI or BIOS,

$ grub-install --target=i386-pc /dev/sda # for BIOS
$ grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=GRUB # for EFI

Then create the configuration,

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

Setting up a user

First, let’s set the root password,

$ passwd

Then we create a user and add it to the appropriate groups,

$ useradd -m [username]
$ passwd [username]
$ usermod -aG adm,ftp,games,http,log,rfkill,sys,systemd-journal,uucp,wheel [username]

And finally, give the user sudo privileges,

$ visudo

Add the following to the file,

[username] ALL=(ALL) ALL

Once you’ve done, exit chroot and reboot the machine, you should be able to successfully boot to the Arch Linux.

Inline/featured images credits