Anda di halaman 1dari 7

Setting up an Arch Linux VM in VirtualBox

About Arch Linux


There are many Linux distributions out there. Arch Linux is our choice. Start by reading a little bit about
it:
1. Create a new VM in VirtualBox
Select Arch Linux (32 bit)
RAM: 1 GB minimum, 2 GB recommend (or even more, if your host machine has 8 GB)
Hard disk: 20 GB minimum, 50 GB or more recommended. Choose Dynamically allocated so
that the virtual disk takes up only as much space as it is currently using. Choose VDI (VirtualBox
Disk Image).
Boot the VM using the live CD image you downloaded.

Install Arch Linux


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 Beginners Guide carefully step-by-step. You can start at
Section 4, Change the language.
The Arch Linux Beginners Guide well call it the Guide from now on is very detailed and
comprehensive, but sometimes its 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 Beginners Guide that you are supposed to follow.
Establish an internet connection
Assuming you have an Internet connection on your host, your guest should have it as well. If ping
works, skip the rest of this section and move on to the next one.
Prepare the storage devices
This section is a bit long and unwieldy. Skim through the section to get an idea of what its talking
about. Basically, you should come to an understanding of what a disk partition is.
Here is what youll 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 printcommand
to see if all is well before we quit out of parted.
If you paid attention to the printoutput, you will see that your partition doesnt actually start at the
beginning of the disk, even if we told it so. Parted skipped 1049kB at the start of the disk. Dont
worry. Thats 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, dont forget to mount the new partition at /mntto begin filling it up with an Arch Linux
installation:
mount /dev/sda1 /mnt
Install the base system
Follow the Guides instruction.
Chroot and configure the base system
You should carefully follow all of the steps in this section to configure your new system. Here are
some additional tips:
Add FONT=Lat2-Terminus16to /etc/vconsole.conf, which will make the console look
much nicer.
For configuring the network, we follow Wired / Dynamic IP setup, which means that all you need

to do is to run systemctl enable dhcpcd.service. Note that the Guide adds


@interface_name after dhcpcd. You dont need to do that.
For the subsection, Install and configure a bootloader, follow the Guide for the For BIOS
motherboards / GRUB setup.
Unmount the partitions and reboot
Dont forget to eject the virtual CD-ROM (which was mapped to the archlinux-YYYY.MM.DD-dual.iso
file), so that you will reboot into the newly installed Arch Linux, not the install CD again.

Required reading
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:
Section 1: System administration
Section 2: Package management
Section 3: Graphical user interface
After you have read the sections, move on to the post-installation setup.

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 sudocommand.
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 vesadriver by running
pacman -S xf86-video-vesa. This will let you test X window system when you dont 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-server xorg-server-utils 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

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

Install VirtualBox Guest Additions


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.
1. Install packages:
sudo pacman -S virtualbox-guest-utils
sudo pacman -S virtualbox-guest-modules
sudo pacman -S virtualbox-guest-modules-lts
sudo pacman -S virtualbox-guest-dkms
2. Create /etc/modules-load.d/virtualbox.confwhich contains the following three lines:
vboxguest
vboxsf
vboxvideo
3. In order to synchronize time with the host machine, type the following:
sudo systemctl enable vboxservice.service
4. Enable Bidirectional Shared Clipboard from VirtualBox Managers Settings / General / Advanced
menu.
5. Reboot the VM and type ps ax | grep -i vbox. You should see an output like this:
139 ?

Ssl

0:00 /usr/bin/VBoxService -f

402 ?

Sl

0:00 /usr/bin/VBoxClient --clipboard

414 ?

Sl

0:00 /usr/bin/VBoxClient --display

420 ?

Sl

0:00 /usr/bin/VBoxClient --seamless

425 ?

Sl

0:00 /usr/bin/VBoxClient --draganddrop

Try copy & paste between host and guest.


You can look through Archs documentation on VirtualBox for more detailed info.

Switch to Linux LTS kernel


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 linuxpackage in Arch is the stock kernel and the linux-ltspackage is
the LTS kernel. We are going to use the LTS kernel.
1. Install the LTS kernel packages.
sudo pacman -S linux-lts linux-lts-headers
2. Before we update the boot menu to include the new kernel, lets tweak the settings of GRUB (our
bootloader) by modifying /etc/default/grub.
First, you will find GRUB_DEFAULT=0at 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 youre editing this file, you can make your virtual console the text-based
command line before you start Xfce a little bigger. Change GRUB_GFXMODE=autoto:
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"
3. After you modified /etc/default/grub, regenerate the GRUB configuration by running:
sudo grub-mkconfig -o /boot/grub/grub.cfg

4. 1. Type uname -rto see the current kernel version youre running
2. Reboot into the new LTS kernel
3. Type uname -ragain to see the new LTS kernel version.

Fix broken VirtualBox guest modules for LTS


As of 1/19/2015, the virtualbox-guest-modules-ltspackage which provides the binary files
of VirtualBox guest modules compiled for the current LTS kernel is broken. This is why when you boot
into the LTS kernel, resizing your Linux desktop stops working. (Skip this section if this is not the case
the bug might have been fixed by the time youre reading this.)
Follow the steps below to fix it for now.
sudo pacman -R virtualbox-guest-modules-lts
sudo pacman -S virtualbox-guest-dkms
Observe the output on screen. Towards the end, it says To build and install your modules run:. Run
that command. Its most likely this:
sudo dkms install vboxguest/4.3.20

Some recommended UI improvements


Better terminal font
Install the Terminus font, which makes a very nice terminal font:
pacman -S terminus-font
Terminus is my favorite font for terminals because I hate anti-aliased fonts (i.e. fonts with shadows)
on my terminal windows. If you dont mind it, the Inconsolata fonts we installed previously is pretty
awesome too.
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.)

Anda mungkin juga menyukai