Access SD Card on Linux from Windows using VirtualBox
In order to use SD Card from Host OS (Windows) on Guest OS (Linux) through Oracle VirtualBox, follow below steps.
Step 1 – Get the Device ID of your SD card reader.
On Command Line enter below command
wmic diskdrive list brief
It will show something like this
C:\Users\rizwan>wmic diskdrive list brief
Caption DeviceID Model Partitions Size
WDC WD5000BPKT-75PK4T0 \\.\PHYSICALDRIVE0 WDC WD5000BPKT-75PK4T0 3 500105249280
Micro SD SCSI Disk Device \\.\PHYSICALDRIVE1 Micro SD SCSI Disk Device 1 3964584960
So Device ID of SD Card is \\.\PHYSICALDRIVE1
Step 2 – Create VMDK file
Create the VMDK file which will link to the SD card, open a command windows as Administrator
C:\Users\rizwan>"C:\Program Files\Oracle\VirtualBox\VBoxManage" internalcommands createrawvmdk -filename "c:/Hard Disks/sdcard.vmdk" -rawdisk "\\.\PHYSICALDRIVE1"
Step 3 – Attach RAW Disk to VM
Next attach the raw disk VMDK to guest VM within the VirtualBox UI
- Ensure the Guest VM is not running.
- Ensure VirtualBox is not running
- Start VirtualBox by right-clicking on it and choosing “Run as administrator”
- Open the settings area for the guest VM
- Click on “Storage” in the toolbar
- Next to the controller click on the icon to “Add Hard Disk”
- Select “Choose existing disk”
- Navigate to the c:/Hard Disks/sdcard.vmdk and select it
- You should now be returned to the Storage tab and see your sdcard.vmdk in the list.
Step 4 – Start the VM
Depending on whether you have a GUI or not the SD card may or may not automatically mount. If you need to mount is manually it is simply exposed as another standard block device, so on my guest this was exposed as /dev/sdb.
Comments
Hello, thank you for this post. After the second step I received the following error message: VBoxManage.exe: error: VMDK: could not create new file c:/Hard Disks/sdcard.vmdk VBoxManage.exe: error: Error code VERR_PATH_NOT_FOUND at F:\tinderbox\win-5.0\src\VBox\Storage\VMDK.cpp(3415) in function int __cdecl vmdkCreateRawImage(struct VMDKIMAGE *,struct VBOXHDDRAW *const ,unsigned __int64) VBoxManage.exe: error: Cannot create the raw disk VMDK: VERR_PATH_NOT_FOUND VBoxManage.exe: error: The raw disk vmdk file was not created I am running command prompt as admin. Can you suggest how I can go about fixing this? Thank you in advance.
Verify "\\.\PHYSICALDRIVE1" exists by running command wmic diskdrive list brief and is it the one you are trying to mount or some other drive
I had the same error message and after I created the folder C:\Hard Disks the creation was successfull
If you used "-filename "c:/Hard Disks/sdcard.vmdk"" from example, then you probably do not have that directory, "Hard Disks." Changed the argument or make the directory
Hi, Thanks for the guide. I can see the SD cards partitions in the VM. But I cant write to it. I get the following error: The I/O cache encountered an error while updating data in medium "ahci-0-1" (rc=VERR_ACCESS_DENIED). Make sure there is enough free space on the disk and that the disk is working properly. Operation can be resumed afterwards. VM needs to be restarted after this... any ideas?
I am having similar issue. How did you fix it?
Check file system. May be file system is NTFS and Guest OS can only read NTFS and not write it.
Its a bit late but try to execute cmd as Admin
simply asure that the target path where you want to put your SD card image exists. That solved the problem for me.
It Did Work, Thanks.
Thank you for the terrific article
Thanks! It was very helpful.
i could successfully add sd card in storage but now virtual os not starting is there any other issues.my card had partition with pi images
The steps above work if SDCARD is attached permanently. Remove and re-attach use case does not work.
Many thanks for this advice I was basically checking all Yahoo to discover it!
I am a bit of newbie at this, but if anybody can help or has advice. I do the command prompt "c:/Hard Disks/sdcard.vmdk" and the message I get is "The system cannot find the path specified". Do you guys have any ideas what I am doing wrong? Thanks, Timothy
Thanks for sharing this. Just one addition - I had to remove drive letter to make the card accessible to VirtualBox.
Thank you for the post! This worked like a charm. I ran into an issue with respect to permissions since I wanted to format the SDHC using Linux. This could not be solved.
This article is the best one I have seen to solve this problem. Thank you very much!