EREVALD KULLOLLI

How to install Arch Linux on VirtualBox

Requirements

Let’s start by creating a new Virtual Machine (VM) in VirtualBox. For this example we are going to name it “Arch”. Make sure the type is set to “Linux” and version to “Arch Linux (64-bit).

On the next step we have to specify how much RAM we want to allocate to this VM. Stay within the green color range and you should be fine. For this example I am choosing 4GB.

Now we have to create a new Virtual Hard Disk. Choose “Create” and select the first option from the list “VDI”. Choose “Dynamic” on the next step, select a folder to save it and specify the size. We are going to use 12GB for this guide.

Important:

  • Go to the settings of the VM we just created and under the “System” tab enable the “EFI” option.

We are now ready to start the VM! When started for the first time you will be prompted to load an ISO image to boot. Select your Arch ISO file and start the VM.

Make sure you select the UEFI option from the list during boot.

Important:

  • Be patient for the Arch to startup. This may take awhile.

Once loaded you will be presented with the command prompt. The first thing to do here is to prepare and partition the Hard Drive.

Type the following command:

$ cfdisk

A few options will appear on the screen. Select “gpt” and hit Enter. By using the provided editor we create first a partition with a size of 1024M (The default entry will be 12G, just delete that and choose 1024M). Once created, go to “Type” and select “EFI System” from the list. Now back to the previous screen create another partition with a size of 8G. Create the final partition with a size of 3G. Choose “Write” when done.

Time to format the partitions we just created. Type the following commands:

$ mkfs.ext4 /dev/sda2
$ mkfs.ext4 /dev/sda3
$ mkfs.fat -F32 /dev/sda1

Now let’s mount the partitions:

$ mount /dev/sda2 /mnt
$ mkdir /mnt/boot
$ mkdir /mnt/home
$ mount /dev/sda1 /mnt/boot
$ mount /dev/sda3 /mnt/home

All done and ready now. Let’s install Arch.

$ pacstrap /mnt base

Create the “fstab” file:

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

We can now root into the system.

$ arch-chroot /mnt

Create a locale and choose language. We are using NZ English for this guide.

$ nano /etc/locale.gen

Locate your language and un-comment it. Save and exit the editor.

Enter the following commands (modify to match your language).

$ locale-gen
$ echo LANG=en_NZ.UTF-8 > /etc/locale.conf
$ export LANG=en_NZ.UTF-8

Set up a host name for the system (“archbox” for this guide)

$ echo archbox > /etc/hostname

Now we configure the DHCP service.

$ systemctl enable dhcpcd.service

Set a password for the “root” user.

$ passwd

We need some sudo tools, let’s install them.

$ pacman -S sudo

It is not a good idea to use the “root” user therefore we need to create a standard user (“archuser” for this guide).

$ useradd -m -g users -G wheel -s /bin/bash archuser
$ passwd archuser

Allow the standard user to use sudo.

$ EDITOR=nano visudo

Find and un-comment this line:

  • %wheel ALL=(ALL) ALL
  • Save and exit.

To make things easy we need to install a boot loader. We are going to use GRUB for this guide. Install and configure:

$ pacman -S grub efibootmgr
$ grub-install /dev/sda --target=x86_64-efi --efi-directory=/boot
$ grub-mkconfig -o /boot/grub/grub.cfg

Finally let’s exit the environment and reboot.

$ exit
$ reboot

GRUB does not work properly at this stage so we need to correct it.

$ mkdir /boot/EFI/boot
$ mv /boot/EFI/arch/grubx64.efi /boot/EFI/boot/bootx64.efi

Reboot again and login as the standard user we created earlier. You may notice some errors instead of the login prompt. Press Enter and it should allow you to enter the login credentials. Time to install the display Manager and Desktop Environment. There are many options for Arch such as KDE, Xfce etc. We are going to use LXDM with LXDE for this guide.

$ sudo pacman -S xorg xorg-server
$ sudo pacman -S lxdm
$ sudo systemctl enable lxdm.service
$ sudo pacman -S lxde

Update the system:

$ sudo pacman -Syu

Make things easier by installing a terminal and a nifty utility.

$ sudo pacman -S lxterminal
$ sudo pacman -S screenfetch

That’s it! Reboot the system, login and open the terminal. Type:

$ screenfetch

Enjoy :)

Optional

Install VirtualBox drivers.

$ sudo pacman -S linux-headers
$ sudo pacman -S virtualbox-guest-utils
$ sudo nano /etc/modules-load.d/virtualbox.conf

Add the following lines, save and exit.

vboxguest
vboxsf
vboxvideo

$ sudo systemctl enable vboxservice.service
$ sudo usermod -a -G vboxsf archuser
Topic
Linux VM