I played with QEMU for few hours and previous VirtualBox experince made me back to it. QEMU’s virtual machine was sloppy.
Find the header package of current kernel version of the system. ‘ uname -a’ will show the version number of kernel image.
In my Devuan, the header pacakge is linux-headers-3.16.0-4-amd64
$ sudo aptitude install linux-headers-3.16.0-4-amd64
Install VirtualBox packages
$ sudo aptitude install virtualbox virtualbox-qt virtualbox-dkms
Check the kernel modules of VirtualBox are loaded.
$ lsmod | grep
vboxpci 23077 0
vboxnetadp 25443 0
vboxnetflt 23324 1
vboxdrv 340067 4 vboxnetadp,vboxnetflt,vboxpci
Add the user to vboxusers group. This is critical part of the VirtualBox operation.
$ sudo adduser user_name vboxusers
There are VirtualBox tutorials in Linux that explain how to creat a virtual machine. So I would not write here.
Start VBoxMange in a console or click VirtualBox on the popup menu of your window manager.
I used devuan-jessie-netboot-amd64-alpha2.iso to create a Devuan virtual machine. At the end of package installation of Select and install software section, I a failure message which was trivial one.
I chose GRUB installation and it was successful.
Assign external IP address to a virtual machine
Default network adapter for the guest (virtual machine) is NAT which separates the guest machine from the host’s private network. The link explains various network setting of the guest machine.(https://www.virtualbox.org/manual/ch06.html#nichardware)
I uses Briged Adapter because it’s easy to set up. Start or activate the Virtual Box Manager, select the guest machine. If the machine is running, power it off.
Select Network menu.
Select Adapter 1.
Change NAT to Briged Adapter in ‘Attached to’. Assign an active network device of the host, i.e. eth0. To find active network devices, run ‘sudo ifconfig’. For example, here is my result.
$ sudo ifconfig
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
Next time you start the guest machine, it will have a private IP address automatically, i.e. 192.168.1.105.
Start a virtual machine in a console
You can skip the two steps of starting a virtual machine. Normally VBoxManage starts the Virtual Box Manager then you select a virtual machine, press Run.
Below command will show all virtual machines. In my case I had one virtual machine.
$ VBoxManage list vms
VBoxMange startvm virtual_machine_name launces the virtual machine.
$ VBoxManage startvm alpha1
Waiting for VM “alpha1” to power on…
VM “alpha1” has been successfully started.
I made start-vm1.sh in ~/bin directory.
VBoxManage startvm alpha1