December 2014
M T W T F S S
« Sep    
1234567
891011121314
15161718192021
22232425262728
293031  

Categories

Running your Existing Ubuntu installation inside virtualbox on Windows 7

Firstly, why would you do that?
I mean run an existing Ubuntu installation inside windows 7. Its possible to go about it the other way, but this is far simpler. Windows is kind of hardware change unfriendly. When the installed windows detects that the IDE has changed (you are booting a vm) its going to require re-registeration. This wont be a straightforward process if you have an OEM license, which is what you will have if your windows came bundled with your laptop/desktop. On the other hand, linux kernels are soooo easy with hardware changes.

Hardware Requirements

This you will probably find in some virtualbox documentation, but from my experience, I would suggest:
1) older processors like pentium 4, pentium D do not have virtualization support (VT-x on intel cpus). VM performance will be quite poor on these. Only install the VM if you have a relatively new processor.
2) You need a decent amount of RAM. 2 gigs with atleast 750MB allocated for the VM should be a minimum requirement for newer ubuntu versions (10.x etc)

Getting Started:

Before I get started, I’d like to thank the author of this article which I found extremely useful.

1) Download and install virtualbox. Its generally suggested that the non-ose edition is much more up-to-date than the ose edition. Whatever version you use, please go through/understand and respect the license under which the version is released.

2) Create the vmdk file:
2.1) Find the partitions that are used by your linux installation: start cmd as admin and cd into the directory you installed virtualbox and run:

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PhysicalDrive0
Oracle VM VirtualBox Command Line Management Interface Version 3.2.8
(C) 2005-2010 Oracle Corporation
All rights reserved.

Number Type StartCHS EndCHS Size (MiB) Start (Sect)
1 0x06 0 /1 /1 25 /254/63 203 63
2 0x07 26 /1 /40 1023/254/63 23999 417792
3 0x83 1023/254/63 1023/254/63 161242 49567744
5 0x07 1023/254/63 1023/254/63 42343 379792728
6 0x82 1023/254/63 1023/254/63 8635 466513920

PhysicalDrive0 indicates the first hard disk. Sort of like /dev/sda, /dev/sdb etc. Partition types 0×83 and 0×82 are the swap and ext3 partitions here.

From the listing identify all the partitions that are required by linux ( rootfs, swap, boot…)
Dont consider NTFS/VFAT partitions that you want to share between linux and windows.

2.2) Create the vmdk file with the partitions you just identified

VBoxManage.exe internalcommands createrawvmdk -filename C:\path\ubuntu.vmdk -rawdisk \\.\PhysicalDrive0 -partitions 3,6 -register

3) Start virtualbox. You have to start it as administrator, otherwise it wont be able to access the rawdisk.

4) Create a new VM using the vmdk you just created. This is a straightforward process. You would want to enable IO-APIC and if your box has muscle, allow more cores, 2d/3d acceleration etc.

5) And now, you’re all set. Start the VM. You should see the familiar grub boot screen. Select your ubuntu installation and it should come up without any issues.

6) MOunt vbox host additions and install it. This will give you a lot of useful features, like higher resolution display.

Some tips, tricks and problems to be aware of:

1) Use vboxsf to share folders between windows and linux. One thing to be aware of is, at the time this article was written, vboxsf didn’t have support for symbolic links.

2) The VM will be able to connect to the network using NAT. But if you want to do stuff like export NFS shares or use ssh, you would want to create a network bridge. To do this, on windows 7:
a) go to Control Panel\Network and Internet\Network Connections, press ctrl, select both your network adapter and virtual box host-only adapter, right click and create the bridge.
b) Now, on your vm, either through settings, or by right clicking on the vm’s network icon, change your adapter from NAT to bridged adapter.

3) The VM clock can sometimes skew, especially if you hibernate or push your windows to sleep while the VM is running. If you have installed vbox host additions, this shouldn’t happen, but if it still does, one handy trick is to disconnect and reconnect the ubuntu wired network.

4) Whenever ubuntu downloads and installs an updated kernel, it updates grub too. Your VM can only see the partitions that you added into your vmdk while creating it. As a result, it will remove your windows root partition from the grub list. A solution to this, is to reboot into linux and run

sudo update-grub2

8 comments to Running your Existing Ubuntu installation inside virtualbox on Windows 7

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>