Showing posts with label virtualbox. Show all posts
Showing posts with label virtualbox. Show all posts

Sunday, 8 May 2011

VirtualBox : Network Types

You have 4 types of Network in VirtualBox. But how to chose?
Here are the basics...


NAT
NAT (Netork Address Translation) means the virtual machines will have private IP addresses on the virtualBox virtual network
VMs are not available from other pcs networking but can initiate connections to outside resources (servers, internet etc)

Host :

Guest :

C:\>ipconfig

Windows IP Configuration

Wireless LAN adapter Wireless Network Connection:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::8c63:1859:487c:f577%10
IPv4 Address. . . . . . . . . . . : 192.168.0.9
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.1

Ethernet adapter VirtualBox Host-Only Network:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::7804:1a06:c47b:f37d%17
IPv4 Address. . . . . . . . . . . : 192.168.56.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :


C:\>ipconfig

Windows 2000 IP Configuration

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 10.0.2.15
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.0.2.2

C:\>
Bridged Adapter
Bridged Adapter connects virtual machines via the host network card.
They are on the same subnet and get an IP from the same router/dhcp server that the host does.
VMs are effectively on the physical network.

Host :

Guest :

C:\>ipconfig

Windows IP Configuration

Wireless LAN adapter Wireless Network Connection:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::8c63:1859:487c:f577%10
IPv4 Address. . . . . . . . . . . : 192.168.0.9
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.1

Ethernet adapter VirtualBox Host-Only Network:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::7804:1a06:c47b:f37d%17
IPv4 Address. . . . . . . . . . . : 192.168.56.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :



C:\>ipconfig

Windows 2000 IP Configuration

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.0.3
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.1

Host-only Adapter
VirtualBox acts as the router (via adapter vboxnet0) and allocates IP addresses to VMs
By default this is a private network although you can assign a gateway (to grant internet access) making a a Bridged Adapter anyway.

Host :

Guest :

C:\>ipconfig

Windows IP Configuration

Wireless LAN adapter Wireless Network Connection:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::8c63:1859:487c:f577%10
IPv4 Address. . . . . . . . . . . : 192.168.0.9
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.1

Ethernet adapter VirtualBox Host-Only Network:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::7804:1a06:c47b:f37d%17
IPv4 Address. . . . . . . . . . . : 192.168.56.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :


C:\>ipconfig

Windows 2000 IP Configuration

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.56.101
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :

Internal Network
VMs can see each other, but not the host or the outside world :(

Host :

Guest :

C:\>ipconfig

Windows IP Configuration

Wireless LAN adapter Wireless Network Connection:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::8c63:1859:487c:f577%10
IPv4 Address. . . . . . . . . . . : 192.168.0.9
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.1

Ethernet adapter VirtualBox Host-Only Network:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::7804:1a06:c47b:f37d%17
IPv4 Address. . . . . . . . . . . : 192.168.56.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :

C:\>ipconfig

Windows 2000 IP Configuration

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
Autoconfiguration IP Address. . . : 169.254.21.26
Subnet Mask . . . . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . . . . :

Saturday, 7 May 2011

VirtualBox - Change UUID

" Cannot Register the hard disk ‘harddisk_2.vdi’ {93476107-f8f8-44ae-83b9-e6be00432ab8} because a hard disk ‘harddisk.vdi’ with UUID {93476107-f8f8-44ae-83b9-e6be00432ab8} already exists. "


You cannot just copy hard drive files and expect them to work on the same VirtualBox instance. You need to change the UUID, like this -

C:\>cd\program files\oracle\virtualbox

C:\Program Files\Oracle\VirtualBox>vboxmanage internalcommands sethduuid "c:\!rd
\virtualbox\w2000_2.vdi"
UUID changed to: cb850c97-570f-4051-bebb-92951a90e6cf

Saturday, 30 April 2011

Virtualbox : Copying & Converting Drive Images

VBoxManage is a command line tool that allows you to perform administrative functions on VirtualBox installations.
To create a copy of a drive, the command is -
 VBoxManage clonehd sourcefile targetfile . e.g Vboxmanage winxp.vdi winxpcopy.vdi

To change the format of the target, add the format parameter -

VBoxManage clonehd sourcefile targetfile --format VDI e.g.

VBoxManage clonehd c:\!RD\Virtualbox\w2003.vmdk w2003.vdi --format VDI
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: 6a1ded22-edb4-4cef-b74a-871db2fcafd6

If you want to increase the logical size of an expanding volume, the following post shows how to use VBoxManage to create a larger drive.

Thursday, 28 April 2011

VirtualBox : Compacting / Shrinking a Virtualbox drive file

Using Hyper-V over the past couple of years, I blogged on size optimization of the VHD files.
(They get bloated and consume more space than necessary)

Now I'm using VirtualBox for a personal SQL Server test environment, here is how to do the same for VirtualBox drives.

Compacting a VirtualBox Drive
  1. Delete rubbish from your virtual machine (clear temporary internet files, windows installer files, unwanted data, empty recycle bin etc)

  2. Defragment the drive (Use the OS’s defragmenter or third party FREE tool Defraggler)

  3. Zero out the unused data space in the guest OS

    You have 2 options here -
    i. Use Precompact.exe (details in Hyper-V post) or
    ii. Use Microsoft’s SDelete  e.g. SDELETE –c C:  (a lot simpler)

  4. Shrink the hard drive file from the host OS using VboxManage.exe
    vboxmanage modifyhd filename.vdi compact

    I found that Vboxmanage only runs from it’s install directory (dependency on DLL files) hence run it from there, e.g.

    C:\> cd C:\Program Files\Oracle\VirtualBox

    C:\Program Files\Oracle\VirtualBox> VBoxManage modifyhd c:\!RD\Virtualbox\w2003.vdi compact
This screenshot shows the space i was able to reclaim from one of my VMs...

Resources
http://www.dedoimedo.com/computers/virtualbox-shrink-expand-disks.html
http://www.plinky.it/blog/2009/05/18/virtualbox-compact-the-vdi-hard-disk-file/