Archive for the ‘virtualbox’ Category

Access virtualbox shared folders from Ubuntu and fix ruined ubuntu installation.

Sunday, August 19th, 2012

If you are running Ubuntu virtualbox guest then you cannot access the shared folder under /media/shared with regular user. However you can fix this by adding your user to vboxsf additional group.

Important! make sure you append the additional group so that other groups are not removed! Run te command below as exactly as seen and replace you username. If the permission is not applied immediately then reboot.

usermod -a -G vboxsf username

In case you forgot flag -a then it is bad but not hopeless 🙂 (more…)

Recover virtualbox guest from failing snapshot

Sunday, August 12th, 2012

When making snapshot of running virtualmachine guest the process got stuck and left below traces in logfile. I had to kill hte snapshot process and reboot machine to continue.

vboxmanage snapshot mymachine take initial
00:00:14.576 PCNet#0: The link is back up again after the restore.
00:03:47.980 Changing the VM state from 'RUNNING' to 'RUNNING_LS'.
00:03:48.014 
00:03:48.014 !!R0-Assertion Failed!!
00:03:48.014 Expression: <NULL>
00:03:48.014 Location  : /build/buildd/virtualbox-4.1.12-dfsg/src/VBox/VMM/VMMAll/PGMAllBth.h(1458) void pgmR0BthEPTProtSyncPageWorkerTrackDeref(PVMCPU, PPGMPOOLPAGE, RTHCPHYS, uint16_t, RTGCPHYS)
00:03:48.014 HCPhys=00000000d5a37000 wasn't found!

After  reboot i see:

# vboxmanage list vms
"<inaccessible>" {d1d42d8a-38ed-4d6d-95a1-356d2896ff26}

(more…)

Creating VM-s via CLI using VBoxManage

Sunday, July 29th, 2012

If you happen to setup virtual machines to remote server then you might not have good access to graphical interface to use the VirtualBox graphical interface but you have to be able to manage using CLI. This gives you even more flexibility but needs some time until you can figure out what and how to do.

First create virtualmachine and register it with virtualbox.

VBoxManage createvm --name myvirtmachine --register

Create harddisk for this virtualmachine

VBoxManage createhd --filename myvirtmachinedisk --size 100000

Set some useful params for tis virtual machine

VBoxManage modifyvm myvirtmachine--ostype Ubuntu_64 --memory 2048 --cpuhotplug on --cpus 2 --nic1 bridged --bridgeadapter1 eth0

Create storage controller for virtual machine

VBoxManage storagectl myvirtmachine --name myvirtmachinestoragectl --add sata

Attach installation media into DVD drive to this storage controller. In this case i have downloaded previously the ubuntu isntaller CD

VBoxManage storageattach myvirtmachine --storagectl myvirtmachinestoragectl --port 0 --type dvddrive --medium ../ubuntu-12.04-server-amd64.iso

Attach HDD to this storage controller

VBoxManage storageattach myvirtmachine --storagectl myvirtmachinestoragectl --port 1 --type hdd --medium myvirtmachinedisk.vdi

Now you are ready to start the VM. First command is without vnc access, another has vnc access and you can get the access to console by opening vnc session to host machine.

VBoxHeadless -startvm myvirtmachine --vrde off
VBoxHeadless -startvm myvirtmachine --vnc --vncpass 12345

Running static ip Virtualbox images in ubuntu server in datacentre

Saturday, January 22nd, 2011

Virtual machines have several advantages over physical servers. Especially restoring state and making backups. If you have minimal ubuntu server then first you need to install virtualbox. Best version at the time is virtualbox 4.

Add into /etc/apt/sources.list

line

deb http://download.virtualbox.org/virtualbox/debian maverick contrib

Now you can install virtualbox itself

apt-get install virtualbox-4.0

Easiest way to get VM running in server is to prepare image at home and upload this to server. Make sure you configure ssh and networking correctly (network configuration is explained bit later in here), network interface must be bridged to eth0
Once image is uploaded to server import this with command.

VBoxManage import vmname.ova

Run VM with command which make it run in background and dows not stop if you log out from ssh

nohup VBoxHeadless -startvm vmname &

If there was no problems then you are ready to go, almost.

You want to assign each VM static ip. In hosting providers, like Hetzner, network devices accept traffic only from MAC addresses of physical NIC-s and as VM-s have different MAC-s then by default they cannot communicate with outside world.

To solve this you need to set up routing in host machine, write into host machine

nano /etc/sysctl.conf

statements

net.ipv4.conf.all.rp_filter=1
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
net.ipv4.conf.default.proxy_arp=1

Now reboot host.

Configure guest machine, edit

/etc/network/interfaces

and write there something like

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
 address 188.40.103.103
 gateway 188.40.103.70
 netmask 255.255.255.192

where 188.40.103.103 is extra ip assigned to you and 188.40.103.70 is host machine ip.This tutorial helped to set up the networking http://www.howtoforge.com/how-to-enable-networking-in-xen-guests-on-hetzners-new-eq-servers-debian-lenny