I’ve been playing with Alpine Linux on VirtualBox, and here are some notes I took during the process.
Let’s get started:
- Create a NAT Network in the VirtualBox preferences, call it “MyNetwork”.
- More information here.
- Download the latest x86_64 version in ISO format.
- Create a virtual machine in VirtualBox.
- Name it “Alpine Linux”.
- Attach the ISO image to the virtual machine.
- Select “Attached to NAT Network” as adapter, and select the “MyNetwork” option if not selected.
- Choose “Bridged Adapter” if you want to access the VMs from the host and vice-versa.
- Boot and run the
setup-alpinecommand to get started. Reply all questions and wait for system to be installed.
- Choose a proper hostname, so that another machine has a different hostname in the prompt.
- Shutdown with the
poweroffcommand, remove the ISO from the virtual disk drive.
- Start the VM, it should work.
vi /etc/apk/repositoriesand uncomment both lines with
- Install some common stuff:
apk add sudo vim emacs python3 mplayer bash zsh tmux git curl wget bat fortune jq tig mc mandoc man-pages
For Pandoc we need to install Haskell and a few more things first:
# apk add cabal ghc libc-dev zlib-dev # cabal update # cabal install pandoc
You don’t want to be root all the time:
- Follow the steps here to install build tools and add the new user to have
- Add the line
username ALL=(ALL) ALLbelow the similar one for
apk add alpine-sdk
- Exit root and login as new username:
sudo apk add htopshould work
My favourite shell is zsh:
apk add shadow(there’s no
chsh -s $(which zsh)
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"to install Oh-My-Zsh
Connect to Another VM
Let’s repeat the process, so that we can
ssh from one VM to another:
- Create a second VM with the same procedure as above, and create the same username.
ifconfigin both to find the IP addresses.
ssh XX.XX.XX.XX(that is, connect from one to the other.)
tmuxin one VM and
tmux attin the other.
- Type and see how things happen in both at the same time.
Xfce is a nice and snappy desktop environment. The install instructions are very straightforward:
# setup-xorg-base # apk add xfce4 xfce4-terminal lightdm-gtk-greeter xfce4-screensaver dbus-x11 # apk add virtualbox-guest-additions virtualbox-guest-modules-virt # rc-service dbus start # rc-service lightdm start
By default one can’t shutdown or reboot from the Xfce UI, though; easy fix:
apk add polkit consolekit2
Networking from ISO Image
When booting from the ISO image, all changes are lost!
Write this into
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp
Then type the command
/etc/init.d/networking restart and you should be able to
ping google.com once again.
When cloning VMs in VirtualBox, pay attention to the fact that it also clones the MAC address of the interface… hence the clone shares the same IP address as the original VM! Don’t forget about this.
Stuff that doesn’t (can’t) work on Alpine
Some software I tried to install actually requires glibc, but since Alpine uses musl, it can’t run:
- Emacs GUI