Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I have an SD Card reader built into my Lenovo laptop and I've installed VirtualBox and Debian squeeze to a VM but I can't seem to view the EXT4 partition, or any partition for that matter, on the SD card!

I asked this question: Change IP settings by mounting the SD Card in another computer

And the suggested answers involve mounting the SD card in a virtual machine.

share|improve this question
    
I think you have to pass through the USB device (the SD card reader is probably connected to the USB bus internally) - see howtoforge.com/… - Let us know if it works and I'll write it up as an answer. –  Alex Chamberlain Jul 7 '12 at 15:22
    
@Alex Chamerlain - I'm still struggling, it doesn't seem to show up as a USB device, i'm looking at mounting the partition as a raw device in VirtualBox but we've no (or very little) internet connection it is hard to work out what I need to do! –  Dog Ears Jul 7 '12 at 20:26
    
Thank you sir, worked perfectly to use my Xubuntu SATA hard disk in VirtualBox. Exactly what I was looking for. –  user5691 Jan 29 '13 at 7:28

2 Answers 2

up vote 7 down vote accepted

Internal Card Reader - Not USB - Windows 7 Host

My laptop has a built-in Card Reader and doesn't appear as a USB device. To get it to work I had to mount the EXT4 partition as RAW before assigning it to the VM and then booting the VM.

First thing I noticed was if I opened the Disk Management utility under Computer Management - Right click on My Computer and select Manage you should be able to see the SD card as a disk and as Kibbee mentioned mine also had three partitions, I guessed the larger middle partition is the one that I was after.

To mount the raw partition within VirtualBox you need to know the disk & partition number. I confirmed these first using the windows command line utility Diskpart and the list disk command (on my laptop, and in Disk Management, the SD Card appeared as #1)

To identify the partitions correctly, I used the VirtualBox command listpartitions here's mine as an example:

vboxmanage internalcommands listpartitions -r awdisk \\.\PhysicalDrive1

And the output for me was:

Number  Type   StartCHS       EndCHS      Size (MiB)  Start (Sect)
1       0x0c  16  /0  /1   1023/3  /32            75         2048
2       0x83  1023/3  /32  1023/3  /32          1590       157696
3       0x82  1023/3  /32  1023/3  /32           191      3416064

From this I'm guessing the partition 2 is the EXT4 partition I'm trying to get access to.

Mounting the Partition as a raw volume

To make the raw partition available to the Linux guest, VirtualBox allows you to submit the createrawvmdk command which creates a file with a .vmdk extension that you can then specify as an existing disk from the VM's storage settings. Again, here's mine as an example:

vboxmanage internalcommands createrawvmdk -filename 
C:\VirtualMachines\Debian\disk1_part2.vmdk -rawdisk \\.\PhysicalDrive1
-partitions 2

(you can leave out the "-partitions 2" parameter to enable all partitions on the device.)

Adding the raw disk to the VM

Before starting the VM

  • Open the VM's Settings dialog, select Storge
  • Right click SATA Controller and click Add Hard Disk
  • Select the Choose Existing Disk button and browse to the file created in the previous step.

You're now be able to boot the VM and have access to the EXT4 partition.

Problems with User Account Control

If the following conditions are met:

  • the host system is running Windows Vista, 7 or 8 (or perhaps Windows Server 2008R2/2012)
  • User Account Control is enabled
  • and you haven't modified permissions regarding raw disk access

then the above operation might fail, even if you're an Administrator. This is due to the fact that non-administrators will not have access to raw devices.

I see 4 possible solutions, none of which are very nice:

  • Disabling User Account Control might fix it (I haven't tested that).
  • It might be possible to assign permissions for users to access raw devices; however I wouldn't recommend this as it's extremely insecure.
  • You can run VirtualBox as an Administrator (right click, select "Run as administrator"); you have to do this both while creating and using the device.
  • ....or buying a USB card reader and attach it directly as a USB device.
share|improve this answer
    
This may be specific to my use of this but I figured I'd comment in case it helps anyone else: If you are writing to the SD card from the guest OS and your guest OS bombs with a BLKCACHE_IOERR error, you can fix it by going into the settings of the guest and enabling "Use host I/O cache" on the SATA controller. –  Joshua Whitley Mar 7 '13 at 5:07

To accomplish this, I used an SD card reader, similar to this one. I picked one up my my local dollar store, which is the cheapest place to get them. Although I would assume that almost any USB card reader would work.

After plugging it in and starting up your Virtual Machine, go to the "Devices" menu for Virtual Box, and select USB, then find your USB Device. My shows up as "Generic-USB2.0-CRW [8687]". Your device name may be different. As soon as I plugged it in, it auto mounted the drives and popped up a window for each of the 2 partitions (not counting the swap partition). If this doesn't happen for you, the device is recognized as /dev/sdb on my machine with the three partitions:

boot: /dev/sdb1
root: /dev/sdb2 <-- This is the EXT 4 one with the /etc/network/interfaces file
swap: /dev/sdb3

The device name may be different on your virtual machine, and the partitions may be different if you are using something other than Debian for the Raspberry SD card. If you don't have an SD Card reader handy, you may want to try putting the SD card into a camera, and attaching that to Virtual Box. This may or may not work, just tested with my eBook reader (Kobo) and only the vfat (boot) partition shows up.

share|improve this answer
    
+1 although it doesn't help me, maybe a title identifying this solution as applicable to USB? –  Dog Ears Jul 8 '12 at 16:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.