Showing posts with label virtualization. Show all posts
Showing posts with label virtualization. Show all posts

Booting your Dual-boot OS in a virtual machine

In my previous post I showed how to boot from a USB device in a virtual machine by directly connecting a physical disk from the host to the VM. Just to see how far you can go with that I tried to boot my dual-boot OS in the same way.

Note: directly accessing your boot-disk from a VM can seriously mess up things. You are warned :)

Note: simultaneously running your host OS in a virtual machine is most definitely going to result in disaster; I strongly advise not to do that.

The process is basically the same as for attaching your USB stick, but this time you have to select PhysicalDrive0 in QEMU or VMWare player.



In VMWare player you have the option to select the partions the VM is allowed to access. The bootsector/MBR is always accessible, so you can use this option to prevent the VM from accessing your host OS. On my disk I have Samurai WTF installed next to my windows OS. I have 2 NTFS partions, 1 FAT32 partition and 2 ext partitions. In this example I booted in windows and want to have the VM boot the dual-boot linux so I only selected the ext partitions in the VM properties:



Booting the VM first shows the bootloader



And after selecting the Linux option it will boot without problems.



Attempting to boot from a partion not selected in the VM properties will result in an error, so you can use this option to prevent accidentally selecting the wrong OS:

Booting from USB flashdrive in virtual machine

The last weeks I have been playing a bit with bootable USB flashdrives and bootloaders/managers. One of the annoyances in doing that is testing if your changes work. The easiest way is to do this in a virtual machine of course, but not all virtual machine solutions support booting from a USB device. Many solutions found on the internet suggest booting an iso with a bootmanager (like plop) first, but there is a more direct solution in VMWare player and QEMU (maybe also in other products). A big advantage of this method is that directly accessing the disc is a lot faster than by using the USB stack of the virtual player.

Both VMWare player and QEMU support booting from "Physical Drives", which basically is nothing more that booting from a disk that is already present in the host.

When you are using QEMU with QEMU Manager the option can be found on the Drives tab:



The booting device of the host is typically PhysicalDrive0. Your USB devices should be PhysicalDrive1 or higher. Make sure you select the right one.

In VMWare the option is not directly available when creating a new VM. First you have to create a virtual hd of any size and finish the VM. After that edit the properties and delete the created HD. Now add a new hard disk and select the option "use a physical disk (for advanced users)":



Just as in QEMU the booting device of the host is typically PhysicalDrive0. Your USB devices should be PhysicalDrive1 or higher. Make sure you select the right one.



There is also a selection for using the whole drive or individual partitions, but for USB flashdrives you can leave this on "use entire disk" (as partitions on USB flashdrives are hardly supported and unusual).

A screenshot of a proof-of-concept running the miniXP from Hiren's BootCD in VMWare player. In this case the USB flashdrive was formatted as FAT32, but for me it also worked when it was formatted as NTFS. I used grub4dos as the bootloader/manager.



and the properties of the virtual machine in VMWare Player:



Update: to prevent the VM from hijacking the USB flashdrive remove the "USB controller" from the VM properties.

QEMU: Portable Virtualization

Sometimes you find yourself in a situation where you really need that one tool on another LiveCD, but that means rebooting and losing the stuff you're working on (or at least slow you down in the progress).

For this I found QEMU to be very useful. Combined with QEMU Manager this tool provides a nice GUI based portable virtualization tool. Best of all it's able to boot a CD, USB device or ISO.

So put QEMU, QEMU Manager and all of your favorite ISO's on a USB stick and you are able to use all the tools you want, whenever you want. (well .. off course you cannot run any WLAN hacking tools, but that goes without saying).