Dual-mode dual-boot Ubuntu x64 with Windows 7 x64 without burning a CD
The term "Dual-mode dual-boot" refers to a single physical copy of OS which can run both in Virtual Machine or on its own standalone. You can launch it by either booting directly into it upon machine restart (referred to as dual-boot) or running it in a virtual machine. This way of installation is very useful for some people because certain big tasks is better to be run directly in Linux but not in virtualbox's Linux due to performance reduction in VM.
Dual-booting Ubuntu with Win7 is no longer a big problem for many people. Just a bit of googling will give you dozens of solutions. However, to install dual-mode dual-boot Ubuntu on the same harddisk of the currently running Win7 is kind of headache especially for 64-bit windows because of the new restriction on raw disk access from Vista onwards ( support.microsoft.com/kb/942448 ) as well as Windows 7 64-bit forbids loading kernel drivers without Microsoft digital signature (this can be solved by enabling testsigning in boot config using bcdedit).
I have cracked my head and eventually managed to install Ubuntu 12.04 64-bit on Windows 7 Ultimate 64-bit using VirtualBox 4.2.4 using a Ubuntu ISO image without burning a physical CD. The copy of Ubuntu is installed using VirtualBox but can run not only inside Windows 7's virtualBox but also on its own (restart computer and boot directly into the same copy of Ubuntu). However, I am skeptical about the repeatability of my installation procedures, hope other people can have a try and to figure out whether it works and to make the procedure clearer and simpler.
Warning: DO NOT try this if you are NOT an expert in OS boot principle and harddisk partition, attempting things without understanding what exactly it does may result total loss of your harddisk data and at the same time rendering your current system unbootable.
Here're the required stuffs you need to prepare:
1. VirtualBox 4.2.4
2. EasyBCD 2.2 (in case needed)
3. EaseUS Partition Master (in case needed)
4. Ubuntu CD (12.04 I used)
5. basic knowledge in Command Prompt and Windows disk management
6. in BIOS, enable Intel virtualization technology, otherwise, 64-bit OS cannot be emulated in virtual machine, only 32-bit OS can be emulated
To get started:
1. Make sure you are in administrator mode with UAC disabled, so each operation has admin privilege;
2. run the following command in command prompt to enable test signing mode so that some kernel drivers can be loaded (I'm not sure if it's neccesary)
Bcdedit.exe -set TESTSIGNING ON
3. in "Windows disk management" (by right-click Computer -> Manage -> Storage -> Disk Management), make sure you have 2 empty partitions prepared for Ubuntu, 1 for system (suggest >=8GB), 1 for swap (total memory size). Your current harddisk type must be a basic disk (not a 'dynamic disk' or a 'GPT disk').
For example, in the figure above, Drive X is for Ubuntu OS and Y is for swap area (optional but strongly recommended unless you don't need virtual memory in Ubuntu).
Take note that the Ubuntu OS better to be installed on a primary partition, swap can be either on primary or extended partition.
4. The two Ubuntu partitions must be unformatted by Win7, if formatted, delete and recreate; moreover, you MUST assign letters to the two partitions but don't use it in Win7. In addition, all other partitions must also have be assigned a letter, including the system reserved partition M in my case.
5. Create the disk image. In command prompt, goto virtual box folder,
C:\Program Files\Oracle\VirtualBox in my case, run this:
VBoxManage internalcommands createrawvmdk -filename C:\rawdisk0.vmdk -rawdisk "\\.\PhysicalDrive0" -partitions 0,1,2,3,4,5,6
The image file 'disk0.vmdk' can be put anywhere you want with folder names not containing space. The actual number of partitions "0,1,2,3,4,5,6" depends on your harddisk. There must be no errors in running this command, if there's an error, delete the possibly wrongly created disk0.vmdk and disk0-pt.vmdk file and change parameters and retry.
6. Create a new virtual machine in VirtualBox, use this C:\disk0.vmdk as the disk and load Ubuntu ISO image into CD-DVD drive as shown below.
Make sure you select Linux -> Ubuntu (64 bit) when creating the VM and have no other warnings in VirtualBox manager on this VM.
7. Launch the created virtual machine, press F12 to boot into Ubuntu CD, perform normal install, make sure you install into the right partition and set correct swap area. For the boot loader I install into the Ubuntu partition, not MBR.
Here comes tricky! I often encounter the problem when either 1. Ubuntu installer cannot find any partition or 2. cannot write into the partition or 3. cannot write boot-loader. If you encounter so, try fiddling around by removing drive letters, reassigning drive letters (trying using only the 2 partitions instead of putting all 0,1,2,3,4,5,6), deleting VM in virtualBox completely and recreating disk0.vmdk and VM. You may even try running EasyBCD 2.2 or EaseUS Partition Master to make raw disk operations doable. That's the part which I suspect to be non-repeatable.
If the boot-loaders fail to install, you can still force to boot into Ubuntu using EasyBCD by adding a new entry and setting the drive to be the Ubuntu partition (i.e. X in my case) as shown below (it will be changed back to C by EasyBCD for some unknown reason):
8. The installation eventually complete successfully and the resultant copy of Ubuntu 64-bit can be run both inside Win7's virtualBox and upon machine reboot.
Unfortunately, you cannot run the same copy of Win7 both on its own or in Linux's virtualBox because too many hardware changes will require another windows activation.
Warning: DO NEVER reboot into the same copy of Win7 from Win7's virtualBox although you can do so in the boot option above. Doing so may result in file system corruption or rendering existing operating systems unbootable.
To prevent doing so, I strongly encourage you to set default system to Ubuntu in the boot option.
The good thing is that the Ubuntu in virtualBox is able to access windows partitions in read-only mode or full-access if they are unmounted, to unmount a volume E:, run in command prompt:
mountvol E:\ /D
Here are some of my food-for-thoughts:
1. Although the new restriction in Vista/Win7 forbids full access to \\.\PhysicalDrive0, it does allow full access to individual mounted but unlocked raw partitions, this installation procedure does not violate this rule as long as you don't install grub loader into MBR
2. Win7 has some harddisk I/O flush delay, updating MBR or partition boot sector takes a long time (say 20 minutes) unless you reboot Win7. That might possibly cause the tricky part I mentioned above.
3. In Win7, assigning a drive letter to a partition causes it to be mounted. Every time you make changes to your harddisk, i.e. mount/unmount some partitions, you must delete the entire VM in virtualBox manager together with the .vmdk files, otherwise, it seems not working.
For those people who are interested you may have a try and help me figure out a better/clearer way of doing so.:) Be very careful throughout, bear in mind that you may blow out your system and data anytime.:cool: