Mounting an external USB drive via VirtualBox?

79,646

those three partitions are all on the same drive.

the external hard drive should show up as /dev/sdb#.

go to Devices/USB Devices on the virtualbox window and select your external hard drive. now the drive should be mounted automatically by Ubuntu

Share:
79,646

Related videos on Youtube

Jay
Author by

Jay

Updated on September 18, 2022

Comments

  • Jay
    Jay over 1 year

    I have an external hard drive that Windows can't open (gives an error message saying the file system is unrecognized and wants me to reformat), so I am trying to see if Ubuntu, which I am running as a guest vm in VirtualBox on my Win 7 host, can open it.

    I am confused as to how to mount it. When I open up VirtualBox and click "Settings" for the Ubuntu vm, do I go to "Storage" and try to see if I can mount it there, or do I go down to "USB" and attempt to mount it from there? When I tried the latter, and clicked on "Enable USB 2.0 (EHCI) Controller", a warning popped up from VB saying I needed to download VBox extensions to be able to select that option. So I downloaded the extensions and am unsure of what to do next. When I get into Ubuntu, how can I access the external hard drive via the command line? When I tried the command "fdisk -l", the following is printed:

    http://paste.ubuntu.com/1053741/

    But I have not done anything else in the VBox settings, so I don't think any of those hard drives listed are referring to the external USB drive that I want to access (even though the drive is plugged into my laptop). I do not know what drives sda1, sda2, and sda5 refer to exactly, but apparently I have an extended partition since it goes from sda1 and sda2 to sda5. When I created space for the Ubuntu virtual machine through VBox, I think I only created one main partition and one for the swap, so why is fdisk showing me 3 partitions, unless one of them is referring to the plugged in USB external hard drive, but I don't think that is it because I have not done anything else in the VBox settings for USB?

    Any suggestions will be appreciated :-).


    I have a Western Digital external HD of around 2TB; Windows 7 for some reason no longer allows me to open it: when I plug it into my laptop (via a USB 2.0 port), Windows either does nothing or asks me to format the drive because it doesn't recognize the file system. So I am trying to see if I can access the files in Ubuntu.

    I am running Ubuntu through VirtualBox. Before starting Ubuntu, I went into the USB settings for the Ubuntu virtual machine, and selected the external hard drive (VBox sees it). Then I started Ubuntu. Here is the print out of fdisk -l:

    Disk /dev/sda: 91.3 GB, 91268055040 bytes
    255 heads, 63 sectors/track, 11096 cylinders, total 178257920 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
    Disk identifier: 0x000d5f79
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *        2048   174583807    87290880   83  Linux
    /dev/sda2       174585854   178255871     1835009    5  Extended
    /dev/sda5       174585856   178255871     1835008   82  Linux swap / Solaris
    
    Disk /dev/sdb: 2000.4 GB, 2000396746752 bytes
    255 heads, 63 sectors/track, 243201 cylinders, total 3907024896 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
    Disk identifier: 0x00020fc3
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1   *        2048  3907024895  1953511424    7  HPFS/NTFS/exFAT
    

    I believe the external drive is the bottom one, sdb1, but I have no idea how to access it. Is it already mounted or do I have to mount it manually? If Windows 7 did not recognize it, will the same problem occur in Ubuntu?

    • Sanam Patel
      Sanam Patel almost 12 years
      Might be easier to just boot a live CD/USB and mount the drive to see the files. You could copy them over to the Windows partition and then reformat the USB drive, if that's all you are wanting.
    • Jay
      Jay almost 12 years
      Well, if Windows is saying that it doesn't recognize the file system now, won't that make it difficult to copy over files from the external HD to Windows? Also, there is over 1TB of data on the external, and my Windows hard drive in total is around 450GB.
    • Sanam Patel
      Sanam Patel almost 12 years
      You can view all files on all partitions (assuming no encryption) with the Live CD, but that won't help due to the quantity of data you have vs. available space. For future reference, you can copy files to a Windows partition using a Live CD and then when you boot Windows, they are there ready to be accessed.
    • Jay
      Jay almost 12 years
      Ok, thanks Tom; I will attempt to mount the USB to the VirtualBox and see if Linux recognizes it for now.
    • Jay
      Jay almost 12 years
      Ok, so before I started up Ubuntu via VirtualBox, I went into the VBox settings and selected the external drive through the filter. Then, when I ran fdisk -l, sdb1 (which I'm pretty sure is the external hard drive) shows up. Since I am running Ubuntu via VBox on a Windows host, I am guessing that I do not need to make a vboxusers group, since the VBox manual lists this step for Linus hosts (newer ones), and does not list it for Windows hosts. My question now becomes how do I access the files in sdb1? When I tried "cd /dev/sdb1", it says "no such directory"; same for "sda1".
    • Jay
      Jay almost 12 years
      Yeah, I kind of got stalled in that question- I just flagged the other one for removal.
  • Jay
    Jay almost 12 years
    Thanks Marty- it is asking me to specify a file system, which I don't know because I can't access it. All I know was that it was working fine in Windows 7 a few weeks ago, so it's probably NTFS or some kind of FAT. Any advice on what file system to choose? If I choose the wrong file system, will that damage the external drive?
  • Deepak Verma
    Deepak Verma almost 12 years
    the type is exfat; I don't actually have anything with this type of file system. The full command is sudo mount -t exfat /dev/sdb1 ~/wd; but usually the type isn't required, so this might mean you don't have the exfat utilities as mentioned by Anwar Shah. The type tells it about the format for the raw data that is at /dev/sdb1. If you specify it wrong, it will look like garbage, and you wouldn't want to try to write to it.
  • Jay
    Jay almost 12 years
    Ok I will try it with exfat. Btw, how did you know that that was the fs? Is exfat simply the standard fs for external hard drives by Western Digital and/or other disk drive manufacturers?
  • Jay
    Jay almost 12 years
    Ok, so I tried the <code>sudo mount sudo mount -t exfat /dev/sdb1 ~/wd command and received the following message: "mount: unknown filesystem type 'exfat'"; any suggestions for this?
  • Deepak Verma
    Deepak Verma almost 12 years
    @Jay: I might be confused - I'm not sure now why I thought it was exfat; maybe because I thought it would automatically detect NTFS, but it might be ntfs, so try "ntfs" (or "ntfs-3g") instead. I think I answered your original post, and now I'm not 100% sure my answer is even applicable without starting over, but try the mount with ntfs as the type to see what happens.
  • Amar
    Amar almost 9 years
    I use Ubuntu guest (10.04) on Windows host (Vista) VirtualBox setup. I had the exact same query as OP and your solution worked perfectly well! Thank you! :-)