Skip to content
John Hoffer edited this page Mar 23, 2017 · 83 revisions

The Ubuntu Server VM

guest additions

download .iso + mount on host as cd

$ sudo apt-get install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r)
$ mount /dev/cdrom /media/cdrom
$ sudo sh ./VBoxLinuxAdditions.run
$ # verify installation
$ lsmod | grep vboxguest

mount shared folder

$ cd
$ mkdir bfly_data
$ sudo mount -t vboxsf bfly_data /home/butterfly/bfly_data

set up butterfly

$ sudo apt-get install virtualenv
$ sudo apt-get install python-pip

$ cd
$ mkdir repo
$ cd repo
$ git clone https://github.com/Rhoana/butterfly.git

$ cd
$ mkdir env
$ cd env
$ virtualenv butterfly
$ source ~/env/butterfly/bin/activate

$ cd
$ cd repo/butterfly
$ git checkout update_v2
$ pip install -U pip
$ pip install -r requirements.txt
$ pip install -e .

Make the VM from the command line

  • Install a packaged virtualbox on your Linux, MacOS, or Windows server.
  • This will give you the VBoxManage command, which you will use to set up the bfly VM.
  • Consult the VBoxManage Manual for anything not given here.

Declare some parameters

bflyvm=bfly;
vdifile=$bflyvm/$bflyvm.vdi;
isofile=ubuntu-16.04.2-server-amd64.iso;
ostype=Ubuntu_64;
ncores=1;

Even if your host server has a 64-bit processor, there are many reasons why you may not be able to host a 64-bit vm without further configuration. If your BIOS or motherboard simply won't support it, set ostype=Ubuntu; and isofile=ubuntu-16.04.2-server-i386.iso. You may also not set a higher ncores if v-tx is not available.

Make the virtual machine

VBoxManage createvm --name $bflyvm --register;
VBoxManage modifyvm $bflyvm --acpi on --boot1 dvd;
VBoxManage modifyvm $bflyvm --memory 1024 --cpus $ncores;
VBoxManage modifyvm $bflyvm --ostype $ostype;

If you don't need ssh, continue to set up the virtual machine.

With SSH: you need a host-only network

Create a host-only network if none in VBoxManage list hostonlyifs

if [[ -z $(VBoxManage list hostonlyifs) ]]; then\
    VBoxManage hostonlyif create;\
fi;

Get the host-only network and its ip.

vboxnet=$(VBoxManage list hostonlyifs | egrep -o 'vboxnet.' | tail -1);
vboxip=$(VBoxManage list hostonlyifs | egrep -o '192\.168\.[^.]*' | tail -1);

Continue by enabling DHCP for your host-only network:

VBoxManage dhcpserver add --enable --ifname $vboxnet --ip $vboxip.99 --netmask 255.255.255.0 --lowerip $vboxip.101 --upperip $vboxip.254;
  • Set up host-only adapter
VBoxManage modifyvm $bflyvm --nic1 nat --nic2 hostonly;
VBoxManage modifyvm $bflyvm --hostonlyadapter1 $vboxnet;

Set up the virtual machine

  • cd to the VirtualBox VMs directory and get the iso file
cd $HOME/VirtualBox\ VMs;
wget http://mirrors.lug.mtu.edu/ubuntu-releases/16.04.2/$isofile;
  • Set up the hard drive and disk drive
VBoxManage createhd --filename $vdifile --size 10000;
VBoxManage storagectl $bflyvm --name "IDE Controller" --add ide;
VBoxManage storageattach $bflyvm --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium $vdifile;
VBoxManage storageattach $bflyvm --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium $isofile;

If you don't need a remote server, instead run the installation locally.

With a remote desktop server

Install the RDP extension pack:

extpack=Oracle_VM_VirtualBox_Extension_Pack-5.1.18-114002.vbox-extpack;
wget http://download.virtualbox.org/virtualbox/5.1.18/$extpack;
sudo VBoxManage extpack install $extpack;

Start the Remote Desktop Protocol Server

port=2001
VBoxManage modifyvm $bflyvm --vrdeauthtype external;
VBoxManage modifyvm $bflyvm --vrdeport $port;
VBoxHeadless --startvm $bflyvm --vrde on;

You must see VRDE server is listening on port {port}, where {port} is $port.
After you see the above on the server, switch to a client with a Graphical User Interface.
Download and install a packaged xfreerdp on your Linux, MacOS, or Windows Client. This will give you the xfreerdp command, which you'll use once to install Ubuntu.

port=2001;
uremote=John;
premote=JohnPassword;
hremote=server.example.com;

xfreerdp /v:$host:$port /u:$uremote /p:$JohnPassword;

Run the installation locally

VBoxManage startvm $bflyvm;

Install the Ubuntu 16.04 iso

  • Select Language
  • Install Ubuntu Server
  • Language, Location, keyboard, waiting
  • if ssh: Choose enp0s3 network interface for installation
  • Hostname: butterfly
  • Username: butterfly
  • Password: butterfly
  • Encrypt: No
  • Timezone: Eastern
  • Partition Disks
    • Guided - use entire disk
    • SCSI1 (0,0,0) (sda)
    • yes, write changes
  • HTTP Proxy Information
    • Leave blank, continue
  • No automatic updates
  • Software Selection
    • if ssh: OpenSSH Server
  • Grub Boot Loader: yes

Final installation steps

  • Eject the iso disk image
VBoxManage modifyvm $bflyvm --dvd none;
  • Shut down the bfly VM
VBoxManage controlvm $bflyvm poweroff;
  • Reset the bfly VM
VBoxManage controlvm $bflyvm reset;

If you need to start over, delete the vm VBoxManage unregistervm $bflyvm --delete

Version 2

Version 1

Clone this wiki locally