Skip to main content

Installing Arch Linux on a VitualBox VM (Spoon-fed version)

I have Windows 7 64-bit on my Laptop (it has 4GB RAM) and here is how I went about Installing Arch Linux on a virtual machine created using VirtualBox

Prepare the virtual machine:

  1. Make sure your computer has an active internet connection
  2. Download and install "VirtualBox for Windows hosts" from here.
  3. Download and install "VirtualBox Oracle VM VirtualBox Extension Pack". Just double click on  .vbox-extpack file to install it.
  4. Download the Arch Linux iso image file. The name of the latest image at the time of writing this was: archlinux-2012.11.01-dual.iso
  5. Click on "New" to create a new virtual machine for Arch Linux. Name it the same as the iso file (archlinux-2012.11.01-dual in my case) and the "Operating System" and "Version" types will automatically be selected. Set the RAM to 1024 MB, Hard Disk to VDI having capacity of 10GB.
  6. Before starting the virtual machine, right click on it and select settings and perform the following configurations:
    • Under "General>Advanced" set the Shared Clipboard to Bidirectional
    • Under "Storage>IDE Controller" point to the Arch Linux iso file for loading into the virtual CD/DVD drive. Put a tick in the Live CD/DVD checkbox.
    • Under "Network" ensure that the Adapter 1 is enabled and attached to NAT. Under the "Advanced" option for the same, change the adapter type to "PCnet-FAST III"
    • Under "Display" tick the "Enable 3D Acceleration" checkbox and increase the video memory to 128 MB.
  7. Double click on the newly created virtual machine to start it.
  8. When the system boots select "Boot Arch Linux" from the menu presented by the live CD

Format and mount the virtual hard disk:

Note that you will need to manually type out the commands, copy and paste won't work between Windows host and the Arch Linux 
  1. When the command prompt is presented, execute the following command:
    # cfdisk /dev/sda
  2. Create one primary partition to use the whole 8GB hard disk.
  3. Mark the partition as Bootable. 
  4. Write the partition table
  5. Exit cfdisk.
  6. When you are back to the command prompt, execute the following command to make the file system for the first and only partition:
    # mkfs.ext4 /dev/sda1
  7. Mount the partition as root:
    # mount /dev/sda1 /mnt
  8. Install the base system (internet connection required, ~152MB will be downloaded):
    # pacstrap /mnt base base-devel
  9. Generate an fstab (fstab stores filesystem information):
    # genfstab -U -p /mnt >> /mnt/etc/fstab
  10. Generate locale:
    # locale-gen
  11. Chroot into the new system (Chroot is the process of changing of the apparent disk root directory to another root directory) :
    # arch-chroot /mnt
  12. Set time zone. Mine is India:
    # ln -s /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
  13. Set hostname of your computer, I set mine to "alvm" :
    # echo alvm > /etc/hostname
  14. Set a password for the root user:
    # passwd root
  15. Add a new user. I added a user named "anurag"
    # useradd -m -g users -s /bin/bash anurag
  16. Set password for this new user:
    # passwd anurag
  17. We need to enable DHCP client services on the virtual network adapter 1 which we had configured for this virtual machine to operate in NAT mode. Execute the following four commands:
    # pacman -S ifplugd
    # cd /etc/network.d
    # ln -s examples/ethernet-dhcp .
    # systemctl enable net-auto-wired.service
    [Deleted above lines on 2014-04-27]

    Execute the command:
    # cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/profile
  18. Next we need to find out the identifier name of our adapter, execute the command:
    # ip link
    you will get the output like:
    [root@tristan]# ip link show
    1: lo:  mtu 16436 qdisc noqueue 
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: enp3s0:  mtu 1500 qdisc pfifo_fast qlen 100
        link/ether 00:80:c8:f8:4a:51 brd ff:ff:ff:ff:ff:ff
    The name of the ethernet adapter is enp3s0.
  19. Execute the command :
    # nano /etc/netctl/profile
  20. Change all instances of eth0 to enp3s0 or whatever your ethernet adapter identifier is.
  21. WriteOut the File (Ctrl + O) and then exit.
  22. Execute the following command to start the network:
    # netctl start profile
  23. Test the network using:
    # ping www.google.com
  24. To permanently set the network to start at every boot up, execute:
    # netctl enable profile
  25. Create an initial ramdisk environment:
    # mkinitcpio -p linux
  26. Install bootloader (the one I used is Syslinux) by executing the following two commands:
    # pacman -S syslinux
    # syslinux-install_update -iam
  27. Configure the bootloader. Edit the configuration file using nano text editor:
    # nano /boot/syslinux/syslinux.cfg
  28. Change the following entry:
    APPEND root=/dev/sda3 ro
    to
    APPEND root=/dev/sda1 ro

    You will have to do this in two places. One for the Arch (LABEL arch) entry and another for the fallback (LABEL archfallback)  entry.
  29. WriteOut the file
  30. Exit nano
  31. Exit chroot:
    # exit
  32. Unmount the partitions:
    # umount /mnt/{boot,home,}
  33. Reboot the virtual machine
    # reboot

Boot system, install VirtualBox guest additions and Desktop Manager (internet connection needed for all the following steps):

  1. When the live CD menu shows up, select "Boot existing OS"
  2. Login as "root"
  3. Install VirtualBox guest additions:
    # pacman -S virtualbox-guest-utils
  4. Configure the guest addition modules to load at startup:
    # nano /etc/modules-load.d/virtualbox.conf
  5. Type the following three lines:
    vboxguest
    vboxsf
    vboxvideo
  6. WriteOut the file
  7. Exit nano
  8. Install D-Bus:
    # pacman -S dbus dbus-core
  9. Install the X Window System packages:
    # pacman -S xorg-server xorg-xinit xorg-server-utils
  10. Install mesa for 3D support:
    # pacman -S mesa
  11. Install touchpad driver (required if you are using laptop):
    # pacman -S xf86-input-synaptics
  12. Install the default environment:
    # pacman -S xorg-twm xorg-xclock xterm
  13. Install TrueType Fonts
    # pacman -S ttf-dejavu
  14. Install the GNOME Desktop Environment (~400 MB Download):
    # pacman -S gnome gnome-extra gnome-control-center
  15. Restart:
    # reboot
  16. Login as a normal user. I logged in with "anurag"
  17. Configure X Server, get a copy of the configuration file and place it in your home directory:
    # cp /etc/skel/.xinitrc ~
  18. We need to configure the GNOME to start automatically when X is started
    # nano ~/.xinitrc
  19. Remove the "#" from the head of the following line, changing
    # exec gnome-session
    to
    exec gnome-session
  20. WriteOut the file (Ctrl + O)
  21. Exit nano
  22. Use the following command whenever you want to start the Graphical Interface:
    # startx
  23. Copy and paste between Windows host and Arch Linux guest will now work.
  24. You can now shutdown the virtual machine.
  25. Detach the Arch Linux live CD from the virtual machine.
  26. If you want to always start the virtual machine in graphical mode, reboot the virtual machine and login as root and issue the following command:
    # systemctl enable gdm
The condensed instructions above were prepared using the following references:

Comments

  1. Thanks for posting; good info here!

    ReplyDelete
  2. In case the dhcp doesnt get enabled, execute the following to enable it at bootup:
    "systemctl enable dhcpcd@enp0s3"

    replace enp0s3 with whatever is ur adapter name.. get the adapter name by executing "ip addr"

    ReplyDelete

Post a Comment