Showing posts with label VirtualBox. Show all posts
Showing posts with label VirtualBox. Show all posts

Monday, March 27, 2017

VirtualBox: resize disk in linux

Resize to 350GB using VirtualBox 5.18: VBoxManage modifyhd "/home/myhome/VirtualBox VMs/arc/arc.vdi" --resize 350000 Full path to virtual disk (e.g., arc.vdi) is important. Without the full path, the following error occurs: VBoxManage: error: Cannot register the hard disk '/home/myhome/VirtualBox VMs/arc/./arc.vdi' {54199b9e-0a91-4d84-a7d0-fe2b47ed8f47} because a hard disk '/home/myhome/VirtualBox VMs/arc/arc.vdi' with UUID {54199b9e-0a91-4d84-a7d0-fe2b47ed8f47} already exists
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 179 of file

Saturday, December 10, 2016

VirtualBox – Cannot Register the Hard Drive Because a Hard Drive with UUID Already Exists

After moving virtualbox folder to new location, cant boot any vm. To fix this, one can use this for example vboxmanage internalcommands sethduuid /mnt/stuff/linux_backup/VirtualBox\ VMs/w7/w7.vdi

Saturday, March 07, 2015

Fedora 21: VirtualBox additions

su -
dnf update kernel*

dnf install kernel-headers kernel-devel dkms make bzip2 perl and reboot.
Optinally (usually not needed) KERN_DIR=/usr/src/kernels/`uname -r`

Monday, June 21, 2010

"Remote desktop session has ended" error when connecting to a guest on VirtualBox

I had a problem connecting from Windows using build-in Remote Desktop Connection program to a a guest on a headless VirtualBox server. I found that the reason wast that I did not checked "Allow me to save credentials" option in a Remote Desktop Connection.
With this option, the client will ask for username/password before connecting to the VirtualBox. Thus it seems, that VirtualBox requires user credentials at the very beginning of the session. Without this option, connections will fail.

I was using VirtualBox 3.2.4 in a headless mode running on a CentOS 5.5 x86_64.

Friday, May 14, 2010

VirtualBox: start and stop a guest in a headless mode

Lets assume that we have a guest VirtualBox machine called "xp". To start it in a headless mode we can use VBoxHeadless --startvm "xp"To stop it we can use VBoxManage controlvm "xp" savestateSince it is in a headless state we have to access it using a RDP viewer, e.g. rdesktop command in Linux:desktop -u username -p password -a 16 serverIPOf course, before we can use it in this way, we have to enable remote destkop for the "xp" machine and define authentication method. In my case, I used External method, since it uses the linux user account under which my VirtualBox is running.

Wednesday, February 10, 2010

VirtualBox: Autostart guest in Windows XP host

Some time ago I was asked to quickly setup a temporary LAMP server. Since, the time was an issue and it was supposed to be only a short-term solution I decided to take a PC box with Windows XP, install a VirtualBox, and setup an Ubuntu server 8.04 LST as a guest operating system.

Unfortunately, it was over a 1.5 year ago and what was a short-term solution become now de-facto a long term one. However, recently we had some power shortages in our building, and the problem appeared with this PC box, i.e. after it went down due to power shortage it did not start VirtualBox automatically when being turned on. Thus, I was asked to make it start automatically, in such a way that after turning the PC on, everything VirtualBox and ubuntu-server start automatically. I did it in to steps:

1. Setup autologin in Windows XP.

To do this I followed instructions from here.

2. Make VirtualBox start automatically.
To do this I wrote very simple Windows batch script called startVB.bat that contained the following two lines:cd "C:\Program Files\Sun\xVM VirtualBox"
vboxmanage startvm "ubuntu-server"
where "ubuntu-server" is the name of virtual machine to be started. The script was located in Startup folder C:\Documents and Settings\MY_USER_NAME\Start Menu\Programs\Startup.

Thursday, July 09, 2009

VirtualBox on CentOS 5.3: port forwarding

I have installed VirtualBox 2.2.4 on a CentOS 5.3. As a guest OS I installed Ubuntu, and on that Ubuntu I made a LAMP server. So, what I wanted was to redirect all html requrest on port 80 of CentOS (host) to port 80 of Ubuntu (guest). This is similar problem to the previously described on Windows XP host. The difference is that this time my host was CentOS 5.3, and VirtualBox was running as a normal user, not as a root.

The first thing to do was to make VirtualBox to forward the ports. I did it by executing the following commands, as a normal user under which VirtulBox was running. VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/Protocol" TCP
VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/GuestPort" 80
VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/HostPort" 80
where "ubuntu-server" is the name of Ubuntu guest.

Than I wanted to start it in a headless modeVBoxHeadless -s ubuntu-server but I was getting the following error:Error: failed to start machine. Error message: NAT#0: configuration error: failed to set up redirection of 80 to 10.0.2.15:80. Probably a conflict with existing services or other rules (VERR_NAT_REDIR_SETUP).
Unknown error creating VM (VERR_NAT_REDIR_SETUP)
This error is due to the fact that in Linux systems only root can bind to ports below 1024, and not a normal user!. There are two possible solutions. First is to run VirtualBox as a root, the second is to redirect port 80 to port 8080 in the CentOS and the make VirtualBox to get connection from port 8080 of CentOS. I choose the second option. Therefore, I did as follows:

VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/Protocol" TCP
VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/GuestPort" 80
VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/HostPort" 8080
The above makes VirtualBox to redirect trafic from 8080 of CentOS to 80 of guest ubuntu-server. Than as a root I used iptables to redirect port 80 to 8080 in CentOS iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080To check if iptables command was succesfull I used iptables -t nat -L commandiptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
REDIRECT tcp -- anywhere anywhere tcp dpt:http redir ports 8080

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
If OK save your iptables settings usingsudo /etc/init.d/iptables saveHope it will be useful. I also used VirtualBox 2.2, rather then VirtualBox 3.0, but I think the procedure will be similar.

The schematic illustration of what I did is below:



Wednesday, July 08, 2009

Install VirtualBox on CentOS 5

Go to the conclusions if you have no time for BS. If you have time the details of my installation of VirtualBox 2.2.4 on CentOS 5.3 are below.

1. I downloaded VirtuaBox rpm form virtualbox.org. In my case I downloaded VirtualBox-2.2.4_47978_rhel5-1.i386.rpm

2. Installed the rpm as a rootsu root -c "rpm -ivh VirtualBox-2.2.4_47978_rhel5-1.i386.rpm"
But I got the errorerror: Failed dependencies:
libSDL-1.2.so.0 is needed by VirtualBox-2.2.4_47978_rhel5-1.i386


3. So I installed SDL su root -c "yum install SDL" and I tried again su root -c "rpm -ivh VirtualBox-2.2.4_47978_rhel5-1.i386.rpm" and the installation failed Preparing... ########################################### [100%]
1:VirtualBox ########################################### [100%]

Creating group 'vboxusers'. VM users must be member of that group!

No precompiled module for this kernel found -- trying to build one. Messages
emitted during module compilation will be logged to /var/log/vbox-install.log.

Compilation of the kernel module FAILED! VirtualBox will not start until this
problem is fixed. Please consult /var/log/vbox-install.log to find out why the
kernel module does not compile. Most probably the kernel sources are not found.
Install them and execute

/etc/init.d/vboxdrv setup

as root.
The reason is that kernel-headers and kernel-develop packages were missing, so I installed them su root -c "yum install kernel-headers kernel-devel" Be sure that the install packages correspond to your kernel version! You can check this as follows: [W@localhost ~]$ uname -a
Linux localhost.localdomain 2.6.18-128.1.16.el5 #1 SMP Tue Jun 30 06:10:28 EDT 2009 i686 i686 i386 GNU/Linux
[W@localhost ~]$ rpm -q kernel-headers kernel-devel
kernel-headers-2.6.18-128.1.16.el5
kernel-devel-2.6.18-128.1.16.el5


4. I removed failed installation of VirtualBox su root -c "rpm -e VirtualBox-2.2.4_47978_rhel5-1.i386" and I tried again to install it. Again I got the same error. But this time the reason was that I did not have gcc installed. So I installed it su root -c "yum install gcc", removed failed installation of VirtualBox and tried again to install it: [W@localhost ~]$ su root -c "rpm -ivh VirtualBox-2.2.4_47978_rhel5-1.i386.rpm"
Password:
Preparing... ########################################### [100%]
1:VirtualBox ########################################### [100%]

Creating group 'vboxusers'. VM users must be member of that group!

No precompiled module for this kernel found -- trying to build one. Messages
emitted during module compilation will be logged to /var/log/vbox-install.log.

Success!
This time it worked!!

Concussion

First, download VirtualBox from virtualbox.org. Second, install four missing packages (at least I did not have these packages installed, they are on CentOS CDs/DVD, you can use pirut or yum to install them) su root -c "yum install SDL kernel-devel kernel-headers gcc" Third, install VirtualBox su root -c "rpm -e VirtualBox-2.2.4_47978_rhel5-1.i386" Fourth, add yourself to the vboxusers group su root -c "/usr/sbin/usermod -a -G vboxusers yourusername"Finally, start VirtualBox:[W@localhost ~]$ VirtualBox

Thursday, April 23, 2009

VirtualBox: 3D acceleration for Ubuntu

I have just installed VirtualBox 2.2 on Mac X 10.4. I also installed latest Ubuntu 9.04 as a guest in the VB. To my surprise, 3D acceleration works! I can enjoy compiz effects (3D cubes or wobbling windows) in VirtualBox. There were absolutely no problems to make it work!

Thursday, March 26, 2009

Arch linux: very first impression

Usually I don't write any reviews or any opinions on linux distros. However, I have to make an exception. The reason is that I have just install Arch linux! Arch linux is
a lightweight and flexible Linux® distribution that tries to Keep It Simple.
First on virtual box though, just to see what all the fuss is about. What I see is that this distro is quite interesting, it was easy to install. It was easy to set up fluxbox, and some other programs that I need (e.g. python-numpy, python-scipy, matplotlib). Currently I’m using CentOS on my HPC (high performance computing) server, and ubuntu 8.10 on desktop. In few weeks Ubuntu 9.04 released and I strongly think that I may move to Arch on desktop! Not 100% sure now, but I keep testing arch on virtualbox. Definitely, the first impression is positive! If I'll have some further info about this, I will update this post.

Friday, February 06, 2009

ubuntu-server: installing different GUIs

By default, ubuntu-server 8.04 does not come with any graphic desktop environment or GUI. Which is natural, because it is server. However, sometimes it would be useful to have some GUI. It is not a problem to install it. Admins have quite a few options for GUIs. Here I will show only few of them.

Method

The following examples were performed using ubuntu-server 8.04.2 installed as a guest os in VirtualBox 2.1.2. The screenshot of a system was performed just after the fresh install of ubuntu. After installation of each desktop the system was reverted to current snapshot. Therefore, in each example, only one GUI was present in the system. For each example /etc/apt/source.list was not modified. All desktops are available in default ubuntu repositories.

To start any of the following GUIs after they have been installed, the following command can be used: startx

ubuntu-desktop

sudo aptitude install ubuntu-desktopThe command will take 560MB of space. This amount includes about 37MB for xorg. It installs full ubuntu/gnome desktop with every software normally available in ubuntu-desktop (OpenOffice, Firefox, etc...). It takes quite a long time to install. The main disadvantage of this, is that it de facto converts ubuntu-server into ubuntu-desktop. This has not much sense, since we want ubuntu-server and not ubuntu-desktop. However, such an option exists, and in some cases it may be useful.Instead of gnome base ubuntu-desktop, in a similar way, user can install kubuntu-desktop or xubuntu-desktop.

gnome-core

sudo aptitude install xorg gnome-coreThe command will download about 160MB. It also takes a bit of time to install. As the name suggests it installs only basic gnome functionality.

xfce4

sudo aptitude install xorg xfce4The command will download about 80MB. Again, as the name suggest, it installs xfce4 desktop environment. Installation time is not so terrible.

enlightenment

sudo aptitude install xorg enlightenmentThis will download about 50MB.

fluxbox

sudo aptitude install xorg fluxboxThe command will download about 39MB. It must be rememberd that xorg is about 37MB! Hance, fluxbox is about 2MB! Most of the installation time is used for installing xorg.

twm

sudo aptitude install xorg twmIt will download about 38MB. It must be remembered that xorg is about 37MB, therefore twm is about 1MB!

ctwm

sudo aptitude install ctwmThe command will download about 38MB. This is slightly improved version of twm. Specifically it adds virtual desktops. However, for me there was some problem in that I could not navigate through the menu.

vtwm

sudo aptitude install vtwmThe command will download about 38MB. Again, this is slightly improved version of twm. Specifically it expands desktop.

Conclusions

There are many desktops that can be installed in ubuntu-server. As far as I am concerned, for me the smaller desktop the better. This is because, they do not consume lots of server resources, their installation is fast, and they are perfect for using with vncserver. Therefore, I would recommend fluxbox, twm, ctwm or vtwm.

Wednesday, January 28, 2009

VirtualBox: discard snapshot

I have always been confused by naming of commands available for snapshots in VirtualBox. Especially, what is the difference between discard snapshot and discard current snapshot and state. For that reason, I made small experiment. I made new virtual machine (without any snapshots) and I performed the following operations:
  1. Make folder named made_before_a
  2. Take snapshot named a
  3. Make folder made_before_b
  4. Take snapshot named b
  5. Make folder made_before_c
  6. Take snapshot named c
  7. Remove all dirs and save state of machine
As a result, the my snapshots were as follows:At this point, I had three possibilities:I wanted to see what would happen if I had performed 'discard current snapshot and state' or 'revert to current snapshot'. Remember that in point 7 above, I removed all my folders, therefore Current State (changed) refers to the guest OS without the folders (i.e. without made_before_a, made_before_b and made_before_c).

Discard current snapshot and state

This option removed snapshot c and the Current State (changed). After starting my guest OA I had only folders made_before_a and made_before_b!

Revert to current snapshot

After this my guest os was in a state at which snapshot c had been taken (i.e. folders made_before_a, made_before_b and made_before_c were restored)

Discard snapshot

Final option is discard snapshot.This option removes the snapshots but not the current state. In other words, I could remove all my snapshots (named a,b, and c) and I was left only with my current state (i.e. no folders)!

Conclusions

  • Revert to current snapshot - it moves guest os to the state it was when the snapshot was made. All changes made since the snapshot creation time will be lost.
  • Discard current snapshot and state - it moves guest os to the state of the previous snapshot. Current snapshot and all changes are lost. In my example, performing operation 'discard current snapshot and state' on snapshot c, moved my systems to state of snapshot b.
  • Discard snapshot- it removes a snapshot, but not the changes made since the creation of the snapshot.

Hope it will be useful and hope I did not make any mistake (apart from my English :-)).

Alternative source of info

This topic was previously discussed. Also, VirtualBox documentation might be handy.

Monday, January 26, 2009

VirtualBox: port forwarding

My host: windows XP
My guest: ubuntu 8.04.1

To redirect all connections from port 80 (www server) of the host machine to port 80 of theguest operating system being I used the following commands in windows xp console: VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/Protocol" TCP
VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/GuestPort" 80
VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/HostPort" 80

"Apache" is an arbitrary name, and "ubuntu-server" is the name of my virtual machine with Ubuntu.

Ports can be redirected only when VirtualBox is turned off.

Sunday, January 25, 2009

VirtualBox: discard snapshot versus discard current snapshot and state

The post was moved here.

Mac X: Port forwarding from Host OS to guest OS in VirtualBox 2.0.2

I run ubuntu-server on my VirtualBox 2.0.2. In order to run ubuntu-server on my VirtualBox I followed this site. The reason is that Ubuntu-server uses PAE (physical address extension) which is not supported in VB (this feature is still in beta in VB). Once this has been fixed, I was able to connect to web server running within VB from my Mac OS. For this I used the following commands in Mac X:
VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/Protocol" TCP

VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/GuestPort" 80

VBoxManage setextradata "ubuntu-server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/HostPort" 8080
To remove this forwarding just execute the same commands without 80,8080 and TCP.


The same should work in windows xp. Command netstat -a shows connections.

When porting VB ubuntu-server from Mac X to Windows XP, there was a problem with VB - no internet. I run dhclient and change entry in /etc/network/interface. After that internet in VB was working, and web server also.

Sunday, August 24, 2008

VirtualBox: backup VDI using clonevdi tool

To list virtual drives:
VBoxManage list hdds
You must get UUID of virtual drive you want to clone. As an egzamples lets assume that UUID is 973b3243-8168-41c3-bb29-1c9865eaec7c. Having this, one executes clonevdi command as follows:
VBoxManage clonevdi 973b3243-8168-41c3-bb29-1c9865eaec7c outfilename.vdi I noticed that when coping VDI to new Vbox, networking does not work good.
I managed to repair this by restarting it (my guest is Linux):
/etc/init.d/networking restart
Also sometimes this failed, because the command was restarting wrong network interface, e.g. eth4 instead of eth2. This can be change in /etc/network/interfaces

Thursday, May 17, 2007

VirtualBox, Intel Mac X, Ubuntu (Ubuntu Server Edition)

Having Mac X at work is really nice thing. However sometimes one would like to use something else like Linux or Windows or whatever. I'm one of those guys that needs usually more than one operating systems, just to test something, or just because there is some feature that is present in e.g. Linux which is not available in Mac X. I decided to try VirtualBox beta for Intel Mac X, and to install Ubuntu. My choice of Ubuntu was driven only because where I work, Ubuntu is Ubuntu available at local ftp i.e. do not need to download it form the Internet.

Even thought VirtualBox for Intel Mac X is in beta stage, the installation was smooth, installation of Ubuntu also. Ubuntu on VirtualBox had out-of-the box internet and network working. In other words, there was no problems in installing, running, and using virtual Ubuntu.

The only problem there was/is with shearing folders. This is not VitualBox fold (I thinks so), but Ubuntu's mounting schema. What I mean is, that after mounting share folder, only root can write to it. Unfortunately it is not possible to set up umask=000 (everyone can read/write).

Below some screens of Mac and Ubuntu.


Share folders:mount -t vboxsf [-o OPTIONS] sharename mountpoint

As a matter of fact, I would prefer to have Windows XP on Virtual Box, but to install it, first I have to talk with our IT manager, because he has Windows installation cd-rom.

What about Ubuntu Server Edition? I wander if it was possible to install Ubuntu Server Edition on VirtualBox on Mac X, and use it just like server i.e. to set up an internet website on a virtual server. To check it, and to check Ubuntu Server Edition I decided to install this os on VirtualBox and try to set up a working, virtual LAMP server.
Unfortunately the answer to the above question is: Installation of Ubuntu Server Edition failed. In fact installation went fine, but first booting just after the installation resulted in:


I decided to check something else also. I was wandering if I can copy virtual Ubuntu created in Mac X to Windows XP and run in successfully there.