Wednesday, March 24, 2010

VirtualBox Raw partition - Windows Host Linux Guest

Some virtualization systems have recently been able to handle real hard disk partitions. This is specially useful if you have a dual boot system (lets say Windows and Linux) but you frequently have to access a system while running the other. Then the solution is to use a virtual machine with your real OS installation.

In my case I'm accessing Linux from my Windows XP installation using VirtualBox. For the other way round you can easily find several how-to's around.


The most important and not obvious step is how to create the mapping virtual disk.

First you'll need to have the boot sector of your Linux Machine accessible. To create it use dd to extract the first 512 bytes from your bootable Linux partition. (In this case I have grub installed on it, NOT in the MBR).

After, please find the VirtualBox name of your partition.
  • VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PhysicalDrive0
Switch PhysicalDrive0 to PhysicalDrive1, PhysicalDrive2... as needed.

You should see something like this:

Number Type StartCHS EndCHS Size (MiB) Start (Sect)
1    0x07  0   /32 /33  13  /163/19           100         2048
2    0x07  13  /163/20  1023/239/63         20480       206848
3    0x07  1023/239/63  1023/239/63         26410     42149888
4    0x83  1023/239/63  1023/239/63         10239     96238800


To create the VirtualBox disk issue the command:

  • VBoxManage.exe internalcommands createrawvmdk -filename e:\vm\ubunturaw.vmdk -rawdisk \\.\PhysicalDrive0 -register -partitions 4 -mbr c:\linux.bin

-filename is the VirtualDisk name (may include path)
-register tells VirtualBox to register the virtual disk in the Virtual Media Manager
-partitions specifies which partition is to be mapped. Make sure it's your linux partition. If you don't specify VirtualBox will try to map the whole Disk, which can corrupt your data, besides not accepting your mbr file.
-mbr Specifies the master boot record for your system (required)

Now just create a common virtual machine with the recently created disk!

Tuesday, March 2, 2010

NIC Bonding/Teaming

NIC binding/teaming is about creating a virtual network device that can make use of several real NICs to achieve higher throughput and/or fault-tolerance.

This means both will have the same MAC address. Depending on the protocol, you might not even have to change router configuration, and several Linux distributions have good support on that.

Here I provide links to some how-to’s on enabing NIC bonding for some of the most popular Linux distributions. Windows users don’t have the same luck, unless the NIC manufacturer had provided some utility for this specific purpose.

In all the cases an additional kernel module has to be loaded (bonding). Debian systems make use of the ifenslave utility.

RedHat Linux Enterprise 4
http://www.cyberciti.biz/tips/linux-bond-or-team-multiple-network-interfaces-nic-into-single-interface.html

Debian
http://www.5dollarwhitebox.org/wiki/index.php/Howtos_NIC_Bonding_Debian
http://www.howtoforge.com/nic-bonding-on-debian-lenny

Ubuntu
https://help.ubuntu.com/community/UbuntuBonding