Notes on VirtualBox / Quickstart guide to VirtualBox

General Notes

  • “hosted” hypervisor or type 2 hypervisor where as a “bare-metal” or “type 1″ hypervisor would run directly on the hardware
  • open virtualization format (OVF)
  • VirtualBox Remote Desktop Extension (VRDE) – also support for full client USB Support
  • Extensible RDP authentication
  • USB Over RDP
  • Extension packs available
    • the virtual USB 2.0 (EHCI) device
    • virtual boc remote desktop protocol
    • Intel PXE boot RPM with support for E1000 network card
  • fixed sized hard disk image is faster and has less overheads compared to an expanding overhead
  • different kinds of disks:
    • VDI
    • VMDK
    • VHD
    • HDD
  • Two importable formats:
    • VMDK with a file in an XML Dialect with an .ovf extension. These files must reside in the same directory for the VirtualBox to be able to import them.
    • Everything in a single archive called the .ova extension. its an archive file with a variant of the TAR archive format)
  • Commmands in the virtualbox package
    • VirtualBox – virtualbox manager
    • VBoxManage is a command line manager fro very detailed control
    • VBoxSDL for simple graphical frontend
    • VBoxHeadLess is yet another frontend to produce no visible output on the host at all.
  • Dynamic Kernal Module Support requires to be installed, this framework helps with building and upgrading kernel modules.
  • if the kernel of your linux host was updated and DKMS is not installed, in that case the kernel module will need to be reinstalled by executing (as root)
    $ /etc/init.d/vboxdrv setup
    
  • virtualbox now not only supports PIIX3 but also the ICH9 chipset for latest operating systems like macosx
  • Auto mounting: linux guests automounted shared folders are mounted into /media directory align with the prefix sf_. for example, the shared folder mayflies would be mounted to /media/sf_myfiles on linux. The sf_ is controlled by the property /VirtualBox/GuestAdd/SharedFolders/MountPrefix
  • access to the automounted folders is only granted to members of the user vboxsf
  • listing the virtualbox guest property
    $ VBoxManage guestproperty enumerate "Windows Vista" 

    or listing a specific property

    $VBoxManage guestproperty get "windows vita" "/VirtualBox/GuestInfo/OS/Product"
  • to change values use $ VBoxControl guestproperty enumerate
  • VBoxManage guest-control to run commands inside the guest from the host machine
  • Memory ballooning is used to share memory associated with a vm with another vm. This is used for memory over commitment.
  • VBoxManage controlvm “VM Name? guestmemoryballoon where n is the memory the memory to allocate the guest vm. the guest additions software must be installed for this to run.
  • Virtual box dedups the page duplication by using PageFusion you can only turn it on when a vm is turned off
  • VBoxManage modifyvm "VM Name" --pagefusion on
    you can observe page fusion operation using metrics RAM/VMM/Shared shows the total amount of fused pages, whereas the per-vm metric guest/RAM/Usage/Shared will return the amount of fused memory for a given VM.
  • Virtualbox allows you to manage the size of the disk even after the disk creation, even after data has been written to it.
  • Virtualbox disk format:
    • normally by default for a new image, the format it uses is called Virtual Disk Image (VDI).
    • VirtualBox also fully supports the popular and open VMDK contrainer format that is used by many popular virtualization softwares like VMWare.
    • Alsofully supports the VHD format from microsoft.
    • Image files from Parallers version 2 (HDD format) also supported. newer formats 3, and 4 are not supported however you can convert them into older format (version 2) by using tools provided by parallels.
  • Do not simply make copies of virtual disk images. if you import such a second copy into a virtual machine, virtualbox will complain with an error, since VirtualBox assigns a unique identifier (UUID) to each disk image to make sure it is only used once.
  • Disk modes:

    • normal mode, allows you to take snapshots and restore from it.
    • write-through hard disks: are completely unaffected by snapshots. their states are not taken and not restores when snapshots are restored.
    • shareable hard disks: works the same as write-though hard disks however they can be used to be shared across multiple VMS writing to it directly. standard filesystem is not setup to be written by multiple file systems at the same time.only fixed size images can be used in this way, and dynamically growing images are rejected.
    • immutable images only remember write access temporarily while virtual machines are running. so the approach is create a new ‘normal’ image and once you are happy with the setup and deem its contents useful then mark it ‘immutable’;
    • if you take a snapshot of a machine with immutable images, then on every machine power-up those images are reset to the state of the last (current) snapshot (instead of the state of the original immutable image)
    • As a result the same immutable image can be used by several virtual machines without restrictions. (Also looking at the ‘enabling the differencing disks’ that with auto-reset turned to off so that the vm’s sharing the immutable disk don’t forget the settings.
  • An image in ‘multi-attach mode’ an be attached to more than one virtual machine at the same time, even if these machines are running simultaneously. For each virtual m aching to which an image is attached, a differencing image is c reared. As a result data that is written to such a virtual disk by one machine is not seen by the other machines to which the image is attached. each machine creates its own history of the multi-attach image.
  • The standard approach would be ‘one immutable disk for the operating system’ and one ‘write-though’ for your data files.
  • Networking: virtualbox providers up to eight virtual PCI ethernet cards for each virtual machine. for each such card, you can individually select:
    • The hardware that will be virtualised as well as
    • The virtualization mode that the virtual card will be operating in with respect to your physical networking hardware on the host.
  • Networking modes:

    • Not attached: in this mode the virtualbox reports to the guest that a network card is present but there is no connection, as if no ethernet cable was plugged into the card.
    • NAT: default mode, only required to browse the web, download files and view email inside the guests. certain limitations when windows file sharing.
    • Bridged network: more advanced needs such as network simulations and running servers in a guest. when enabled virtual box connects to on our installed network cards and exchanges network packets directly, circumventing your host operating system’s network stack.
    • Internal networking: visible to only certain software based networking (selected virtual machine) but not to applications running on the host or the outside world. Internal networking is the same as bridged networking as that it lets the vm speak to the outside world except that the outside world is the other vm’s on the same host.
    • Host-only networking: create a networking containing the host and a set of virtual machines without the need of the host’s physical network interface. instead a virtual network interface (similar to loopback interface) is created on the host, providing connectivity among virtual machines and the host.
    • VDE (virtual distributed ethernet) networking:
  • port forwarding
    VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"
    natpf1 denotes the network card
    2222 is the port on the host
    22 is the port on the guest
    guestssh is purely description and will be auto-generated if not present
    
  • to remove the same rule:
    VBoxManage modifyvm "VM name" --natpf1 delete "guestssh"

    NOTE: it is not possible to configure incoming NAT connections while the VM is running. However, you can change the settings for a VM which is currently saved (or powered off at a snapshot)

  • bridged networking: with bridged networking, virtualbox uses a device driver on your host system that filters data from your physical network adapter. this driver is therefore called ‘net filter’ driver. this allows virtualbox to intercept data from the physical network and inject data into it, effectively creating a new network interface in software. When a guest is using such a new software interface, it looks to the host system to the host system as though the guest were physically connected to the interface using a network cable. the host can send data to the guest though that interface and receive data from it. thismeans that yo can setup routing and bridging between the guest and the rest of your network.
  • running virtualbox as headless
    VBoxManage startvm "VM Name" --type headless

    the extra –type option causes VirtualBox to use VBoxHeadless as the front-end to the internal virtualization engine instead of the qt-front-end
    the alternate syntax is:

    VBoxHeadless --startvm <uuid|name>

Steps to install a vm headless server

create a new virtual machine

VBoxManage creative --name "Windows XP" --ostype WindowsXP --register

--registervm is optional, doing it now saves you from having to do that manually later.
--ostype is also optional but selecting this upfront results in some default options to be selected.
[/cpde]

To get the complete list

<code>VBoxManage list ostypes</code>
<ul>
<li>make sure that the vm is configured the guest operating system.
	1VBoxManage modifyvm "Windows XP" --memory 256 --acpi on --boot1 dvd --nic1 nat
  • Create a virtual hard disk for the vm (10GB)
    VBoxManage createhd --filename "WinXP.vdi" --size 10000
  • Add an IDE controller to the new VM
    VBoxManage storagectl "Windows XP" --name "IDE Controller" --add ide --controller PIIX4
  • set the VDI created above as the first virtual disk of the new VM
    VBoxManage storageattach "Windows XP" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium "WinXP.vdi"
  • attach the ISO file that contains the operating system
    VBoxManage storageattach "Windows XP" --storagectl "IDE Controller" --port 0 --device 1 
  • type
    dvddrive --medium /full/path/to/iso.iso
  • Start the virtual machine
    VBoxHeadless --startvm "Windows XP"
  • About rp

    Architect for large, highly scalable LAMP applications and Technical Manager with special focus on metrics based continuous improvement of teams and products. Rajat has close to a decade of experience of a very wide range of skills related to infrastructure, middleware, app servers all the way to front-end technologies and software development methodologies including agile, iterative waterfall, waterfall as well as ah-hoc startup using the right approach in the right context to reduce time to market.