Jump to content











Photo
* * * * * 1 votes

Booting VirtualBox with USB workaround

usb virtualbox grub4dos plop

Best Answer steve6375 , 26 February 2013 - 12:18 PM

Is the Win7 64-bit or special in any way? Did you try an plain MS Win7 32-bit ISO extracted to a USB drive?

How about creating a virtual HDD, mounting the HDD, copying the USB stick to the virtual HDD, dismounting it, then boot from it via VBox?

Go to the full post


  • Please log in to reply
288 replies to this topic

#76 steve6375

steve6375

    Platinum Member

  • Developer
  • 6656 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 19 June 2013 - 06:52 PM

Two more things:
1. Are you using the latest VirtualBox version (4.2.12)?
2. I've seen that some programs (WinSetupFromUSB and probably your program too) use WMI to get data about USB drives. It's good but the problem is that is restricted to Windows (WMI = Windows Management Interface). Other OS's have very poor WMI implementation. For example I tried to use WinSetupFromUSB in wine (Linux), it's not even showing the interface before crashing.
I'm trying to find ways that can be used in any OS so I can port my application (instead of rewriting the entire code). But that's not so easy...

Yes, 4.2.12

No, I don't use WMI. RMPrepUSB does work under WINE (mostly), but some explorer functions don't work properly. 



#77 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 19 June 2013 - 09:54 PM

Btw, should I detach usb.vmdk, rebuild it and attach it again (kind of slow but less potential problems) or should I just change the number of the \\.\PhysicalDrive inside the file (faster but rare problems may appear)?

 

 

One of my vm's has a USB.vmdk+hdd1+hdd2 as storage, when I used your app and added first USB drive, it added USB1 to the other 3 drives and then wouldn't boot due to IDE drive config issues. The addition also meant that the VM that previously worked fine in VM Manager now doesn't (until I delete the extra added drive).

 

I think it was one of those "rare problems"; VMS couldn't read or write from/to the vmdk and tried to create a new one. Since both they were for the same drive it's obvious why VB didn't work.

The reason why it couldn't read or write - I can't tell without looking in the file and without knowing the security permissions to read/write in the file. If it's a reading bug in my code the file would help me fix it...

Anyway I modified VMS to try to detach and erase the first vmdk before adding the second.



#78 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 20 June 2013 - 01:31 AM

The First USB drive list is listing drives F and H, but F is my internal SSD HDD not a USB drive.

 

 

Anyway I was thinking - why restricting the user's choice to only USB drives... Maybe some day he will need to add an internal FDD/HDD/SDD to the VM in the same way...
What do you think...?

Another thing: maybe we can find a way to improve the vmdk file by changing its internal parameters. For example "cylinders": I wonder what it will change in the VM (Grub4Dos) if we'll use the real number not 16383. Or we can try to find a correlation between bios* in vmdk and the geometric parameters of the real drive so Grub4Dos would correctly access the entire drive...



#79 steve6375

steve6375

    Platinum Member

  • Developer
  • 6656 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 20 June 2013 - 08:53 AM

In my case, I have the swap file on the 2nd internal HDD, dismounting that would not be a good idea!

 

To what problem are you referring in grub4dos exactly?



#80 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 20 June 2013 - 09:25 AM

In my case, I have the swap file on the 2nd internal HDD, dismounting that would not be a good idea!

 

 

Right :D, but perhaps some other users will not have the swap file there and they will want to add it to the VM entry.
VMS already eliminates the system drive from the list but how can you verify that, for some reason, it's dangerous to dismount other internal drives..?
You can't; but that's no reason not to let the user choose. After all, he should know that he added a swap file on that drive.
Worst case scenario: the user doesn't know there is a swap file there, adds the drive to the VM entry, it is dismounted, the OS locks or reboots, the user (hopefully will not blame my application :D and) learns that it's dangerous to use that drive.   :rolleyes: 
But this will not happen so often...

 

To what problem are you referring in grub4dos exactly?

 

 

The one from 137 GB detection, when it's tested in VirtualBox (we concluded that it was from that "bioscylinders=1024")...
But I could be wrong...



#81 steve6375

steve6375

    Platinum Member

  • Developer
  • 6656 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 20 June 2013 - 09:48 AM

I have no issues accessing at least up to 900GB on my 2TB USB drive with either QEMU or VBox?

 

P.S. The VM in VBOX that I use has one USB.vmdk+2 vritual HDDs. When I changed over the USB drive from a flash drive to my 2TB USB HDD and re-ran the same VM using your VMStarter app, it complained about the drive being the wrong ID so I cancelled it. This seems to have removed all the attached storage from the VM and when I tried to add the USB.vmdk back in VBox manager did not like it and I had to re-create and re-attach a new vmdk.

 

I didn't quite understand why you need to check IDs, etc.  I just create a USB.vmdk for my largest USb drive (2TB) and then I can use any device up to 2TB as my USB device as long as it is physical device 2.  Why can't your app just determine what the physical device number is and the size of the device and then change the vmdk paramters accordingly? 



#82 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 20 June 2013 - 10:48 AM

I have no issues accessing at least up to 900GB on my 2TB USB drive with either QEMU or VBox?

 

 

Ok, if there no issue then it's fine :D

P.S. The VM in VBOX that I use has one USB.vmdk+2 vritual HDDs. When I changed over the USB drive from a flash drive to my 2TB USB HDD and re-ran the same VM using your VMStarter app, it complained about the drive being the wrong ID so I cancelled it. This seems to have removed all the attached storage from the VM and when I tried to add the USB.vmdk back in VBox manager did not like it and I had to re-create and re-attach a new vmdk.

 

I didn't quite understand why you need to check IDs, etc.  I just create a USB.vmdk for my largest USb drive (2TB) and then I can use any device up to 2TB as my USB device as long as it is physical device 2.  Why can't your app just determine what the physical device number is and the size of the device and then change the vmdk paramters accordingly? 

 

 

Why do I need to check the drive IDs: because, like I said a few days ago, there can be other drives added/removed that will change its drive number. The capacity is not so good to differentiate one drive from another, ID is.
But you don't need to change the USB drive ID every time you want to boot with another USB drive. Just simply create another VM entry and set it for the other USB drive.

For example I have 2 drives. My VM entries look like this:

VirtualBox test with flash
VirtualBox Test with HDD
Qemu test with flash
Qemu test with HDD

For the 2 VB ones I used the same VM.
This way all I have to do is select and click on Start... :D
But don't use the Beta 1 version for this, wait Beta 2.

In a previous post I said that the problem is already somehow solved (in Beta 2), but, to be 100% solved I need to know why VMS couldn't use your usb.vmdk file. So I need this file and perhaps the vbox file as well.
If you can't send them to me all I can implement is the automatic remove of the usb.vmdk. After that it will create another vmdk in an known format and modify it every time you start another VM entry (with different USB drive).



#83 steve6375

steve6375

    Platinum Member

  • Developer
  • 6656 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 20 June 2013 - 11:32 AM

I still don't understand about this drive number ID thing?

 

I have about 20+ different USB drives and I use them all with the same VM - I certainly don't want to create a VM for each of them! Especially as I have the same virtual HDDs attached to all of them.

I don't use a different vmdk for all of my USB drives. I just use one vmdk and one VM.

The only thing is that I have to make sure that when I connect a USB drive, it is connected as PhysicalDevice2  (as 0 and 1 and my internal HDDs). My vmdk is  called USBPort2.vmdk and was made using the 2TB USB drive. I can plug any USB drive into my system and any of them will work with the same .vbox VM which has the USBPort2.vmdk storage attached.

 

So the only thing needed is to select the Physical Device number in the existing vmdk

This line in the vmdk seems to describe the size in sectors and drive number

# Extent description
RW 3906963456 FLAT "\\.\PhysicalDrive2" 0

So I would just want to select  a VM and select a USB drive (or two).

 

VM      18687c05-e790-4f1c-846b-dfcf686da801

Drive   H: Lexar Jumpdrive

 

Your app would then look at the .vbox file, find the attached devices section,  find the one which refers to the vmdk(s), change the vmdk to point to the correct PhysicalDevice number for the selected device (and poss. change size entry) and then run the VM.

 

So to launch from your app, I would select a VM and select a drive and click Start.

 

I am afraid I cannot send you the vmdk and vbox that I had the problems with as these have had to be deleted and re-created and I had to delete the snapshot and VBox Manager seems to object to me creating a snapshot now!



#84 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 20 June 2013 - 11:56 AM

It seems that you don't understand that the problem was created by that usb.vmdk (with an unkown format) and not by the "ID check"...

The Beta 1 version ALREADY knows how to modify the vmdk file (like I said a few hours ago), it didn't know how to modify that usb.vmdk because it had that unusual format.

THAT WAS THE PROBLEM.

 

AND I haven't said to create 20 VM's in VirtualBox, I said to create multiple VM entries in my application and use only  one VM from VirtualBox! Which is (very) different.



#85 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 20 June 2013 - 11:58 AM

1.0 Beta 2 version:

Changes:

BugFix: name of the VM entry was loaded from the configuration file only if it was minimun 2 chars long. Now it can be 1 as well.
Improvement/BugFix: it detaches and tries to remove the vmdk files which can't be read and/or write (before adding another).
Improvement: in Add/Edit window, the user can directly see and choose from drives+volume(s) list. The drive ID was removed from interface because usually there is no need to be manually inputed/edited but it was kept internally and in the configuration file.



#86 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 20 June 2013 - 12:15 PM

ALL you have to do know is to plugin a USB drive, create a VM entry in my program for it, unplug it, plug in other USB drive, create a VM entry for it in my program using the same VM from VirtualBox (or a different one if you want, but it is not necessary) and so on.
This way, you could have those USB drives in ANY COMBINATION on your computer, VMS will know to boot from the one that you want.
For example, on my computer, if I plug in the flash first and the HDD second, or the HDD first and the flash second, it will still now how to start each one when I start "VirtualBox test with flash" and "VirtualBox test with HDD".



#87 steve6375

steve6375

    Platinum Member

  • Developer
  • 6656 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 20 June 2013 - 12:27 PM

ALL you have to do know is to plugin a USB drive, create a VM entry in my program for it, unplug it, plug in other USB drive, create a VM entry for it in my program using the same VM from VirtualBox (or a different one if you want, but it is not necessary) and so on.
This way, you could have those USB drives in ANY COMBINATION on your computer, VMS will know to boot from the one that you want.
For example, on my computer, if I plug in the flash first and the HDD second, or the HDD first and the flash second, it will still now how to start each one when I start "VirtualBox test with flash" and "VirtualBox test with HDD".

So if I plug in another different flash drive, I have to create another entry in your app? If I have 20 USB drives  (which I do) then I need to create 20 entries? I often switch between USB drives and install and test colleagues USB drives too.

 

I would rather have an interface that is just:

 

Emulator = QEMU/VBox

VM = testVM

Attach Boot USB 1 = Physical Drive 2  H: Lexar Jumpdrive  32GB

Attach Boot USB 2 = Physical Drive 3  J: WD Passport 2TB

 

I then pick a VM, pick a USB drive (or 2) and click Start. There can be a 'Settings' tab to set exe paths, wait time, window size and CPU priority.



#88 steve6375

steve6375

    Platinum Member

  • Developer
  • 6656 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 20 June 2013 - 12:44 PM

I made the vmdk using the attached cmd script.

 

Attached Files



#89 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 20 June 2013 - 01:00 PM

So if I plug in another different flash drive, I have to create another entry in your app? If I have 20 USB drives  (which I do) then I need to create 20 entries? I often switch between USB drives and install and test colleagues USB drives too.

 

 

I understand.
But the good thing is you have to create that VM entry in VMS only ONCE for that USB drive. And it's VERY EASY to create or modify, you just have to get use to it a little.
If you plug in that drive any time later it can be booted in VB by scrolling to that VM entry (if you used a suggestive name) in VMS and click on start.

Your case it's a special case. Not everyone has/uses so many USB drives. As you probably already know a programmer has to design his program to be useful for the majority of the users. Unfortunately this way he will lose the "special cases" :(
I will think on a way to make you happy too :D but you realize that it's not so easy for me.
 

I would rather have an interface that is just:

 

Emulator = QEMU/VBox

VM = testVM

Attach Boot USB 1 = Physical Drive 2  H: Lexar Jumpdrive  32GB

Attach Boot USB 2 = Physical Drive 3  J: WD Passport 2TB

 

I then pick a VM, pick a USB drive (or 2) and click Start. There can be a 'Settings' tab to set exe paths, wait time, window size and CPU priority.

 

This way you will still have to change the USB drive in settings each time you use a new USB drive (or 2). But, if you're ok with this, what's stopping you to create a single "universal" VM entry in VMS and editing only the drive(s) (each time you use another Usb drive)? It's not much to modify and you can get use to it fast...



#90 steve6375

steve6375

    Platinum Member

  • Developer
  • 6656 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 20 June 2013 - 01:26 PM

I actually use your original non-GUI VMBox app all the time. I just have to make sure that PhysicalDevice 2 is the USB I want to boot to. Sometimes this means manually dismounting and unplugging any USB drives already connected and then plugging in the USB drive I want to boot to so it is Device 2.

Maybe I will write an app or cmd script which will just allow me to select any USB drive connected to my system and change the PhysicalDevice entry in the vmdk file before calling your app...



#91 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 20 June 2013 - 03:15 PM

I'm glad that the non-GUI version helps you but still you have to work to place them in the right order...

What do you think of this, is it a little better? Look in Add/Edit > 1st/2nd Drive...

 

LE: link removed, you can find a better version in the next posts.



#92 steve6375

steve6375

    Platinum Member

  • Developer
  • 6656 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 20 June 2013 - 06:21 PM

Thanks for the change, it is now much more useful, however I am sorry but there is a problem with it.

 

  1. Make  new VM with 1 virtual HDD
  2. Use new VMStart to add one USB flash drive and Start - Storage order is USB, then HDD and boots from USB drive - OK.
  3. Now Quit and edit the VMStart config and change the First drive to add  to a different USB drive and Start - now order is  Virtual HDD and then USB vmdk and it boots from the virtual HDD.


#93 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 21 June 2013 - 05:48 AM

You don't have to be sorry. Thank you for helping in making VMS better.

Strange, on my computer doesn't do that...
Perhaps it's from the OS difference, who knows...
Could you please send me the vbox file (from all 3 steps) and the vmdk (last 2 steps)? Thank you.

Now I'm working on adding the Vendor and the Product ID of the drive...



#94 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 21 June 2013 - 06:05 AM

1.0 Beta 3 version

Changes:

Improvement: In Add/Edit entry >> First/Second drive it shows Vendor ID, Product ID, Size, Volume(s).

 

Attached File  Virtual machine starter Gui.zip   410.75KB   237 downloads



#95 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 21 June 2013 - 03:06 PM

Ok then, let me ask you a question: when you created the VM, have you set the virtual HDD from the VM to the next "position" (Primary slave / Secondary master / Secondary slave on IDE or SATA > 0)?
The idea is to keep a "place" for the drive added by VMS, because it will boot from the first HDD in that list.

Why haven't I asked until now? Because you said "2. ...Storage order is USB, then HDD...". This would of been impossible with no "place" before the virtual HDD.



#96 steve6375

steve6375

    Platinum Member

  • Developer
  • 6656 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 21 June 2013 - 06:54 PM

Hi David,

 

Even if I set up 

Primary IDE Master = (empty)

Primary IDE Slave= vhdd

 

then after using Edit in VMS to change USB drives a few times, it all starts to go wrong and boots from the vhdd after 3 or 4 swaps.

 

If I use

 

SATA = vhdd

 

Then VMS works fine.



#97 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 21 June 2013 - 07:05 PM

Ok, thanks, I'll check what's wrong with the code for IDE...



#98 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 21 June 2013 - 08:38 PM

Here is a debug version. If it can't access a vmdk file, it will stop and display a message so you can make a backup copy in another location and send it to me.

 

LE: link removed, better version in the next posts.



#99 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 22 June 2013 - 03:34 AM

Well, I installed Windows 7 x64.
First, VMS starts fine the VirtualBox VM right after Windows loads. No need to start VirtualBox.exe first.
Second, in both OS's I keep trying to make VMS fail but without "luck" (so far)... But I will try more :D

 

LE: I'm working on a new way to read from the vbox file, hopefully it will solve (at least some of) the problems...



#100 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 23 June 2013 - 08:31 AM

1.0 Beta 4 version:

Changes:

BugFix + Improvement: the code for accessing the VirtualBox files (Virtualbox.xml and the *.vbox) has been completely rewritten. The main golds were to avoid using "vboxmanage.exe" (at all), increase the speed and the accuracy.
Improvement: the error messages are giving now more details about the problem so the user could fix it much easier.
Improvement: now it remembers the position and the size of the main window.

 

LE: link removed, better version in the next posts.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users