How to mount a drive?

Discussions about using Linux guests in VirtualBox.
cshaum

How to mount a drive?

Post by cshaum »

How do I mount a drive in ubuntu? Windows is my host and Ubuntu is my guest. And I like to mount my F drive in Ubuntu. I saved everything in my F drive that way I can shared in between the two. I got some directions off another thread but I got lost. Here they are: Can these be explained little bit more I'm new this VM thing. Thanks

To get a volume to mount on boot, you need to edit the filesystem table, located at /etc/fstab. To do this, type

Code:
sudo nano /etc/fstab

at Terminal in Linux. The format for a fstab entry is

Code:
<file system> <mount point> <type> <options> <dump> <pass>

so you would need to add

Code:
sharename /media/sharename vboxsf defaults 0 0

to mount a share callec "sharename" at /media/sharename. Then, to save the fstab, press Ctrl+O, Enter, then Ctrl+X to exit.
Perryg
Site Moderator
Posts: 34370
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to mount a drive?

Post by Perryg »

Actually this is not the preferred way to mount a share in Ubuntu these days. fstab gets loaded before the VBox files are loaded and you may find that it fails more then it works. You should use the /etc/rc.local file instead, but that is your choice.

Steps are as follows. (this is an example use the names you want)
create the share in VBox under shared folders. Do not use spaces or special characters in the share name.
Start the guest and create a mount point. In terminal do sudo mkdir /mnt/Transfer
Then you mount the share manually to test before you do the permanent mount.
sudo mount -t vboxsf <share name> <mount point>
If it works then you edit the /etc/rc.local file and add it as shown in the attachment. Be sure to not add it below the last line or you could have a system hang. Also note that you must make this file valid by removing the # from the first of line one.
rc.local.jpg
rc.local.jpg (22.22 KiB) Viewed 25109 times
You can read more about it in Shared Folders in your VirtualBox users guide. Yes it states to use the fstab and you can if you like but I see this fail more then it works in Ubuntu
cshaum

Re: How to mount a drive?

Post by cshaum »

I tried it and it failed, can you tell me what I did wrong. Using "/"as my mounting point. Than F_DRIVE is the drive I'm trying to mount. Here are the terminal entries:
carl@carl-laptop:~$ sudo mkdir /mnt/transfer
carl@carl-laptop:~$ sudo mount -t vboxsf F_DRIVE /
/sbin/mount.vboxsf: mounting failed with the error: Invalid argument
carl@carl-laptop:~$

Thanks
Perryg
Site Moderator
Posts: 34370
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to mount a drive?

Post by Perryg »

carl@carl-laptop:~$ sudo mkdir /mnt/transfer
carl@carl-laptop:~$ sudo mount -t vboxsf F_DRIVE /
First you can not use the _ or - these are the special characters I talked about. If you want to call it F that is ok
then the mount statement would be sudo mount -t vboxsf F /mnt/transfer
Why not call the shared name share?
then your mount statement would be sudo mount -t vboxsf share /mnt/transfer
cshaum

Re: How to mount a drive?

Post by cshaum »

I took your advice and changed the name to: share. In the shared folder window in VB. But I get the same error message:
carl@carl-laptop:~$ sudo mount -t vboxsf share /mnt/Transfer
/sbin/mount.vboxsf: mounting failed with the error: Invalid argument

What shall I try next? Thanks!
Perryg
Site Moderator
Posts: 34370
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to mount a drive?

Post by Perryg »

Look in the /mnt folder and see what the folder says it is that you created for the mount point. Also Linux is case sensitive. Caps matter.
cshaum

Re: How to mount a drive?

Post by cshaum »

Yes, I was able to mount it. But it not permanent. I checked the box to make permanent. and edited the rc.local file. Using the sudo nautilus command in terminal. I used lower case on the word transfer for that is the way the file is: /mnt/transfer. If I want to access it, I have to fire up the terminal and type in that whole string of command. Thanks
Perryg
Site Moderator
Posts: 34370
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to mount a drive?

Post by Perryg »

Look at the rc.local file again and read it. It tells you to mark it active. To do that you remove the # from the first line.
Then follow the example I sent you above for the proper syntax.
orsula
Posts: 5
Joined: 18. May 2010, 16:03
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Win7

Re: How to mount a drive?

Post by orsula »

Hi,
I'll hijack this thread for the same mounting a share problem. I read many threads here and still have an issue. I'm using W7 as host and Ubuntu 10.04LTS as guest. VBox 3.1.8. Guest additions installed without errors (dkms was installed prior to guest additions). I created a Machine share called C with path C:\ and full access and a mount point /mnt/tunnel.
Trying to mount yields:

Code: Select all

sensors:~$ sudo mount -t vboxsf C /mnt/tunnel
/sbin/mount.vboxsf: mounting failed with the error: No such device
What does the error "no such device" mean? I think I have all the folders created/defined properly.
Seems guest additions were installed:

Code: Select all

sensors:~$ which mount.vboxsf
/sbin/mount.vboxsf
But the vboxsf module doesn't load properly:

Code: Select all

sensors:~$ lsmod | grep vbox
vboxvideo               1196  1 
drm                   162471  2 vboxvideo
vboxguest             138999  6 
Trying to load it fails:

Code: Select all

sensors:~$ sudo modprobe vboxsf
FATAL: Error inserting vboxsf (/lib/modules/2.6.32-21-generic/misc/vboxsf.ko): Invalid module format
I also saw here (http://forums.virtualbox.org/viewtopic.php?f=3&t=15868) that if I use a personal folder (a.k.a My Documents) as a share it might cause the the "no such device" error, but I am trying to share the entire C drive, which shouldn't be personal.
I have reinstalled the guest additions several times and it goes without errors every time. I have not seen any other ideas beyond
loading the module manually with modprobe, but that fails for me as well.

Can someone give a tip on what's going on?

Thanks much.

UPDATE:
The vboxadd module has an issue:

Code: Select all

sensors:~$ sudo /etc/init.d/vboxadd start
Starting the VirtualBox Guest Additions ...fail!
(modprobe vboxsf failed)
Still no idea how to solve this.
orsula
Posts: 5
Joined: 18. May 2010, 16:03
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Win7

Re: How to mount a drive? SOLVED!

Post by orsula »

Seems that in my case, the issue was with a virtualbox-ose-dkms module that was giving grief.
I came across it when I tried to reinstall dkms and got this reply:

Code: Select all

sensors:~$ sudo apt-get install dkms
Reading package lists... Done
Building dependency tree       
Reading state information... Done
dkms is already the newest version.
The following packages were automatically installed and are no longer required:
  virtualbox-ose-dkms
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Seems I needed to remove the virtualbox-ose-dkms. Doing 'apt-get autoremove' and then trying

Code: Select all

sensors:~$ sudo /etc/init.d/vboxadd start
Starting the VirtualBox Guest Additions ...done.
Allowed to mount as usual with 'sudo mount -t vboxsf VMshare /mnt/share'

Hope it helped someone.
:)
Sasquatch
Volunteer
Posts: 17800
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: How to mount a drive?

Post by Sasquatch »

Just for this, I made a howto: Howto: Use Shared Folders.
And this is not about Windows Hosts, it's about the Linux Guest. Moving it.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
cshaum

Re: How to mount a drive?

Post by cshaum »

What does this phrase mean? In order to enable or disable this script just change the execution
bits. I did remove the # sign off the first line. And this is what I put in above the exit line: mount -t vboxsf -o rw,uid=1000,gid=1000 transfer /mnt/transfer
Thanks,
Perryg
Site Moderator
Posts: 34370
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to mount a drive?

Post by Perryg »

You run chmod a+x /etc/rc.local in terminal to make the file executable for all users.
Actually you don't need to remove the #
I had to to make it work the first time in Ubuntu 10.04 but then I put it back and it worked as it should.
Sasquatch
Volunteer
Posts: 17800
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: How to mount a drive?

Post by Sasquatch »

The file should also be executable by default.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
cshaum

Re: How to mount a drive?

Post by cshaum »

Back from a break. I ran that line in the terminal and this is what it said: chmod: changing permissions of `/etc/rc.local': Operation not permitted. What now?? Thanks
Post Reply