Sunday, April 03, 2016

VirtualBox access to SD card through Windows Host

The problem is how to set the wireless details for a headless Raspberry Pi, and so the challenge is how to change a file on an SD card formatted as Ext4 for Linux when Windows doesn't recognise it.

As I'm already running a Centos 7 image of Linux in VirtualBox, one solution is to access the whole, raw SD card direct from that VM.


And this post details exactly how to do this, whilst the VirtualBox man pages can be found here.



1. Get the DeviceID for your SD card reader

As administrator, open a command prompt and type:

wmic diskdrive list brief



2. Create an image representing the SD card

As administrator, navigate create a link file to the SD card on the desktop:

cd c:\Program Files\Oracle\VirtualBox

VBoxManage.exe internalcommands createrawvmdk -filename "%USERPROFILE%/Documents/sdcard.vmdk" -rawdisk "\\.\PHYSICALDRIVE1"


3. Connect the VM to the SD card using the link

Open VirtualBox as administrator, and open the Settings for the VM. Go to Storage -> Controller: SATA -> (right click) Add Hard Disk -> Choose Existing Disk and open the file that was created in Documents (note VM must be powered off).
.

4. Access...

Start the VM and mount the card using the GUI. The card should now be accessible in native Ext4 format...