Hello, fellow dual-booters. I am sure many of you, while using your windows installation, for one or another reason needed to use Ubuntu. Using a virtual machine does the trick, but with virtual os’s you have limited resources and require more space. That’s why I thought if it is possible to boot your existing, already installed Ubuntu through a virtual machine while still using Windows. As it turned out, it was possible. So, let’s see how it’s done.
Creating grub boot disk image
1. Boot into your Ubuntu installation
2. Somewhere create an directory(I’ll name mine iso)
3. in the iso directoy, create subdirectoy “boot”. In the boot directory create a directory named “grub”. Now, your directoy tree should be “<path-to-your-iso-dir>/iso/boot/grub”
4. now, copy all the files in your /usr/lib/grub/i386-pc to your grub directory. By command prompt, you can use:
cp /usr/lib/grub/i386-pc/* <path-to-your-iso-dir>/iso/boot/grub
5. also, you need to copy the ‘grub.cfg’ file
cp /boot/grub/grub.cfg <path-to-your-iso-dir>/iso/boot/grub
6. finaly we create our booting iso file
grub-mkrescue -o boot.iso <path-to-your-iso-dir>/iso/
This will create an iso file located in your Home directory.
Note: If you recieve an error “/usr/bin/grub-mkrescue: 323: xorriso: not found” you will need to install xorriso
sudo apt-get install xorriso
Creating .vmdk file for Linux
1. Boot into Windows
2. Go to the installation directory of Virtualbox(if you haven’t installed it, now is the right time)
3. Open a command promt there with admin rights and type
VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PhysicalDrive1
Note: if that doesn’t work, try with PhysicalDrive0 instead of PhysicalDrive1. Those are the numbers of your hard drives(Master is 0, second hard drive is 1, etc.)
Here you should see your partitions including the ones used by Ubuntu.
The partitions 5 and 6 are the Ubutnu’s ext3 and swap partitions
To create a .vmdk file, execute the following command
VBoxManage.exe internalcommands createrawvmdk -filename C:\<path>\ubuntu.vmdk -rawdisk \\.\PhysicalDrive1 -partitions 5,6 -register
In this command, you should change “<path>” with the directory you want the .vmdk to be. Also 5 and 6 are the numbers of your Ubuntu installation partitions.
Note: newer versions of Virtualbox don’t require the -register statement. If you recieve such an error, just retype the command without “-register”
Open your virtual machine with Virtualbox
1. Open Virtualbox(again with admin rights) and create a New virtual machine. In the dialog window, select Linux ubuntu. For loading disk, select existing and find the .vmdk file you created.
2. Once created, go to settings and choose the .iso file for loading disk(In my case, go to Storage -> Ide controller, Add a CD/DVD device and choose it as primary)
Now once started, through Virtualbox’s window you should be able to access your installed Linux Ubuntu installation.