Skip to content

Instantly share code, notes, and snippets.

@dannycastonguay
Last active November 7, 2022 17:00
Show Gist options
  • Save dannycastonguay/46e8cca629d67105a2db to your computer and use it in GitHub Desktop.
Save dannycastonguay/46e8cca629d67105a2db to your computer and use it in GitHub Desktop.
Installing Arch Linux on VirtualBox in Windows 10 for beginners

Installing Arch Linux on VirtualBox in Windows 10

I recently upgraded to a new system, and instead of running Arch Linux natively I've decided to run it inside VirtualBox on Windows 10. Below I note down the steps I took, which closely follow the excellent wiki pages of archlinux. But along the way, I also noted a few other steps steps I took to make this system very comfortable, which you'll have to figure out for yourself if you like them or not!

Setting up Windows 10 to be ready

There isn't much of preparation required, given that I started from scratch, but I did have to setup my windows environment a little bit.

  1. Install the windows package manager chocolatey
  2. Install qBittorrent (which will be used to download an iso copy of arch) by running the following command from the command line choco install qbittorrent (recommended to run the command line as an administrator)
  3. Head over to the Arch Linux download section and click the torrent link for the latest version (I'm not pasting the link here, because arch evolves so fast that next time anyone reads this gist it is very likely that it will already be old). This normally should start your qBittorrent. Please consider seeding others once you are done with your download.
  4. Unless you've already installed Virtual Box from the download website, I personally prefer to use Chocolatey because its faster by typing choco install virtualbox followed by installing the [guest additions] (http://download.virtualbox.org/virtualbox/5.0.10/Oracle_VM_VirtualBox_Extension_Pack-5.0.10-104061.vbox-extpack)
  5. While you are at it, why don't you invert your colors in Windows to relax your eyes? Hit the Windows Key + Minus Sign, which will start the handy Magnifier app, followed by Ctrl + Alt + I which will toggle inverting your colors.
  6. And while you are really at it, consider adding Vimium to your Chrome browser.

And that's it. I'm now ready to follow the setups listed on the arch wiki.

Mount Arch Linux on VirtualBox

I couldn't find a section on the Arch wiki where these steps are listed, perhaps they are obvious, but since I think I know what I'm doing I'm just going off script here (what a great start!).

  1. Start VirtualBox and click New
  2. Name your machine, preferably with a descriptive but memorable name (e.g., exultant carpenter), select type Linux, and version Arch Linux (64 bit) (unless you downloaded the 32 bit version. A note on this, I recall in the past that for some machines you may need to go inside your UEFI/BIOS firmware, and enable Intel VT-x to be able to run the 64 bit version, highly recommended!)
  3. Next set your RAM. I have 16GB and I want to make this my main development environment, so I decide to set mine to 8192MB, but Arch Linux requires much less than that.
  4. Create a virtual hard disk now and select VDI and Dynamically allocated on the next screens.
  5. Select a reasonable disk size (e.g., 40GB). Note that all of those settings are not that important at the moment as they can be changed in the future
  6. Once this wizard completes, hit settings and make a few additional changes. Namely: System > Processor > 2 CPU, Display > Screen > Video Memory 128MB & Monitor Count 4 & Enable 3D (or whatever is the number of monitors that you have, hopefully >1 unless you sport a 4K monitor)
  7. And finally go to Storage > Storage Tree > Controller: IDE > Optical Drive + icon > Choose Disk and navigate to where the ISO file you downloaded previously is stored (I personally moved the ISO under C:\Users\USERNAME\VirtualBox VMs\archlinux-2015.11.01-dual.
  8. Click ok and you are now ready to Start the VM
  9. Once started, select `Boot Arch Linux (x86_64)

Install arch on VirtualBox

We now want to install Arch Linux as guest to our Virtual Box, following the steps listed here.

  1. I skip over setting up my keyboard and my internet, because I'm happy with the keyboard default and my internet works (as is verified by typing ping google.com or curl google.com)
  2. Start system clock with timedatectl set-ntp true
  3. This step is informational only: list block devices with lsblk, you will see sda with a size of XXG and type disk listed as well as sr0 where the ISO. Our goal here is to make sda bootable but at this point its just an unmounted, unformatted block, which is pretty useless. So let's setup a partition in sda using parted
  4. Type parted /dev/sda, and once inside parted type mklabel msdos to setup a new MBR/msdos partition (why not mklabel gpt? this is because VirtualBox offers an BIOS system)
  5. Next I follow the BIOS/MBR example. I run mkpart primary ext4 0% 100%, set 1 boot on, and quit
  6. Format the partition in ext4 with mkfs.ext4 /dev/sda1 and mount it with mount /dev/sda1 /mnt
  7. I skip over changing the mirrors
  8. Install the base packages with pacstrap -i /mnt base base-devel (if this is your first time using pacman, rejoice because it will be the main reason you will love Arch Linux! You will be prompted with a few confirmation screens, just keeping hitting enter until you downloads start (this may take a few minutes, depending on the speed of your internet connection). A quick note on the questions in Linux that end with [Y/n], these are usually pretty safe questions, so you don't actually need to type Y and can just hit enter. More discussion about this here for example.
  9. Generate an fstab file using genfstab -U /mnt > /mnt/etc/fstab and change root using arch-chroot /mnt /bin/bash
  10. To help your locale-aware programs and libraries render text, regional monetary values, time and date formats correctly, set your Locale I type the following (assuming US): vi /etc/locale.gen, which will open the vi editor, /en_US.UTF-8, followed by the character x to delete the leading #, which uncomments the appropriate line, and finally :wq which saves and quits the file
  11. Use tzselect to find your time zone, and type ln -s /usr/share/zoneinfo/Zone/SubZone /etc/localtime where Zone/SubZone is your selection. Since windows 10 is also installed on the machine, important to set hwclock --systohc --utc
  12. Do not install microcode updates, as this is a virtual machine
  13. Install grub package with pacman -S grub os-prober
  14. Next pick a hostname to refer to your machine on the network, I pick exultantcarpenter, and put this is a file as such echo exultantcarpenter > /etc/hostname. Also add this hostname to /etc/hosts by adding it as an option beside localhost (the line should look like 127.0.0.1 localhost.localdomain localhost exultantcarpenter, all separated by tabs.
  15. Ensure that you machine will be able to connect to the internet when boot in the future, by running the following two commands. 1) ls /sys/class/net which will output two words to the screen, for instance enp0s8 lo. and 2) systemctl enable [email protected], where you replace enp0s8 with what your first command outputed.
  16. Almost there! Next we set a password, unmount and reboot! Set a password with passwd, exit chroot with exit, unmount with umount -R /mnt, and reboot with shutdown. Once the machine is off the virtual machine, return to VirtualBox, select the machine, and remove the drive (Settings > Storage > Storage Tree, select the ISO and click on the minus sign to remove)
  17. Hit start again and you are done!

Install Guest Additions

here.

What next?

At this point, you can take a break and come back later to continue the setup of all your favorite goodies for your brand new Arch Linux (xmonad, haskell, R, apache Spark, clojure).

@Foxh0und
Copy link

FYI, Virtualbox has upgraded, and thus, had to download the latest extensions from here.

@byque
Copy link

byque commented Dec 27, 2017

I think you are missing the part about grub configuration after step 13:
]# grub-install /dev/sda
]# grub-mkconfig –o /boot/grub/grub.cfg

@pmavila
Copy link

pmavila commented Aug 8, 2018

@byque that's right. Now you won't be able to boot without the grub configuration.

So for everyone who skipped, you can follow @byque 's commands above, however you'll need to run and re-mount the iso copy of arch.

Then:
# mount /dev/sda1 /mnt
# arch-chroot /mnt /bin/bash

Then you can proceed with:
# grub-install /dev/sda
# grub-mkconfig –o /boot/grub/grub.cfg

@thecaralice
Copy link

thecaralice commented Apr 11, 2020

I followed the steps (I had to also do pacman -S vim dhcpcd), then the grub commands in comments but now it gives me
this

EDIT: Figured out on 8th step you should do pacstrap -i /mnt base base-devel linux linux-firmware

@love2d-lua
Copy link

as iamalicecarroll pointed out
pacstrap -i /mnt base base-devel linux linux-firmware
instead of above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment