Cannot write to SD raw disk

Discussions related to using VirtualBox on Windows hosts.
Post Reply
yournickname
Posts: 3
Joined: 7. Apr 2015, 03:57

Cannot write to SD raw disk

Post by yournickname »

Summary:
I am attempting to write a image onto a SD card for a Raspberry Pi type platform. I am using a Windows 7 host with a Ubuntu 10.04 guest on a laptop with a built in SD card reader. Currently I can access and read files from the SD card. The guest OS will also allow me to modify and save files to the SD card as well (i am testing with short text files). Everything looks fine from the guest OS until I shut the VM down. Upon re-entering the VM, or checking with the host OS, any modifications to the SD card are lost or never happened. If someone can help me fix this or understand why it is happening I would greatly appreciate it. I am fairly new to both Ubuntu and virtual box so more detailed answers would help me greatly. Thank you in advance.

Details:
Version selection is based upon compatibility with a program I will be using for this project.
VBox Version: 3.1.8 r61349 w/ guest additions
Windows 7 Host / Ubuntu 10.04 LTS Guest. Both 64Bit
SD Card: Fat32 file structure (new card, single small text file)


NOTE: Since I am not allowed to post urls i have added them as a text file and referenced them as [x].
I am accessing the SD card as a raw disk. I am doing this due to the fact that I must have full access to the card in order to image it, and therefore cannot use a shared folder setup. The SD card does not show up as a USB device when installed. I have setup my raw disk access as explained in [1]. In order to automatically mount the device and provide me with permissions to write to it i have modified the /etc/fstab file as described in [2] . With this setup I can see, and read a text file originally written by the Host OS. It also appears that I can modify and create files on the SD card when looking at the guest OS. All changes are saved in the guest OS, and no errors are thrown. I can log out of my ubuntu user account and relog, and the changes are still there. After powering down the guest OS all changes are lost however. The host OS sees no change in the card, and re-entering the Ubuntu guest shows the original condition of the SD card. From this it seems to me I have a configuration error with my raw disk setup. I have attached my .vmdk file. I have modified the line ddb.adapterType="sata" from "ide" as reccommended in [3] with the hopes it would help. I also tried to configure the raw disk as a IDE drive instead of SATA in the VM settings, but this threw large numbers of errors ~22 seconds after attempting to modify a file. The root of the errors seemed to be "entity not found" which I assume means it could not locate the SD card on the IDE buss.

I am having difficulties solving this problem as searches seem to bring up either permission errors or hard disk failures. I am not ruling out a permission error altogether, however i believe Ubuntu would provide me with some type of warning if this were the case, and it seems I have solved the permission issues that appear in my searches. The SD card should not have a problem as it is new, and I have no problems with it using the Win7 host. Again any help is greatly appreciated. If any more information would help solve this problem please let me know what I can provide.

Thank you
Attachments
urls.txt
URL reference
(262 Bytes) Downloaded 28 times
sdcard.txt
SD Raw Disk config file (vmdk extension normally)
(639 Bytes) Downloaded 35 times
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Cannot write to SD raw disk

Post by mpack »

Try reading this past discussion :-

Enabling raw access to Win7 / Win2k8 disks.
viewtopic.php?f=6&t=38914#p175089
yournickname
Posts: 3
Joined: 7. Apr 2015, 03:57

Re: Cannot write to SD raw disk

Post by yournickname »

Hello mpack,

Thank you for your reply. I forgot to mention that I have viewed that post. I previously cleared the read only attribute for the disk, but performed the procedure again to ensure that it was not still the problem somehow. The read only attribute lists as "No", however windows will not allow me to offline the disk as "this operation is not supported on removable media". I do not know if this is preventing my access to the disk.

I noticed on a related thread [2-1] you stated "You can't mount the current host system drive as a virtual drive in a VM. First, Windows will not allow it because the drive is locked, since it's in use." I do not know if the removable media counts as "in use" since I cannot offline it even though it is not the host system's main drive. Any attempt I have made to offline/unmount/eject the disk from windows has resulted from it disappearing from the system and virtual box will not start the VM with the hard disk missing. Am I missing a way to offline the disk that retains its connection to the host OS?

Thank you
Attachments
url.txt
url referenced
(69 Bytes) Downloaded 9 times
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Cannot write to SD raw disk

Post by mpack »

I think the key term in that passage of mine which you quoted is "system drive". The system drive is the drive which the host OS is running from. You can't mount that drive in the guest, nor can you offline it. As far as I can remember that is the only significant point being made there.

I'm going to move this discussion to "Windows Hosts" since, really, the guest has nothing to do with this issue. It's not even a VirtualBox issue. This is all about disk permissions on a Win7 host, and it's about how USB drives work on that host.

First of all, you can offline a removable drive. Every time you "safely remove" a USB drive before unplugging it, unmounting the filesystem is exactly what you're doing. Your problem is that when Windows unmounts a USB drive, the drive ceases to exist because of the layered nature of how USB works. I.e. your "\\.\PhysicalDrive1" identifier is no longer valid.

So what happens if you don't offline the drive? My guess is that you'll get errors if you try to do sector level writes. So, I assume the problem is that you need to be in a supervisor mode. I would therefore look at creating a shortcut to the VM, and seeing if I could make that shortcut use "Run as administrator" to launch the VM. I'm afraid I can't provide details since I don't use Win7 for anything like this. I'm sure you could find info on "Run as administrator shortcuts" if you Googled for it. I emphasize that this is something to try, I don't warrant that it will work. VirtualBox isn't a simple, single process app, so running run the VM console process in supervisor mode may not be enough. We shall see perhaps.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Cannot write to SD raw disk

Post by mpack »

Incidentally: there is no point in posting offsite URLs, since very few of us is willing to check out unfamiliar links in order to investigate someone else's problem.

What I do need is a VM log of a session where've you've mounted the drive and done your unsuccessful write tests. After the VM is shut down, right click it in the GUI. Select "Show Log". Save "VBox.log" to a file. Zip that file and directly attach the zip to a message here (no URL please).

Oh, and please confirm that you are not using snapshots or immutable drives in this VM. In fact, just include the VMs .vbox file in the zip.
yournickname
Posts: 3
Joined: 7. Apr 2015, 03:57

Re: Cannot write to SD raw disk

Post by yournickname »

Hello mpack,

Thanks again for your time and information. I have attempted to run VirtualBox as administrator and still have the problem. I did change my shortcut to run as admin to ensure it is not a problem in the future however.

I have attached the log file you requested, as well as the .xml file for the VM settings. From the manual it seems that I have a .xml file instead of a .vbox file as I have a pre 4.0 version. Please let me know if I am incorrect and need to provide a different file.

I am not using snapshots with my VM. I am not familiar with immutable drives, however from what I gathered from the manual you have to use the virtualbox command line tools to change you settings to this format, which I have not done.
Attachments
VBox_Log_And_XML.zip
Requested Information
(14.23 KiB) Downloaded 9 times
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Cannot write to SD raw disk

Post by mpack »

Ah, I hadn't noticed where you said that your VirtualBox version was so old. That makes the xml useless. It also makes support pointless, since you have no access to bugfixes and I can barely remember what the issues were two years ago, never mind five. I do recall that there was issues with raw level access on Vista+ hosts, and your VBox version is so old that it may not include the fixes.

What "compatibilty with a project" requires such an old version? Tell me it's not just that you're following some ancient blog. I'm not aware of any technical capability with 3.x will have but which 4.3.x doesn't.

IMHO Nobody should be doing any new work with VirtualBox versions older than 4.1.0, and in fact I'd recommend switching to 4.3.12 and scrapping what you've created so far.
Post Reply