Page 1 of 1

Running linux as raw disk on windows host (both on same HD)

Posted: 5. Jan 2013, 11:53
by armyofda12mnkeys
Hello all,
I have Windows and Linux dual booted on same hard drive.
Im trying to get my Linux OS to show up in Windows VirtualBox as a Guest 'raw disk' OS so I can work in Windows but have option of working on the other OS at the same time.
I hit a snag and thought I'd ask community for some help.
All it says when I start the Virtual Machine is 'Missing Operating System' but some background on my hard drives might be useful to determine if i created the Virtual Machine correctly:

############
/dev/sda
just a 2nd hard drive on my laptop (IDE). I use it for storage and also put some windows programs here to save on disk space since my mSATA is only 256GB (so it has just a Program Files directory and Downloads directory).

############
/dev/sdb
My system SATA drive. I partitioned it for Dual Boot setup.
It has Windows installed first on it.
I choose to use the Windows Bootloader to handle the dual boot instead of Linux as I heard Windows Updates (and even antiviris programs) sometimes overwrite stuff in the MBR (and if linux bootloader stuff in the MBR it gets overwritten and causes issues).
I then installed Linux and used the windows program EasyBCD to setup the dual boot screen, (and setup Linux's bootloader to display for 0seconds (via GRUB_TIMEOUT=0) so if you choose Ubuntu from the Windows Bootloader, the linux bootloader GRUB won't ask you again to go into Ubuntu.

Anyway here is a description of each partition on that System hard drive:
$D:\Program Files\Oracle\VirtualBox>VBoxManage internalcommands listpartitions -rawdisk \\.\PhysicalDrive1

Number Type StartCHS EndCHS Size (MiB) Start (Sect)
1 0x07 0 /32 /33 1023/254/63 210000 2048
This is the Windows C: drive (210GB)
/dev/sdb1
###
2 0x0b 1023/254/63 1023/254/63 1000 430082048
This is a small shared FAT32 partition to be used (heard writes to NTFS are pretty good from linux but just thought i'd put this just in case) (1GB)
/dev/sd2
###
These next 4 linux partitions are on the extended partition of the drive:
5 0x83 1023/254/63 1023/254/63 500 432132096
This is a separate partition for the GRUB Boot Loader for Ubuntu (500MB)
/dev/sdb5

8 0x82 1023/254/63 1023/254/63 4000 433158144
This is the linux-swap (4GB)
/dev/sdb8

6 0x83 1023/254/63 1023/254/63 20000 441352192
This is the main linux partition (/ EXT4 20GB)
/dev/sdb6

7 0x83 1023/254/63 1023/254/63 8693 482314240
This is a separate partition for the home directory (/home EXT4 8.5GB)
/dev/sd7

I first turned on Virtualization options on my laptops BIOS (there were two options, one said VT-x and other think said Intel Virtualization).
I used the following command in windows cmd (and used 'Run as Administrator' as i see recommended) to try to create a raw disk for the Ubuntu partition to be used by Windows/VirtualBox:
VBoxManage internalcommands createrawvmdk -filename D:\dev\vm\VirtualBox\RawUbuntuLinux.vmdk -rawdisk \\.\PhysicalDrive1 -partitions 5,8,6,7
I thought maybe VirtualBox would need access to all those partitions so hence why i included all. I am not sure but dont think i need the -mbr option above, true?

Then i ran VirtualBox (via 'Run as Administrator') and added the existing raw disk partition...
One unusual thing is i see right then and there when i add it is it says '238GB' even though the linux partitions total are ~33GB (screenshot of VirtualBox settings:
I'll post the pic tomorrow since it won't allow me to add links as a new forum user here.
).
All it says when I start the Virtual Machine is 'Missing Operating System' and not sure how to fix so it just works.

Sorry for the long post but think i put all the data someone who knows VirtualBox/raw disk to analyze and help out how to get the raw disk Linux OS to show up in Windows (both which are on the same disk 'sdb' as mentioned in partition descriptions above).
Thanks for any advice and guidance,
Ari

EDIT:
Still haven't gotten to work...
I did try the -mbr option but wasn't very successful. this is what happened:

I logged into native linux partition and got the mbr from the boot partition sda5:
dd if=/dev/sdb5 of=/media/me/SHARED/linux-boot-partition-native.mbr bs=512 count=1
then moved the file to my Windows drive and logged into Windows and re-created the raw disk virtual machine with -mbr option.
VBoxManage internalcommands createrawvmdk -filename D:\dev\vm\VirtualBox\RawUbuntuLinux.vmdk -rawdisk \\.\PhysicalDrive1 -partitions 5,8,6,7 -mbr D:\dev\vm\VirtualBox\linux-boot-partition-native.mbr
Then added and ran the vm in Virtual Box.
I got to the Ubuntu Login GUI, very slow....But i signed in but got a total black screen. Wasnt sure if it had enough video ram so tried increasing Video Memory to 128MB but still black screen when restarted VM and tried logging into Ubuntu again.
Powered Off the VM and tried again and same happened.
Then forget what i did, but probably Powered Off the VM and tried again...
but it didn't go to the Ubuntu GUI login...
It went to a GRUB screen (not sure why since GRUB_TIMEOUT is set to 0 so Windows Bootloader can just pick Ubuntu and not have another screen to 'pick' Ubuntu)
Anyway, when i picked Ubuntu from the GRUB screen, it said something like 'Bug: Soft 20second CPU' and some sort of terminal shows up where i couldn't startx into GUI.

Got a bit scared (as since i use windows bootloader, the GRUB bootloader is setup to not even load) so I restarted computer to make sure I could still get into Ubuntu natively.
It gave the same GRUB screen there I got in the Windows VirtualBox vm. I choose the first option Ubuntu and went straight into the Ubuntu GUI Login screen that i normally expect.
I checked GRUB config to see why I got the GRUB loader (GRUB_TIMEOUT was set to 0 so assumed the VM rewrote it and was expecting to see another value?).
I checked via 'gksudo gedit /etc/default/grub' and see it was still 0 so not sure why I got the GRUB bootloader in first place. I ran 'sudo update-grub' so to make sure login comes up without GRUB.
Any idea why/how the VM would have messed up the bootloader (even if it wrote to it, why would /etc/default/grub still have timeout of 0 yet i got GRUB screen to show up)?

EDIT2:
I think I got it working!...
I think adding the -mbr was the correct thing to do...
Wonder if it was the slowness that really caused the issues that made me think VirtualBox rewrote my boot partition...
Maybe since it was so slow, I Powered Off, which made GRUB think the boot failed... I believe GRUB has a setting called something like GRUB_RECORDFAILSAFE_TIMEOUT (that when doesnt boot correctly, it presents a GRUB menu)...
I turned on the option 'Enable IO AIPC' on the VM's System->Motherboard setting accidentally (by turning on >1CPU dedicated to the vm in the System->Processor, it says it will turn on this feature too) and it seemed to fix the slowness/black screen (which in turn caused the GRUB menu to show up, by me powering off VM while it was trying to boot).
I went back to 1 CPU and still fast so think that one setting was only one that needed to be turned on...
Still kinda concerning it says 238GB for the vm when the partitions allocated are only 33GB ... wonder if anyone can confirm if the way I set it up is correct.

Thanks,
Ari