Archive
Start a VirtualBox operating system from the command line
Problem
Under Linux I have a Windows 7 system in VirtualBox that I mainly use for Powerpoint. I have some more virtual operating systems too but I almost always launch Windows 7 only. Starting the GUI and clicking on the “Show” button to launch it quickly became a pain in the ass. How to launch my Windows 7 from the command line?
Solution
jabba@montreal:~$ VBoxManage list vms
"Windows 7 (old Office XP)" {80ce13dd-8a59-4d0a-94b5-9d8fa1130c62}
"Ubuntu 12.04" {e76ac634-1b73-42fc-85c0-f4f700edbe14}
"Office 2007" {43553e05-55b1-4095-8b66-8dcda275d9e2}
"Ubuntu 12.10 beta" {a22a2b9b-7a64-4345-8fb2-26d766989773}
jabba@montreal:~$ VBoxManage startvm "Office 2007"
I put it in a shell script called “office2007″. Done.
More info
Increase the size of a Virtualbox hard drive (.vdi)
The following entry is based on this post.
Problem
I have a Linux host with a Windows 7 guest. The hard disk of the Windows guest was set to 30 GB but it got full. How could I extend its size to 40 GB for instance?
Solution
Locate the .vdi file of the virtual system. To be safe, make a backup copy of it. After that you can increase its size:
sudo VBoxManage modifyhd Windows7.vdi --resize 40000
Here Windows7.vdi is the name of my .vdi file and 40000 is given in megabytes, which is roughly 40 GB.
Now, if you boot the system and you verify the size of the C: drive, it will still be the old value. The increased size appears as a new unformatted and unused partition. You can join it with the C: partition the following way:
Go to the Control Panel, then System and Security, then Administrative Tools. Here you will see an icon called Computer Management. Start it. Choose Disk Management on the left side. Right click on drive C: and choose “extend volume“. It will be extended in a second. Done.
USB drive not mounted in Virtualbox guest
Problem
I have a Linux host with a Windows 7 guest in Virtualbox. I want to transfer some big files to the Windows guest via a USB stick but the Windows guest doesn’t see the attached USB stick. What to do?
Solution
I didn’t find a proper solution but I have a workaround. In Virtualbox, before booting up the guest system, you can specify a CD/DVD image under Settings -> Storage (see this figure). This image will be mounted and will be visible in the guest.
So, collect the stuff you want to transfer in a directory, convert the folder to ISO image format and mount this image file before booting up the Windows guest. Works for me :)
Another solution is to set up a shared folder but I haven’t figured out yet how to do that.
Virtualbox shared folder: Ubuntu host, Windows 7 guest
See http://maketecheasier.com/share-files-in-virtualbox-between-vista-guest-ubuntu-host/2008/11/12. Although it explains Vista, it works the same way with Windows 7.
Create a shared folder in Virtualbox
Problem
You have a guest operating system in Virtualbox and you want to exchange some data between the host and the guest. For this purpose you want to use a shared folder. The shared folder should be writeable in the guest too.
In my case I had two Ubuntu systems as host and guest.
Solution
There are several guides for setting up a shared folder (one, two). In short:
- create a shared folder on the host (e.g.
/opt/shared.folder.vbox) - create a shared folder on the guest (it can have the same path, e.g.
/opt/shared.folder.vbox) - install guest additions under the guest (Devices -> Install Guest Additions…), then restart the guest
- under the guest, go to Devices -> Shared Folders… Under Shared Folders, add the path of your shared folder (here
/opt/shared.folder.vbox). You can tick Auto-mount and Make Permanent if you want. Note that in my case, although I selected these two options, the shared folder was not mounted automatically.
Make the shared folder writeable
On the guest, you can manually mount the shared folder with the following command:
sudo mount -t vboxsf shared.folder.vbox /opt/shared.folder.vbox
As I figured out, only root can mount a shared folder.
However, it mounts the folder in read-only mode! To make it writeable, I had to add the following line(s) to /etc/fstab under the guest:
# shared folder shared.folder.vbox /opt/shared.folder.vbox vboxsf defaults,rw,auto,uid=1000,gid=1000 0 0
I use the system as a normal user called jabba, and 1000 is its user id and group id. It can be found in /etc/passwd (columns 3 and 4):
$ cat /etc/passwd | grep jabba jabba:x:1000:1000:Jabba Laci,,,:/home/jabba:/bin/bash
After a reboot, this folder is still not auto-mounted :( You can mount it with:
sudo mount /opt/shared.folder.vbox
But now it should be writeable…
Auto-mount shared folder at each boot
Now let’s put the dot on the “i” :) If you want your shared folder auto-mounted at each boot, add this line to /etc/rc.local on the guest:
mount /opt/shared.folder.vbox
Make sure that it comes before the line “exit 0“.
Windows 7 stops booting in Virtualbox
I installed Windows 7 in Virtualbox and it worked fine until I installed all the updates… After that the boot process stopped at the splash screen and nothing happened. Neither restart nor boot in safe mode helped.
Solution
Close Virtualbox completely. Restart it and go to the Settings of Windows 7. Here change some parameters, e.g. the number of processors and the amount of memory reserved for the system. After this Windows 7 booted up normally. I could even restore the settings without corrupting the booting process.
Installing VirtualBox
Problem
Under Ubuntu you want to use another OS (like Windows) in a virtualized environment.
Solution
As a free solution you can use VirtualBox. Be aware that it has two versions! A proprietary (also free) and an open-source edition (OSE). Some features are missing from the OSE, so I suggest using the other one.
Installation:
- visit the download page and fetch the install file that matches your host system
- when the installation is done, launch the application with the command
VirtualBox(pay attention to the capital ‘V’)
Other Products
There is another great (though proprietary) product called VMware Workstation. It also runs on Linux.
Troubleshooting
When I wanted to increase the number of processors available to a guest system, I got this error message: VERR_VMX_MSR_LOCKED_OR_DISABLED. It means that virtualization is disabled in the BIOS. Steps to follow (under Dell):
- Restart the machine and enter the BIOS by pressing F2.
- Go to Performance -> Virtualization, and set it On.
- Go to Security -> Execute Disable, and set it On.
