Howto: Boot existing Ubuntu Partition using Virtualbox inside Windows


Recommended Posts

This is a tutorial I wrote up and posted up on my blog.

I recently got Windows 7 and Ubuntu running in a dualboot. However, since I’m using more of Windows now I figured I should probably find a way to run Ubuntu inside my Windows. VM’s are great, but it’d be better if I can actually boot into my existing Ubuntu partition. So I searched the web and kept on finding tutorials on how to boot existing XP partitions inside Windows. So I decided to extrapolate from those tutorials and work my way through it. I’ll be writing how I did it here.

Before we begin, you should have a dual boot setup. I will NOT be showing you how to setup a dual boot, if you need help plenty of other guides out there.

Step 1: Creating a grub boot iso

The grub iso file will allow you to specify which partition to boot into.

1. Boot into Ubuntu

2. We create the folders and copy the necessary files to setup an isoRun the command:

cd; mkdir -p iso/boot/grub; cp /usr/lib/grub/*-pc/stage2_eltorito /boot/grub/menu.lst iso/boot/grub

3. Configure your ~/iso/boot/grub menu.lst file to boot your target OS (in this case Ubuntu). Remove the “savedefault” option from your target entry if it exists.

4. We now create the bootable iso fileRun the command:

cd; mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o grub.iso iso

5. Move the iso to a location that’ll be accessable by your Windows partition

Step 2: Creating the .vmdk file

This creates a file which tells Virtualbox what partition to actually load as the harddrive. Unfortunately, unlike VMWare Workstation, Virtualbox does not support a GUI interface for selecting RAW hard disks as the “virtual hard drive”.

1. Boot into Windows

2. cd into the directory you installed virtualbox

3. We find the partition number that needs to be mountedRun the command:

VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PhysicalDrive1

(where 1 is the number of the hard drive ubuntu is installed on. E.g. Master should be 0, you’re second hard-drive should be 1 etc…The output should be something like:

	  Number  Type   StartCHS	   EndCHS	  Size (MiB)  Start (Sect)
	  1	   0×07  0   /32 /33  1023/254/63		902023		 2048
	  5	   0×83  1023/254/63  1023/254/63		 49677   1847346543
	  6	   0×82  1023/254/63  1023/254/63		  2164   1949086188

In this example, my Ubuntu partition is number 5 and the swap is number 6

4. We now create the VMDK file with the given informationRun the command:

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

Step 3: Setup Virtualbox

Now everything should be ready to setup Virtualbox. Create a new virtual machine. Select the .vmdk file we just created as the hard drive and mount the grub.iso file we created at Step 1. If everything was successful Ubuntu should boot up nicely.

Edited by PCBEEF
  • Like 1
  • 1 month later...

Wonderful! I created an account on this site just to thank you!

I just have one small problem: Not able to run the guest at more than 800x600 resolution. I'll try my best to find out a way. If there isn't one, I'll just ignore it.

*Edit*

Nevermind, I just needed to install the VirtualBox guest add-ons and it worked!

Edited by Druglord
  • 2 weeks later...
  Druglord said:
Wonderful! I created an account on this site just to thank you!

I just have one small problem: Not able to run the guest at more than 800x600 resolution. I'll try my best to find out a way. If there isn't one, I'll just ignore it.

*Edit*

Nevermind, I just needed to install the VirtualBox guest add-ons and it worked!

I'm glad that my post helped you out :)

  • 2 years later...

Hi, first of all great and useful tutorial.

I just started to set up Windows7 and Ubuntu 11.10. I choked at the line


cd; mkdir -p iso/boot/grub; cp /usr/lib/grub/*-pc/stage2_eltorito /boot/grub/menu.lst iso/boot/grub
[/CODE]

You (or anyone) got any idea how this works in a recent version of ubuntu?

I'm completely new to unix so I got no idea. :s

regards, mouszeman

can you use this the other way round, i would like to use more ubuntu and less windows, but i want dual boot if needed. would be nice to use the current windows7 i have installed as virtualbox, under ubuntu. BTW if possible if i boot into windows (normal boot) would this do bad things?

  • 4 months later...

Brilliant!!! I spent enormous time solving this booting problem. This post helped finally! Many other posts on this issue point to the fake mbr way which I tried but got no luck. I guess the problem is all about helping virtualbox find the right boot record. The boot iso method is not the perfect way to do that since it depends on boot iso image but it's absolutely an ingenious method! Thank you very much!

  On 22/10/2011 at 21:38, mouszeman said:
Hi, first of all great and useful tutorial. I just started to set up Windows7 and Ubuntu 11.10. I choked at the line
 cd; mkdir -p iso/boot/grub; cp /usr/lib/grub/*-pc/stage2_eltorito /boot/grub/menu.lst iso/boot/grub [/CODE]

You (or anyone) got any idea how this works in a recent version of ubuntu? I'm completely new to unix so I got no idea. :s regards, mouszeman

In ubuntu 11.10 I use grub-mkrescue which can make rescue iso image for your system.

  • Make your own iso directory (e.g. /root/iso/boot/grub/) and copy /usr/lib/grub/i386-pc into it.
  • Copy /boot/grub/grub.cfg into /root/iso/boot/grub/
  • Run command: grub-mkrescue -o boot.iso /root/iso/ (I encountered an error about xorriso in the first time and "apt-get install xorriso" made it go away.)

After all those steps, you'll get your iso image. And then follow the other steps metioned by Jexel. Good luck!

  • 3 months later...
  On 03/03/2012 at 15:35, lniniaa said:

In ubuntu 11.10 I use grub-mkrescue which can make rescue iso image for your system.

  • Make your own iso directory (e.g. /root/iso/boot/grub/) and copy /usr/lib/grub/i386-pc into it.
  • Copy /boot/grub/grub.cfg into /root/iso/boot/grub/
  • Run command: grub-mkrescue -o boot.iso /root/iso/ (I encountered an error about xorriso in the first time and "apt-get install xorriso" made it go away.)

After all those steps, you'll get your iso image. And then follow the other steps metioned by Jexel. Good luck!

Hi, I didn?t check back for some time, but now I found your reply.

I did create the ISO the way you described, and managed to create the ISO.

After initial problems when I did not start Virtualbox as admin I got to the grub-screen.

Unfortunately, after that I got an error screen:

vbox_error.png

I found these two threads that seem related and also reference this current thread:

https://forums.virtualbox.org/viewtopic.php?f=6&t=38914#p175089

https://forums.virtualbox.org/viewtopic.php?f=6&t=49850

Regards, mouszeman

  • 2 months later...
  • 6 months later...

First: Excellent post!

Unfortunately, it didn't work for me: starting the VM gives it a black screen and then nothing happens.

Trying to run dualbooted Xubuntu 12.4.1 from within Windows 7 64bit.

After creating the grub files and ISO in Xubuntu as directed, I used these commands to create the VMDK:

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PhysicalDrive0

Number Type StartCHS EndCHS Size (MiB) Start (Sect)

1 0x07 0 /32 /33 153 /27 /2 1200 2048

2 0x07 153 /27 /3 1023/254/63 384738 2459648

5 0x83 1023/254/63 1023/254/63 72999 790405120

6 0x82 1023/254/63 1023/254/63 1999 939909120

3 0x07 1023/254/63 1023/254/63 16000 944003072

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands createrawvmdk -filename C:\ubuntu.vmdk -rawdisk \\.\PhysicalDrive0 -partitions 5,6

That actually created 2 files:

ubuntu.vmdk

ubuntu-pt.vmdk

however, it would only let me mount the first one.

UPDATE:

I had not correctly mounted the .iso file. When that's selected in the VM, it successfully boots from the iso and goes through the GRUB selection screen. However, then it says "file not found." (attached).

Any tips?

post-483760-0-44266700-1362720466.png

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • lol See... one is only 100% when it's by itself. I live for exceptions to the rule... our talk point was in reference in comparing Vista (not SP1/2) release vs. 7. Any OS will run stable once enough work has been put into it... hell, even Windows 95 had six versions before she was finally complete(d)... just about, what, six or seven months before 98 became available?
    • 3uTools 3.26.007 by Razvan Serea 3uTools is a powerful iOS management tool that allows users to efficiently handle their iPhone or iPad without relying on iTunes. It offers seamless data transfer, one-click backup and restore, firmware updates, and a built-in file explorer for easy access to system files. Users can also manage apps, contacts, and media, including photos, videos, and ringtones, all within a simple and intuitive interface. For optimization and maintenance, 3uTools provides battery health monitoring, real-time device information, and system cleanup tools. It also includes features like screen recording, video conversion, and iCloud backup management, making it an essential tool for iOS users looking for greater control over their devices. Key features of 3uTools: iOS device management App installation and removal Firmware downloads and updates Backup and restore functions Data transfer between iOS and PC Ringtone creation Custom wallpaper management Device flashing File system explorer Battery health monitoring Screen capture and recording Video and photo management iCloud backup support Flashing and restoring iOS without data loss 3uTools 3.26.007 changelog: Easy Flash supports iOS 26.0 flashing. Optimized Virtual Location. Fixed some known bugs. Download: 3uTools 3.26.007 | 186.0 MB (Freeware) Download: 3uTools 32-bit | 192.0 MB View: 3uTools Home Page | macOS | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • The development time of this Operating System will have competition with the development time of Star Citizen 😂
    • I saw the 300 in the image and thought it was the number of cores! 🤣
    • Threads is getting a feature Reddit has had for nearly a decade by David Uzondu Back in January, reverse engineer Alessandro Paluzzi (@alex193a) first uncovered that Threads was working on spoiler tags. Now, Meta CEO Mark Zuckerberg (@zuck) has made it official: the feature is in testing. It is a straightforward tool for hiding content, especially text, behind a block that you have to click to reveal, perfect for discussing the ending of your favorite show without ruining the experience for others. It is also, notably, a feature that Reddit has had since January 2017. https://www.threads.com/@zuck/post/DK-BydcJHkF For a platform aiming to be a town square for public discourse, not having a native way to handle spoilers is a small but noticeable handicap for communities focused on pop culture. In a press release, Meta told TechCrunch that popular shows like The Last of Us trended heavily on the app, which the company frames as a sign of a "growing community of entertainment and pop culture enthusiasts." The new feature also supports images so that you can hide shocking visuals or text-filled screenshots. From the images Meta shared, it seems to work just as Paluzzi uncovered months ago. Users with access to the test can highlight text in the composer, and a "mark spoiler" option will appear in a small menu. This method is purely button-based, unlike on Reddit, where users have the option of either using a similar editor button or manually typing out the markdown command >!like this!< to hide their text. This update does not exist in a vacuum. After several months of feeling incomplete, the platform has been getting features that users have actually been asking for. We have seen this with the recent DMs feature, also in testing, which finally gives people a way to have private chats without jumping over to other platforms like Instagram.
  • Recent Achievements

    • Explorer
      treker_ed went up a rank
      Explorer
    • Apprentice
      CHUNWEI went up a rank
      Apprentice
    • Veteran
      1337ish went up a rank
      Veteran
    • Rookie
      john.al went up a rank
      Rookie
    • Week One Done
      patrickft456 earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      659
    2. 2
      ATLien_0
      271
    3. 3
      +FloatingFatMan
      176
    4. 4
      Michael Scrip
      157
    5. 5
      Steven P.
      136
  • Tell a friend

    Love Neowin? Tell a friend!