Page 1 of 1
Access SD Card on Ubuntu 18.04 LTS VM
Posted: 12. Jun 2022, 16:34
by rambo2_981
I've an Ubuntu 18.04 LTS VM using Virtualbox 6.1.34 on Windows 11. I'm trying to access an SD Card from Ubuntu and don't see it. I can get the DeviceID from Windows PowerShell (it's "\\.\PHYSICALDRIVE1"). How do I get access to this drive from Ubuntu? When I remove the SD Card, I see nothing in /var/log/syslog (and when I insert it, I also see nothing). Is there Virtualbox documentation somewhere, or can someone tell me what needs to be done so I can access (partition/format/read/write) the SD Card from an Ubuntu VM? Thank you.
Re: Access SD Card on Ubuntu 18.04 LTS VM
Posted: 12. Jun 2022, 17:17
by scottgus1
Re: Access SD Card on Ubuntu 18.04 LTS VM
Posted: 12. Jun 2022, 17:20
by rambo2_981
Okay for anyone else looking for notes on how to do this, this is how I got it to work using a pre-formatted SD Card (maybe there's a better way?):
Get SD Card recognized on Virtualbox Ubuntu VM:
Note: do this with the VM powered off
1. Get the DeviceID on Windows using PowerShell (or run Cmd as Admin):
PS C:\Program Files\Oracle\VirtualBox>GET-WMIOBJECT win32_diskdrive
Partitions : 2
DeviceID : \\.\PHYSICALDRIVE1
Model : SDXC Card
Size : 63893975040
Caption : SDXC Card
Partitions : 5
DeviceID : \\.\PHYSICALDRIVE0
Model : NVMe PC SN810 NVMe WDC 1024GB
Size : 1024203640320
Caption : NVMe PC SN810 NVMe WDC 1024GB
or use wmic:
PS C:\Program Files\Oracle\VirtualBox> wmic diskdrive list brief
Caption DeviceID Model Partitions Size
SDXC Card \\.\PHYSICALDRIVE1 SDXC Card 2 63893975040
NVMe PC SN810 NVMe WDC 1024GB \\.\PHYSICALDRIVE0 NVMe PC SN810 NVMe WDC 1024GB 5 1024203640320
2. Determine the DeviceID of the SD Card (look at the descriptions): in my case it's \\.\PHYSICALDRIVE1
3. Enable the disk drive in Virtualbox with (run command window as Admin):
.\VBoxManage.exe internalcommands createrawvmdk -filename C:\sdcard.vmdk -rawdisk \\.\PHYSICALDRIVE1
Which should output:
RAW host disk access VMDK file C:\sdcard.vmdk created successfully.
4. Run Virtualbox GUI as Admin, and:
Select Settings/Storage for VM
Select Controller: SATA
Check Use Host I/O Cache
Select Adds Hard Disk next to Controller:SATA
Select Add
Navigate to the C:\sdcard.vmdk and select that
Select Choose, then OK
5. Start the VM and the SD Card should be at /dev/sdb with each partition a separate device; e.g.:
Verify with:
$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 59.5 GiB, 63900221440 bytes, 124805120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x8d98be2e
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 206847 204800 100M e W95 FAT16 (LBA)
/dev/sdb2 206848 121038847 120832000 57.6G 83 Linux
Re: Access SD Card on Ubuntu 18.04 LTS VM
Posted: 12. Jun 2022, 17:32
by scottgus1
Looks like you used Raw Disk Access. That's a good solution, too, though you have to be careful that the physical drive number you use in the "internalcommands" doesn't change. It will point at the designated drive number regardless of if the host renumbers its drives, and data loss can result. There's a warning about this in the manual, just something to keep aware of when doing Raw Disk.
Re: Access SD Card on Ubuntu 18.04 LTS VM
Posted: 12. Jun 2022, 17:34
by rambo2_981
Thanks, Scott.