My current use for this VM is to run ansible. I use SSH to access the VM (both for running commands and transferring files), so don't bother running a GUI on it, or shared folders.

This document was tested with VirtualBox v5.0.20 r106931, running under Windows 7, and installing AlpineLinux v3.3.3 x64. It is assumed that VirtualBox is already installed.

Obtain installer ISO

Go to the downloads section of https://alpinelinux.org/ and download the 64-bit "Standard ISO" - I got alpine-3.3.3-x86_64.iso - save it somewhere you can find it again.

Setup VM

The blank machine should now be created, and will be listed in the VirtualBox window, on the left. Right-click on the machine and choose "Settings". Configure as follows:

Basic Alpine Linux Install

Run "setup-alpine", and configure as follows:

Wait for it to install...

Now run "poweroff" to shutdown the VM - this is necessary in order to reboot into the installed system, so we can install things there.

Remove CD

In the main VirtualBox window, right-click on the machine and choose "Settings". Reconfigure as follows:

Update Packages

Start the VM. When it has finished booting, the login prompt should show the hostname you selected (instead of "localhost"). Login as "root", using the password you setup.

Use vi to edit the repositories - uncomment all the URL lines to enable them all.

vi /etc/apk/repositories

It should look something like this (but probably different URLs, depending on which ones were detected as being fastest for you):

#/media/cdrom/apks
http://dl-6.alpinelinux.org/alpine/v3.3/main
http://dl-6.alpinelinux.org/alpine/v3.3/community
http://dl-6.alpinelinux.org/alpine/edge/main
http://dl-6.alpinelinux.org/alpine/edge/community
http://dl-6.alpinelinux.org/alpine/edge/testing

Update the package list and upgrade what has already been installed:

apk update
apk upgrade

The base install at this stage will have used about 25MB of the boot partition (nominally about 100MB, but 92.8MB reported), 512MB as swap, and 270MB of the root partition - if the base disk was 2GB, about 1GB is free on the root drive.

Setup User and Sudo

Create the sudo group, create a non-root user (use whatever username you like, instead of "otheruser"), and add the new user to the sudo group:

addgroup sudo
adduser otheruser
adduser otheruser sudo

Install sudo

apk add sudo

Run "visudo" and remove the "#" comment character from the 2nd line in this group so it looks like:

## Uncomment to allow members of group sudo to execute any command
%sudo ALL=(ALL) ALL

Setup VirtualBox Drivers

The VirtualBox drivers improve performance of a VM running under VirtualBox.

apk add virtualbox-guest-modules-grsec virtualbox-additions-grsec

Reboot the VM by typing "reboot".

Test

You should now be able to login as the non-root user you created (using the non-root password you provided).

Once logged in, you should be able to execute commands as root by using sudo (and the non-root user password), eg. "sudo apk update" - if sudo is not working correctly, it will give an error, eg. if you weren't using sudo at all:

testvm:~$ apk update
ERROR: Unable to lock database: Permission denied
ERROR: Failed to open apk database: Permission denied

If sudo is working correctly, the command will execute, eg.:

testvm:~$ sudo apk update
fetch http://dl-6.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch http://dl-6.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
fetch http://dl-6.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch http://dl-6.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch http://dl-6.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
v3.3.3-46-ge9c0256 [http://dl-6.alpinelinux.org/alpine/v3.3/main]
v3.3.3-47-g150c9b2 [http://dl-6.alpinelinux.org/alpine/v3.3/community]
v160223-1826-g4681e7d [http://dl-6.alpinelinux.org/alpine/edge/main]
v160223-1826-g4681e7d [http://dl-6.alpinelinux.org/alpine/edge/community]
v160223-1826-g4681e7d [http://dl-6.alpinelinux.org/alpine/edge/testing]
OK: 15131 distinct packages available

SSH

It should also be possible to SSH from the host machine to the VM at address "localhost" (or "127.0.0.1"), and port "22022"

References