How to install Arch Linux on VirtualBox

Arch Linux is a Linux-based operating system that is designed for i689 and x86-64 computers. Its unique package manager is responsible for providing updates to the latest software applications using “pacman” with complete tracking. Pacman is the package manager that is used to install, update, and remove the software packages. It is designed entirely for free and open-source software, along with the support from the Linux community.

Arch Linux is also popular for having a comprehensive documentation in form of the community wiki known as ArchWiki. This Linux operating system is based on binary packages that are targeted for i832, 64-bit, and 32-bit systems and optimized for the best performance on modern hardware systems.

You can install Arch Linux directly to your home computer by following this guide but you can also install it on a virtual machine on your Windows computer by using VirtualBox.

Arch Linux Repositories

To install Arch Linux on Virtual Box, you must know the basic repositories of this Linux-based operating system. A repository is a storage location from where the software packages are retrieved during the installation process. There are multiple repositories available for Arch Linux, which are accessible via pacman and maintained by package maintainers. Here is a list of some of the basic repositories used to install Arch Linux on Virtual Box:

  • The core repository contains all the packages that are needed to setup the base system like booting Arch Linux and building packages.

  • The extra repository contains extra packages that do not fit in the core involving desktop environment.

  • The community repository has packages that are adopted by trusted Linux community users, and most of them will transfer to the core or extra repository.

  • The Multilib repository contains 32-bit software and libraries for 32-bit application installation on 64-bit system.

  • The testing repository contains packages that are destined for core or extra repositories.

  • The community-testing repository is for the Linux community.

  • The multilib testing repository is similar to the testing repository, but for multilib candidates.

  • The gnome-unstable repository has the latest GNOME desktop environment.

  • The kde-unstable repository contains the latest KDE software before they are been released.

Install Arch Linux on Virtual Box

Download Arch Linux

To install Arch Linux on Virtual Box, you must have the latest Arch Linux version that you can download from their official website. You can pick either the direct download option or torrent download, which is on a secure server. Before the installation, make sure you have 20 MB of free disk space and 1 GB of RAM in your system.

Download Arch Linux

Initializing Installation with Oracle VM VirtualBox Manager

Open the Oracle VM VirtualBox manager, click on new, and type in the name of the new operating system you want to create; in this case, it is Arch Linux. The system will automatically pick up the type and version of the Arch Linux, based on your system’s configuration. Click on next.

Open VirtualBox

Allocate the desired  RAM size to your new operating system, which is ideally 1024 MB. Click on next and then click on create, to create a virtual disk now.

Set RAM size

On the next page, you will be asked to select the type of hard disk file you want for your new operating system. Select VirtualBox Disk Image usually.

Select disk file type

Choose dynamically allocated and click next.

Allocate disk space dynamically

Allocate 20 GB hard disk file location and size.

Choose a hard disk size of 20GB

Now you can see that your Arch Linux operating system is created. Now you can click start.

Start the Virtual Machine

Click on 'browser' and select the startup disk, which you downloaded from the Arch Linux official website.

Choose Arch Linux Disk image

Browse for disk image file

Click on start and then open the full-screen view.

Open the full-screen view

Start the Arch Linux VM

Booting to Install Arch Linux on Virtual Box

You will see the first opening page of Arch Linux. Click on “Boot Arch Linux (x86_64), which is for 64-bit or click on “Boot Arch Linux (i686)”, which is for 32-bit.

Choose to boot Arch Linux

As soon as you click on the first option, the system will start booting. While it completes the temporary boot, we are basically moving into the live version and are logged in as root user.

Booting into Arch Linux live version

Check the Internet connection by typing in the following command.

ping google.com 

The word ping stands for packet internet gopher. You will soon see the response that means Arch Linux has activated the Internet connection. This is essential to perform certain installation steps.

Test internet connectivity with ping

Clear the command by typing

clear

Before we start the installation, you should partition your drive. Type # fdisk – l and you will see the current system’s disk partition. Focus on the 20 GB hard drives that you allocated to Arch in the beginning.

fsdisk -l

Partition the harddisk

Partition the hard disk

We are going to partition this 20 GB space into three partitions. The first one is the primary root partition that will be of 10 GB. The second will be the swap partition, which will be twice the initial RAM allocation that will be 2048 MB. The third will be the logical partition that will be 8 GB allocated.

Create 3 disk partitions

Type the command:

cfdisk

 You will see gpt, dos, sgi, and sun. Select the dos option and press enter.

Create a partition of type DOS

Here you will see the main disk space, which is 20 GB. To change this, press <enter> on the free space and type 10G.

Choose 10GB partition size

Press enter and then click on the “primary” partition.

Now select the “bootable” type by pressing enter on bootable.

Make partition bootable.

Go to write and press enter, to write partition to disk.

Write partition to disk

Then type yes to make the changes, successfully.

Confirm changes

Now the 10 GB partition is created. Click on free space and then enter the partition size of 2048 M.

Create the 2GB swap partition

Now follow the same steps to create the logical partition. Then press enter on quit and clear the command by typing

clear

quit cfdisk

Format the newly partitioned disk by typing:

mkfs.ext4 /dev/sda1

Here sda1 is the partition name. Repeat this for the second drive by typing:

mkfs.ext4 /dev/sda3 

and for the swap partition,

mkswap /dev/sda2

Format the swap partition with mkswap

Activate the swap by typing:

swapon /dev/sda2 

and clear the command by typing:

clear

Enable swap

Mount the primary partition to start the installation part by typing:

mount /dev/sda1 /mnt
mkdir /mnt/home
mount /dev/sda3 /mnt/home

Mount the partitions

Bootstrap Arch Linux

Bootstrap the system by typing:

pacstrap /mnt base base-devel

You can see that it is synchronizing the data packages.

Bootstrap Arch Linux

The installation will start and will take a few minutes.

Arch Linux installation has been started

After the base installation create the fstab file by tying:

genfstab /mnt>> /mnt/etc/fstab 

Generating /etc/fstab

Configure locale, time and root password.

Change the system root to the Arch Linux installation directory by typing:

arch-chroot /mnt /bin/bash

 

Now to configure the language settings:

nano /etc/locale.gen

Set language in Arch Linux

Select the following language configuration (en_US.UTF-8 UTF-8) by deleting the # and pressing control + x, press y, and press enter.

select language

Now activate it by typing:

locale-gen

and press enter.

Generate the locales in Arch Linux

Create the  /etc/locale.conf file by typing:

nano /etc/locale.conf 

then press enter. Now you can add your language to the system by adding this line to the file:

LANG=en_US.UTF-8

 Then press control + x and press y, and press enter.

Set default language

Synchronize the zone information by typing:

ls /usr/share/zoneinfo

and you will find a list of all the zones of the world.

Set System language default

To select your zone, type:

ln –s /usr/share/zoneinfo/Asia/Kolkata /etc/localtime 

or you can select any name from the below list.

Set the time standard using the command.

hwclock --systohc --utc

And the hardware clock is synchronized.

Set time

Set the root user password by typing:

passwd 

And press enter. Then type your password and press enter.

Set the root password

Setup hostname and networking

Enter the host name of the network by typing:

nano /etc/hostname

and press enter. Now type any name and then press control + x and press y, and press enter.

Set the hostname

Enable the dhcpcd by typing:

systemctl enable dhcpcd

and it will be started at next boot time to fetch an IP address automatically.

Enable dhcpd

Install the Bootloader

The final step, initiate the grub installation. Type:

pacman –S grub os-prober

then press y and the download part will begin.

Configure grub

Install the grub boot loader to the hard disk by typing:

grub-install /dev/sda

and configure it:

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

Install and configure grub boot loader

Finally, exit from chroot and then reboot the system by typing:

exit
reboot

and press enter.

Reboot the system

Boot into the installed ArchLinux operating system

Choose “Boot Existing OS” to boot Arch Linux on Virtual Box.

Boot Arch Linux

Login with your root name and password, and you will enter your new Arch Linux operating system.

Arch Linux installed successfully

Share this page:

Suggested articles

74 Comment(s)

Add comment

Comments

By: steve_dupuis

Suggestion: use Arch-Anywhere distro

 

By: tanrt

Some corrections..

Remove the period at the end of this command:  mkswap/dev/sda2. 

It's usr and not user in this command: ls user/share/zoneinfo_

Should be prober and not rober in this command:  pacman –S grub os-rober

By: David

There will be no home directory mounted, this tutorial is not helpfull for newcomer to ArchLinux

By: Arielle

Do you know how to do that?

By: anon

would be nice to add on tutorial how to install a desktop environment and a window manager

By: Sandokan

Thanks!

Just a fix: in the end, before rebooting, you need to exit the chroot by typing exit, and then reboot.

By: horsetamer

I suggest adding a tip to change your mirror by modifying /etc/pacman.d/mirrorlist before you run pacstrap!

By: noname

First of all: WTF is with you command typing dude? Correct your code!

Second of all this line should be: ln –sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime

By: NONaME

No one wanted your opinion

 

By: Pedro

There is a typo in: "pacman –S grub os-rober" at the end shoud be "prober"

 After installation, just after rebooting, you need to exit the chroot command. So it should be "exit" [enter] and then "reboot" [enter].

 

Great tutorial.

By: Aslam

This is a great tutorial for newbies like me. You just need to correct typos.

By: dcpope

This tutorial does not follow the current version of VirtualBox, does not completely cover the process for creating the partitions, and is full of typos. Time for a rewrite.

By: Dan

finally! got Arch on VirtualBox. Thank you. Very helpful

By: Robin

Great tutorial, but only takes things to a very basic level. A follow up on setting up users, desktop environment etc. would be useful or at least some links.Echo other users comments on typos - needs a serious clean up.

By: ErraticFox

This article seriously needs cleaned up in the command line parts. There's some absolutely **terrible** typos in the commands.

By: dax

Thanks good explantion for this install for noob tome

By: AJ

for the second partiton, does it need to be primary or extended? Sorry for the dumb question. There is no specific instructions there.

By: some_guy

Good post but quite a few errors in your instructions.  The only way to make it through this is to go off of the screen shots.

By: till

Thank you for the notice. I've fixed the commands.

By: Jackson

Got me through the install, however you need to go double check everything. the mistakes you have made (like mistaking a lowecase L for the number 1) are shocking!

By: till

Thank you for the notice. I've fixed that in the tutorial.

By: Daniel

Best ArchLinux installation tutorial! Just please fix all the typos to make it more than perfect:-)

By: someone

please look through everything and spell-check this stuff

By: Gabriele

this one is wrong:

arch-chroot /mnt/bin/bash

should be:

arch-chroot /mnt  /bin/bash

By: person

Please revise the entire guide, or just remove it. The fact this guide is the number 1 google search result for "Install arch linux in virtualbox" is terrible.

 

Almost all the commands have many typos, and the only way to understand the guide is too look at the screenshots. But that doesn't even work most of the time because you type clear in the console (why?)

By: till

Thank you for the notice. The tutorial has been revised and updated now.

By: Jason

The install went mostly smooth except for a few problems. The 'ls /usr/share/zoneinfo_' command wouldn't pull up the time zones for whatever reason.

 

Also trying to run the 'Reboot' command told me I needed to 'Exit Chroot' which was confusing at first but just typed 'exit' after searching on google(Confusing from never using Arch before)

 

Everything seems to be working though and thanks for the tutorial!

By: sabinscabin

two typos: /user/share should be /usr/share, and you need to exit chroot mode using exit or ctrl-d before trying to reboot

By: till

Thank you for the note. I've corrected the tutorial.

By: evangel

great tutorial for a newbie like me.

started learning linux with RPi. ther is a tutorial how to add GUI / desktop env (google it) for a basic system, for those interested.

other issues:

please correct ls /use/share/zoneinfo_  to ls /usr/share/zoneinfo

brgs/evangel

By: Joyfilled

Does not work for me, every time i login it puts me back to the terminal and it says as the user [[email protected] ~]#

By: Markus

ls /use/share/zoneinfo

should be usr instead of use?

By: till

That's wrong in the tutorial text indeed, thank you for the notice. I've corrected that.

By: jaro

after i type nano /etc/locale.gen i see only black screen without  language configuration. GNU nano version 2.9.4

By: im not telling

at the end, how do i get into the desktop and out of the command thing.

By: german

Thank you, I followed the tutorial and I got Arch in Virtual Box. There was only an error: after writing "ln –s /usr/share/zoneinfo/Europe/UTC /etc/localtime" I received a message "/etc/localtime: The file already exists". Have I to worry about it?

By: Jibbius

Works if you use the following instead;ln -sf /usr/share/zoneinfo/Europe/UTC /etc/localtime

By: Mateusz

Got to the point "ping google.com", it keeps pinging, I can't do anything, help!!! 

By: till

Press [ctrl] + c to stop the command.

By: Andrew Yang

Jeez! It should be time for archlinux to create an actual installer

By: ArttyY

My archlinux boots into grubshell

By: jay

Why do we create a mount point at /mnt/ and a separate "logical" memory mount point at /mnt/home ? What is the purpose of the logical memory? 

By: cereberus

This part was throwing me errors (Host: Windows 10, Guest: archlinux-2018.12.01-x86_64.iso):

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

The error was:

WARNING: Device /dev/loop0 not initialized in udev database even after waiting 10000000 microseconds.

(And the same warning appeared for /dev/sda and /dev/sda1. This repeated every 10 seconds, resulting in an endless loop, hence the error, not warnings :) )The solution is described here: https://bbs.archlinux.org/viewtopic.php?pid=1820949#p1820949Basically, when in installation media's console (not chrooted already, use these commands):

mkdir /mnt/hostlvm mount --bind /run/lvm /mnt/hostlvm arch-chroot /mnt ln -s /hostlvm /run/lvm

However, I still encountered problems with "automatic" boot, I had to boot manually after reboot, here are the commands (based on this article: https://www.linux.com/learn/how-rescue-non-booting-grub-2-linux%20%20).

grub> set root=(hd0,1)grub> linux /boot/vmlinuz-linux root=/dev/sda1grub> initrd /boot/initramfs-linux.imggrub> boot

After that Arch booted properly. Many thanks for this tutorial it helped me a lot, arch wiki installation guide (https://wiki.archlinux.org/index.php/installation_guide) is not virtual-machine oriented. Even an article about VirtualBox (https://wiki.archlinux.org/index.php/VirtualBox#Installation_steps_for_Arch_Linux_guests) was not as helpful as this tutorial, because it focuses on installation in EFI-mode, not the minimalist version with simple dos label type.

Once again, thank you for this tutorial. If I may suggest something, you can add optional information at the begging about how to increase windows size and terminal font size for HD displays: * Higher window resolution (window gets bigger): https://unix.stackexchange.com/a/320419/258734 (for me, adding video=1200x800 was sufficient, it didn't work when I also appended nomodeset) * Larger terminal font size: https://unix.stackexchange.com/a/320396/258734

By: jeb

Good tutorial.  Thank you for a lot of hard work. 

 

By: Brandon

Superb! Thank you!

By: Rivu Bardhan

It says "failed to update community(invalid url)"

"failed to sychronize full database"

"failed to install new packages to the new root"

By: shyam

superb tutorial !

By: nate

that pacstrap doesnt install the kernel. so if you actually want to install linux youre probably going to want to go head an add that...

pacstrap /mnt base  base-devel linux linux-firmware

 

By: Tom

Thanks for adding this!  The article should be edited to prevent driving newbies nuts.   Also, for some reason, my chrooted environment was missing both vi and nano so I have to run pacman -Sy vi.  I used the 2020.02.01 iso.

By: Mike

I installed this arch 4 times and it isn't working. It always boots into GRUB. I've done everything correctly, every command was listed as "successful" or "done" so it may be a problem with this particular version of Arch --- I don't know -- but something isn't right. It always boots into GRUB!!!!!!! What the hell!!!!

By: pink boi

use this:

pacstrap /mnt base linux linux-firmware

instead of this:

pacstrap /mnt base base-devel

By: andreapas79

Same problem, i cannot understannd...i trying on a virtual box, but at the end only grub

By: clay

Typo: fsdisk -l should be fdisk -l.

By: chungli

you are right.

By: Oddipus

When I boot to the OS it boots me to the GNU GRUB command line

By: Archisio

Go back to this step and run as below, it will work!

pacstrap /mnt base linux linux-firmware

By: Archisio

Thanks very simple steps.

Just to mention there is one typo fsdisk -l which should be fdisk -l on the code snippet screenshot.

By: Archisio

I faced an issue after complete all the steps grub bootloader wasn't working properly as some files were missing such as:

1. vmlinuz-linux

2. initramfs-linux-fallback.img

and the solution was to add linux package alongside others in pacstrap as below:

pacstrap /mnt base base-devel linux

Hopefully will help anyone facing the issue i faced as newbie!

By: Widda

To avoid booting into grub prompt.....

It's very important to update this guide to Bootstrab with this [pacstrap /mnt base base-devel linux linux-firmware] , rather than [pacstrap /mnt base base-devel]. Otherwise you will stuck in the "grub" prompt.

By: faszikam

April 10, 2020 Thanks for the tutorial. Just installed for the second time. Both times, the systemctl enable dhcpcd command failed with "dhcpcd.service does not exist", and I also had to install nano separately.

After the first installation, on reboot, I came to the grub prompt, and got stuck there. Followed Widda's advice and revised the pacstrap step to read: pacstrap /mnt base base-devel linux linux-firmware and booted into the OS as hoped/expected.

The second installation went better, and I booted into the OS command prompt, but I had no network connectivity. The network adapter enp0s3 is present but DOWN. I suspect a network package has to be installed before reboot. Any ideas?

By: faszikam

April 11, 2020 I have solved my networking issue: My pacstrap input looks like this:

pacstrap /mnt base base-devel linux linux-firmware nano netctl dhcpcd dhclient

A question. Is there a reason not to format the swap partition with Id 82 Linux swap/Solaris?

WARNING: Do not attempt to open the /etc/localtime file with cat. I did and ended up with only gibberish characters in my command line. I'm guessing it is a binary file... I had to delete the VM and start the installation process over.

Install #5 here we go. I'm learning a lot.

By: elli

ping is not an acronym for packet internet groper (you said gopher btw which is a dead protocol and also a rodent), muuss intended it to be like pulse in sonar

By: same here

is it solved for you now?

By: RD

If you execute 

pacstrap /mnt base base-devel linux linux-firmware nano dhcpcd

instead of pacstrap /mnt base base-devel

you will have a working system when complete.

If you follow these steps to the end and then discover you should have run the above bold command, you can use the same image and go back to the swapon command and complete each step from there. Some of the steps will prove to be complete because the files are not overwritten when you execute pacstrap again.

That said, yes, these steps will get you to a working base level ArchLinux system. Make a copy so you don't have to do this again and you can then create as many VirtualBox systems as you wish. Happy Arching!

By: sean

You should edit this guide to alter the command for the pacman bootstrap. The command should be pacstrap /mnt base base-devel linux. Otherwise when running the grub-mkconfig command towards the end of this tutorial, grub won't find the kernel and when you boot into the OS you will boot into the Grub CMD.

By: Akonaho

hi,

I go through all these steps one by one (And i have done it twice now), but both times i get:

"Generating grub configuration file...

done"

after typing in the command : 

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

and not the warning as illustrated above. then when i reboot, it takes me to a grub command line instead of the arch linux login terminal. How do I resolve this if this is a problem at all?

By: cfk

tried this tutor 3 times. all the time boot is broken, and grub console apears!!!

By: Nick

I installed arch linux alongside windows 10 and fedora, but now grub is only showing arch linux

Any solution?

By: kevadesu

aaaaaaaand what if...arch didn't find nano?

By: Eugene

This tutorial is absolutely terrible, lots of correcting you have to do on your own, and in the end the system booting into grub is just a joke

By: Vince

I used this tutorial, but some of the steps were in the wrong order and a few important steps were missing. It took a few web searches to get from where this tutorial left me to a working Arch Linux system.

I don't see a date on anything here so, of course, some of this may just be outdated.

By: quark

You have some weird characters inside these text lines:

pacman –S grub os-probergrub-mkconfig –o /boot/grub/grub.cfg

They can't be seen normally, but they get transfered on copy-paste into the terminal.

People doing this should manually write these commands, not use copy-paste.

By: martin

For those stucked at GRUB prompt, I think this can help. Found how to boot from Grub in this page: https://www.linux.com/training-tutorials/how-rescue-non-booting-grub-2-linux/

 

Basically, you have to configure Grub properly. For example:

grub> set root=(hd0,1) grub> linux /boot/vmlinuz-3.13.0-29-generic root=/dev/sda1 grub> initrd /boot/initrd.img-3.13.0-29-generic grub> boot

Names of 'vmlinuz' and 'initrd' were different for me, but using Tab for autocomplete should help.

 

By: Lamdaus

How do I use the archinstall to install on VirtualBox?