There are many Linux distributions out there. Arch Linux is our choice. Start by reading a little bit about it:
Download and install VirtualBox
Download archlinux-2018.01.01-x86_64.iso
from Arch Linux Downloads
page
Create a new VM in VirtualBox
Arch Linux (64-bit)
Once the VM boots successfully into the Arch Live CD image, you are ready to install Arch onto your virtual hard disk. Follow the Arch Linux Installation guide carefully step-by-step.
The Arch Linux Installation guide – we’ll call it the Guide from now on – is detailed and comprehensive, but sometimes it’s a bit confusing. I have listed below some additional info and directions on some of the trickier sections of the Guide.
Note that what follows is NOT the whole instruction. They are clarifications and additional help on the Arch Linux Installation guide that you are supposed to follow.
Set the keyboard layout
Leave the default console keymap as US. Nothing to do here.
Verify the boot mode
Nothing to do here. In case you’re curious, we are booting in BIOS mode.
Connect to the Internet
Verify that the VM is connected to the Internet using the ping command.
Update the system clock
Follow the Guide’s instruction.
Partition the disks / Format the partitions / Mount the file systems
These sections point you to two other long documents, Partitioning and File systems, but don’t really tell you what to do. Skim through the documents to get an idea of what it’s talking about. Basically, you should come to an understanding of what a disk partition is.
Here is what you’ll actually do. First, create a single MBR partition
which fills up the entire hard disk. We will use parted
:
parted /dev/sda
Once you are in parted
(you know it because the prompt changes to
(parted)
), run the following commands:
mklabel msdos
mkpart primary ext4 0% 100%
set 1 boot on
print
quit
First we select “msdos” partition type, which is another name for the
MBR partition type. Then we create a “primary” partition which will
fill up 100% of the disk, and indicate that we will later format it as
an “ext4” file system type. We then make the partition bootable.
Finally run the print
command to see if all is well before we quit out
of parted.
If you paid attention to the print
output, you will see that your
partition doesn’t actually start at the beginning of the disk, even if
we told it so. Parted skipped 1049kB at the start of the disk. Don’t
worry. That’s the way it should be.
After creating the partition /dev/sda1, run the following command to
format the partition as an ext4
filesystem:
mkfs.ext4 /dev/sda1
Note that we do not create a swap partition because a swap file can be added later if necessary.
Lastly, don’t forget to mount the new partition at /mnt
to begin
filling it up with an Arch Linux installation:
mount /dev/sda1 /mnt
Select the mirrors
You should edit /etc/pacman.d/mirrorlist
to put a geographically close
mirror server at the top of the file. For example, you can put the
server hosted at Columbia University at the top of the list.
Install the base packages
Follow the Guide’s instruction.
Fstab
Follow the Guide’s instruction.
Chroot
Follow the Guide’s instruction.
Time zone
The ln
command in the Guide is missing the -f
flag. Also,
obviously, you should change Region/City with the actual region/city
that you are in. For example:
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
And don’t forget to run:
hwclock --systohc
Locale
Follow the Guide’s instruction to generate the en_US.UTF–8 locale, and set the LANG variable in /etc/locale.conf.
Optionally, put FONT=Lat2-Terminus16
in /etc/vconsole.conf
, which
will make the console look much nicer.
Hostname
Follow the Guide’s instruction.
Network configuration
For configuring the network, all you need to do is to run the following command:
systemctl enable dhcpcd.service
Initramfs
Nothing to do here.
Root password
Follow the Guide’s instruction.
Boot loader
This section points you to a lot of super confusing information. Here is all you need to do:
pacman -S intel-ucode
pacman -S grub
grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
For the curious, we are installing the GRUB bootloader into our system, which uses BIOS/MBR boot method.
Reboot
Follow the Guide’s instruction.
When you type “reboot” at the end, the virtual machine will reboot back into the install CD (which is a virtual CD mapped to the archlinux-YYYY.MM.DD-x86_64.iso file).
At this point, eject the virtual CD by clicking the round disk button on the status bar at the bottom of the VM window, and selecting “Remove disk from virtual drive”. If you get an error when you try to eject the CD, power off the virtual machine by closing the VM window, turn it back on, and try ejecting the CD again.
After you have successfully ejected the CD, power off the VM and turn it on again. You will boot into the newly installed Arch Linux.
At this point, you have a minimally functional Arch Linux system. There are a few more things to do before you can use the system productively.
Before we begin, however, you must understand some basic concepts about Arch Linux. Please read the following short sections in the General Recommendations page:
After you have read the sections, move on to the post-installation setup.
User management
Pick a name for a non-root user and add the user. For example:
useradd -m -g users -s /bin/bash archie
passwd archie
At this point, you can make the non-root user a “sudoer”. A sudoer can
run a command as root by passing it through the sudo
command.
First, install sudo:
pacman -S sudo
Then, add the following lines to /etc/sudoers
(you can omit the
comments of course, and replace archie with your user name):
# The basic structure of a user spec looks like this:
# who where = (as_whom) how: what
archie ALL=(ALL) NOPASSWD: ALL
Package management
This is also a good time to install some essential packages:
pacman -S net-tools pkgfile base-devel
And perhaps your favorite editors:
pacman -S vim emacs
You can also try running a full system upgrade to see if any of your installed packages have new versions:
pacman -Syu
At this point, please take a snapshot of your VM from VirtualBox so that you can come back to this point if something goes wrong in the subsequent steps.
Install a video driver
We will be installing VirtualBox Guest Additions later, but for now,
install the vesa
driver by running pacman -S xf86-video-vesa
. This
will let you test X window system when you don’t have VirtualBox Guest
Additions installed yet.
Choose and install a graphical interface
Linux offers a dizzying array of choices when it comes to graphical desktop environments. You can use whatever you like.
Xfce is what I use. Here is how to install it:
# first, install Xorg
pacman -S xorg xorg-server xorg-apps
# install some good fonts
pacman -S ttf-dejavu ttf-droid ttf-inconsolata
# install Xfce
pacman -S xfce4 xfce4-goodies
You can also install a GUI version of your editor and a web browser:
pacman -S gvim firefox chromium
Before you start your Xfce4 desktop, log in as the non-root user. You
can switch to the 2nd virtual console by pressing Ctrl-Alt-F2
. After
you log in as a non-root user, you can type the following to start your
Xfce4 desktop:
startxfce4
Now you should install VirtualBox Guest Additions inside the VM. The Guest Additions will enable very useful features like dynamically resizing the VM window, copy & paste between guest and host, time sync between guest & host, and accessing the host file system from the guest.
Install packages:
sudo pacman -S linux-headers
sudo pacman -S virtualbox-guest-dkms
sudo pacman -S virtualbox-guest-utils
In order to load the VirtualBox kernel modules and synchronize time with the host machine, type the following:
sudo systemctl enable vboxservice.service
Enable “Bidirectional” Shared Clipboard from VirtualBox Manager’s Settings / General / Advanced menu.
Reboot the VM, start your Xfce4 desktop (or whatever desktop environment
you’re using), launch a terminal window, and type ps ax | grep -i vbox
.
You should see an output like this:
154 ? S< 0:00 [iprt-VBoxWQueue]
197 ? Ssl 0:00 /usr/bin/VBoxService -f
392 ? S 0:00 /usr/bin/VBoxClient --clipboard
393 ? Sl 0:00 /usr/bin/VBoxClient --clipboard
401 ? S 0:00 /usr/bin/VBoxClient --display
402 ? S 0:00 /usr/bin/VBoxClient --display
409 ? S 0:00 /usr/bin/VBoxClient --seamless
410 ? Sl 0:00 /usr/bin/VBoxClient --seamless
415 ? S 0:00 /usr/bin/VBoxClient --draganddrop
416 ? Sl 0:00 /usr/bin/VBoxClient --draganddrop
531 pts/0 S+ 0:00 grep -i vbox
Try copy & paste between host and guest.
You can look through Arch’s documentation on VirtualBox for more detailed info.
The stock kernel of Arch Linux stays pretty close to the bleeding edge, so
it gets updated very frequently. Arch offers a more stable alternative
based on a kernel version designated as a Long-Term Support (LTS) version.
The linux
package in Arch is the stock kernel and the linux-lts
package
is the LTS kernel. We are going to use the LTS kernel.
Install the LTS kernel packages.
sudo pacman -S linux-lts linux-lts-headers
Before we update the boot menu to include the new kernel, let’s tweak
the settings of GRUB (our bootloader) by modifying /etc/default/grub
.
First, you will find GRUB_DEFAULT=0
at the top of the file. Change it
to:
GRUB_DEFAULT=saved
so that GRUB will remember the last kernel you boosted from and make it the default entry next time you boot. Then you also need to add the following lines at the end of the file:
GRUB_SAVEDEFAULT=true
GRUB_DISABLE_SUBMENU=y
Optionally, while you’re editing this file, you can make your virtual
console – the text-based command line before you start Xfce – a little
bigger. Change GRUB_GFXMODE=auto
to:
GRUB_GFXMODE=1024x768x32
And make sure the following line is there and not commented out:
GRUB_GFXPAYLOAD_LINUX=keep
Also uncomment the following lines to have the menu screen in color:
GRUB_COLOR_NORMAL="light-blue/black"
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"
After you modified /etc/default/grub
, regenerate the GRUB
configuration by running:
sudo grub-mkconfig -o /boot/grub/grub.cfg
Verify that the new kernel works correctly:
uname -r
to see the current kernel version you’re runninguname -r
again to see the new LTS kernel version.Enable HiDPI support
If you have a HiDPI (High Dots Per Inch) display like Apple’s Retina Display, by default VirtualBox scales the screen to half of its native resolution. You can enable HiDPI support in VirtualBox Manager’s Settings / Display.
Now everything will look tiny. You need to do some work to make your desktop look good on a HiDPI screen. Here is an ArchWiki page on HiDPI.
Better terminal font
On a non-HiDPI display, I hate looking at anti-aliased fonts (i.e. fonts with shadows) in a terminal window. My favorite non-anti-aliased font is the Terminus font. Try switching your terminal font to it unless you are on a HiDPI display.
pacman -S terminus-font
Customize your environment
The following ArchWiki pages have tons of tips on how to customize your working environment. (But be careful. You can spend infinite amount of time tweaking your working environment instead of, um, actually working.)
Congratulations! You have successfully installed and configured an Arch Linux system. Hopefully this is the beginning of a long-term relationship between Linux and you.
Last updated: 2018–01–15