I’ve trying to get my Raspberry Pi working with a touchscreen (eGalax Touch).
This blog post has been an incredible help, but I stumbled at the very last hurdle – modifying the contents of the SD card.
You see, my compile system (Ubuntu 13.04) was in a virtual machine (VM) – VirtualBox running on Windows 7.
Windows 7 doesn’t know how to read the various linux filesystems, so they’re invisible, which means I needed to access to the whole, raw disk directly from the VM.
Here’s a step-by-step guide to directly mounting raw SD card in your virtual machine, so you can edit it.
- Get the DeviceID for you SD Card reader
- Navigate to the VirtualBox directory
- Create the link file to the SD card
- Connect the VM to the SD card using the link
Open a command window as an administrator. (Press Start, type cmd, right click on cmd.exe in the list, and choose “Run as administrator”)
type
wmic diskdrive list brief
and if your system is anything like mine you’ll get something like this:
C:\Users\Sandy Scott>wmic diskdrive list brief Caption DeviceID Model Partitions Size WDC WD7500BPKT-75PK4T0 \\.\PHYSICALDRIVE0 WDC WD7500BPKT-75PK4T0 3 750153761280 O2Micro SD SCSI Disk Device \\.\PHYSICALDRIVE1 O2Micro SD SCSI Disk Device 1 3964584960
The top item is the main hard drive, the lower one is the SD card.
The bit we’re interested in is the DeviceID, in this case \\.\PHYSICALDRIVE1
Next thing you’ll need to find is the installation directory for VirtualBox. This is usually C:\Program Files\Oracle\VirtualBox\. You’ll know it’s the right one if it has lots of files starting with VBox in it.
Go there by entering this command
cd C:\Program Files\Oracle\VirtualBox
VBoxManage internalcommands createrawvmdk -filename "%USERPROFILE%/Desktop/sdcard.vmdk" -rawdisk "\\.\PHYSICALDRIVE1"
The file you’ve just created (sdcard.vmdk, on your Desktop) is a special link that lets a virtual machine access the SD card.
Now, open VirtualBox as Administrator, and open the Settings for your virtual machine. Go to Storage -> Controller: SATA -> (right click) Add Hard Disk -> Choose Existing Disk and open the file you just created.
Fire up the VM and you should be able to access the SD card in all it’s glory!
hi Sandy,
thanks for your post it helped me a lot.
I’ve experienced some issues as my %HOMEPATH% was empty and generated errors during the sdcard.vmdk creation process.
so I just skipped it and created the file in the virtualbox directory π
cheers
Eric
Glad it helped – seems unlucky that you’ve encountered an issue with the environment variable at the same time. With hindsight %USERPROFILE% might have been a safer choice. (Post now edited)
What exactly did you do to solve that problem cause I’m having same issues here. Thanks for your help
Hey Sandy,
I tried the method you suggested but apparently I get an error while creating the .vmdk file.
I used the command as mentioned above, but the error said that “Could not access the rawdisk ‘\\.\PHYSICALDRIVE1”. so the file was not created. Do you have any idea why this could have happened?
Thanks for the help
Aakar
The exact error is :
“Cannot open the rawdisk ‘ \\.\PHYSICALDRIVE1’ : VERR_ACCESS_DENIED”
Off the top of my head
Great. The “as Administrator” did it…
Pingback: Setup cjdns on Raspberry Pi | SplatCrashBang
You are genius.
Thank you for the brilliant guide.
Most useful.
I would like to add though that certainly on Windows 8.1 you will need to run the Virtual Box manager as administrator or you will get an error access denied when you attempt to add the drive to your virtual machine.
Awesome also on Windows 10
thanks
I managed to create the image but now when i create files on the SD card from Windows (host) then Linux cannot see the files created from Windows and vice versa.
This sounds like an issue with the file system you are using – Windows and Linux arrange files on an SD card (or hard drive) in completely different ways, so can’t read each other’s data.
This is the wrong process to do what you want – I would use the shared folders feature for this, which lets Virtualbox handle the translation between the two systems. Instructions on how to do that are here: https://www.virtualbox.org/manual/ch04.html#sharedfolders
The only reason to do the complicated process I’ve described above is for the times when that translation won’t work, because you need to access the really low-level data on the card, and windows either can’t or won’t let you!
Dude, YOU helped me a LOT !
Actually I’m also trying to install the -same- touch screen to my RPi, with the same blog post you mentioned and also using a VM..!
Cheers
Hi,
thanks for the help. Is it possible that you do not only have to modify the VM as administrator but actually can run it only as admin afterwards?
Thanks for the help,
Michael
That’s right, you have to run VirtualBox as Administrator whenever you want to access an SD card in this way. Not great, but understandable considering what’s going on under the hood.
You must be genius!
Thank you very much.
Hi, I did all you said. I’m in the same trouble, but when starting my guest OS is aborted and doesnt work, Until I delete the SATA it finally boots
It might be trying to boot from your SD card rather than the guest OS system drive. I’m not very familiar with the subtleties controlling the boot sequence in Virtualbox, but you could try hitting F12 just after the machine starts and see if trying one of the options in that list lets you boot the main system.
Hi !
My Virtual machine crasches a few sec and message is.
The I/O cache encountered an error while updating data in medium
“ahci-0-1” (rc=verr_access_denied) Make sure theres is enough free space on the disk and that the disk is working properly.
Operation can be resumed afterwards.
Can u please adwise
Brgds Patrik
I’m sorry, I’ve never seen an error like that before!
Im having the exactly same problem of Patrick above.
Im using windows 10 on virtualbox.
Any changes made on the sd card crashes the vm right after.
Looks like the virtualbox donΒ΄t mount the sdcard on write mode.
You guys have any ideas?
thanks
Unfortunately, I have exactly the same problem as Patrick and jeferson -> everything went well, vmdk file created, VM launched as administrator, but right after logon to guest OS (also Windows 10), I am getting that error…
This page https://disqus.com/home/discussion/thomasdalla/bootez_sur_votre_cle_usb_avec_virtualbox_4/ seems to suggest that switching to IDE rather than SATA may help
Go to the storage option of the VB
Right click on your guest OS -> Settings -> Storage -> Controller:SATA
on the right hand side you will see a check box for use Host I/O Cache, if it is unchecked check it save and restart. should work !
Thanks, that solved my issue, I’m now able to dd an image to my SD Card without crashing. π
Thanks a lot for your tip, it helped me solve this problem!
I guess the cache isn’t supported trough the hardlink that was created by the Windows (as host). But using the Host cache bypasses the Linux OS cache and make it work.
Having the same issue as Patrik, Windows 7, virtual box running ubuntu 14. It seams intermittent, in that is happens at different stages each time I reboot and try manipulating the card.
Hi Sandy,
thanks for this helpful article. It works for me, a little different though: When I get to add the created link to the VM, it is rejected, when trying to add it to the existing SATA controller. If I add it one level higher though, (“Massenspeicher”, would be something like “mass storage”) it is accepted and then added to the existing SATA controller. I’m on VBox 4.3.30.
Tchelovek
Thank you for the update! I’ll check this on my own system with a newer version of VBox and update if necessary
AWESOME!!! Thanks Sandy….!
Pingback: VirtualBox vo windows 10 a SD karta raspbian - zwieratkov blog
Thanks. Have you managed to interface the screen to the RPI? I am trying to interface the Kedei V5 screen to RPI3 B. I am writing new kernel since the one provided is old and the GPIOs on RPI are not working.
Thanks for the help π
It was a long time ago now, but yes, I did get it working. It was mainly by following these detailed instructions , all I had to work out was giving a VM (rather than the bare-metal compile system assumed by the article) write access to an SD card.
I followed your instructions, but after creating vmdk file, I have to open the VirtualBox as administrator which is causing problem.
If I open the Virtual Box as Administrator, I did not find any guest OS in the Virtual Box, looks like my guest OS is available only without administrator. How to overcome this problem?
I’m not sure, but it could be something to do with VirtualBox using the administrator windows profile, rather than your own. I’d suggest you try this:
Any way to get optimal performance? Transfer speeds are around 4mbps while on the host I get 30mbps+. Using a class 10 card.
I haven’t investigated speed. I was happy to get it working!
Am I able to partition the SD card on Centos in VirtualBox ?
I would have thought so, as the pass-through link is created to the physical device. Give it a try and see how it goes!
Thank you for sharing! All of them must to perform with “Run as Administrator”
Been trying to configure zero w for headless running kali but so far have been hitting walls to configure Wi-Fi & ssh & running gadget mode has been a waste of time it would seem as it still doesn’t appear. So either mounting this way or via live usb the way to go