Install Arch Linux as VirtualBox Guest OS

When I was an intern at Sandia National Laboratories I was introduced to the concept of using virtual machines to sandbox my projects. I have found this to be very helpful for many software experiments and development environments. I even use virtual machines to run my day-to-day Linux install. Here I give my notes on how to use Virtual Box to run an Arch Linux guest install on Mac OS X. Once a base install is complete it’s easy to make snapshots and spin up and destroy clones from the base install as needed.

Create New Virtual Machine

  • Download Arch Linux ISO Live CD

  • Create VirtualBox Disk Image (VDI) with desired settings.

  • Load the Arch Linux ISO as a CD/DVD image and select the “Boot Arch” option when the live CD boots.

Partition the drive(s)

# gdisk /dev/sda

Name Cmd # Start Stop Code Type
Boot n 1 0 +250M 8300 (Linux Filesystem)
Swap n 2 0 +2G 8200 (Linux Swap)
Root n 3 0 -0M 8300 (Linux Filesystem)
  • Use the n command and values (above) to create partitions using gdisk.
  • Print the the gdisk partition table with the p command.
  • Write the gdisk partition table with the w command.

Install and Configure System

# Format Partitions
mkfs.ext4 /dev/sda1
mkswap /dev/sda2
mkfs.ext4 /dev/sda3


# Mount Partitions
mount /dev/sda3 /mnt

mkdir /mnt/boot
mount /dev/sda1 /mnt/boot

swapon /dev/sda2


# Configure Mirrors


# Install Base System
pacstrap /mnt base base-devel linux


# Generate File System Table
genfstab -p /mnt >> /mnt/etc/fstab


# Set hostname
echo 'myarch' > /etc/hostname


# Change Root Directory
arch-chroot /mnt


# Configure language
echo LANG="en_US.UTF-8" >> /etc/locale.conf
echo LC_COLLATE="C" >> /etc/locale.conf
echo LC_TIME="en_US.UTF-8" >> /etc/locale.conf
echo "en_US.UTF-8 UTF-8" >>/etc/locale.gen

locale-gen

ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
hwclock --systohc --utc


# Generate Ram Disk
mkinitcpio -p linux


# Install and Configure Bootloader
pacman -S syslinux gdisk
syslinux-install_update -iam


# Exit CHROOT, Unmount Drives and Reboot
exit
umount -R /mnt
reboot

Post Install

The following isn’t really intended to be executed as a script.

# Setup Network
systemctl start dhcpcd
systemctl enable dhcpcd

# Virtual Box Guest Utilities
# https://wiki.archlinux.org/index.php/VirtualBox#Arch_Linux_as_a_guest_in_a_Virtual_Machine
pacman -S virtualbox-guest-utils --noconfirm

modprobe -a vboxguest vboxsf vboxvideo

echo vboxguest >> /etc/modules-load.d/virtualbox.conf
echo vboxsf >> /etc/modules-load.d/virtualbox.conf
echo vboxvideo >> /etc/modules-load.d/virtualbox.conf

groupadd vboxsf

systemctl enable vboxservice
systemctl start vboxservice

# X Windows System
pacman -S xorg-server xorg-server-utils xorg-xinit xterm ttf-dejavu --noconfirm

pacman -S awesome

# User Configuration
pacman -S sudo --noconfirm

# use visudo to add  under "User privilege specification" before
# using sudo as 

# Replace user_name with desired user name.
useradd -m -g users -G optical,power,storage,vboxsf -s /bin/bash user_name

chown root.vboxsf /media

# Set  password using "# passwd "
# Set root password using "# passwd"


# Update Packages and System
pacman -Syy
pacman -Syu

Per User Config

Configuration for users other than root.

echo /usr/bin/VBoxClient-all >> ~/.xinitrc
echo "exec awesome" >> ~/.xinitrc

ln -s /media/sf_share_name/* ~/share_name
Advertisements

2 Comments on “Install Arch Linux as VirtualBox Guest OS”

  1. Reblogged this on mylinuxhome and commented:
    Install Arch Linux in virtual Box!!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s