Trying to write a raw image on SDCard from Guest OS

Discussions related to using VirtualBox on Windows hosts.
Post Reply
obor
Posts: 2
Joined: 26. Jun 2017, 11:09

Trying to write a raw image on SDCard from Guest OS

Post by obor »

I am trying to write a raw image on a SDCARD from a guest OS UBUNTU.
But it does not work.

The SDCARD has been installed with a file named "sdcard.vmdk" created with VBoxManage following documentation instructions.
Virtualbox is run as administrator.
The raw image has two paritions (Vfat + ext4)
From Ubtuntu, I used 'dd' command to write the image on the vmdk

Code: Select all

sudo dd bs=512 count=10575839 if=raw_sd of=/dev/sdb
After some time, the command retrn with NO error.

However, I can see that the image has not been properly written.
It appears on the host and the Windows disk manager as two partitions VFAT 1Gb + Other 5GB (which is correct),
but with the file explorer, it appears as one drive E: with 6.03 Total (It should show only 1gb)
and from guest Ubuntu, the two partitions do correctly exist, but there are EMPTY, no data has been written.

Host Windows 8.1
Guest: Ubuntu 16.04

Has someone already succeed writing a raw image on SDcard from a guest OS ? Any suggestion to fix this ?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Trying to write a raw image on SDCard from Guest OS

Post by mpack »

Are you aware of the permissions issues surrounding sector level access to Windows drives? These issues have been around since the Vista era. XP was the last version of Windows which allow user level apps free access to such a low level feature.

viewtopic.php?f=6&t=38914#p175089

p.s. I hope you're aware that a raw disk write access is dangerous. A small slipup (e.g. not noticing that Windows reshuffled the drive numbers) can result in the loss of an entire host drive's worth of data.
obor
Posts: 2
Joined: 26. Jun 2017, 11:09

Re: Trying to write a raw image on SDCard from Guest OS

Post by obor »

Thanks mpack for answer.
From checking the link you provided, on my PC, the "attributes disk" command under "diskpart" says: "Read only : NO"
So it should be ok to write sectors on my SDCARD, afaiu...

You are right about raw disk access being dangerous. I don't want to change access right my host. It looks i'll need to get a dedicated PC linux to do the job..
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Trying to write a raw image on SDCard from Guest OS

Post by mpack »

Did you also offline the disk? I do not use raw disk for the safety reasons already mentioned, but I believe you must offline the disk, especially if it already has a filesystem on it that Windows might have mounted.
Post Reply