Fix error - mount: only root can do that

33,836

To run a command as root, use sudo command. (You may want to read this to learn more.)

So: sudo mount -t vboxf ...

Creating the Mount Point for the Share

If you mount the share at /media/sharename, that directory must first exist. To create it, run:

sudo mkdir /media/sharename

You can mount shares anywhere; they do not have to be mounted in /media. However, these days it's common for filesystems mounted as root, especially if they may be attached and detached, to have subfolders of /media as their mount points.

The more traditional place to put mount points is /mnt. Either way--or elsewhere--will work.

Letting a Normal User Access and Change the Contents of the Share

If the host OS doesn't use a Unix-style filesystem--for example, if you have a Windows host running an Ubuntu guest--then you might want to specify what user you intend to give full access to the files in the share. Otherwise modifying the files (and possibly accessing them at all) will require you to act as root. You probably don't want that; you probably want to mount the share as root, but be able to access its contents as a non-rot user.

To do that, include uid=1000 in the ,-separated list of options issued after -o:

  • If that's the only option you're specifying, no comma is required. Otherwise, all options should be separated with commas, and no spaces.
  • Replace 1000 with your actual user ID. If you're the first user created on your Ubuntu system (the user created during installation), typically your user ID is 1000. To find out your user ID, run the command id -u in the Ubuntu system.
Share:
33,836

Related videos on Youtube

bashboy
Author by

bashboy

Updated on September 18, 2022

Comments

  • bashboy
    bashboy over 1 year

    I am trying to share folders between host OS and guest OS in VirtualBox as shown in this tutorial - http://helpdeskgeek.com/virtualization/virtualbox-share-folder-host-guest/

    As instructed in the tut, I go into my linux (L-ubuntu) guest and type the command -

    mount -t vboxsf [-o OPTIONS] sharedFolderName mountPoint
    

    When I do this, I get the error - mount: only root can do that.

    How do I become root and then execute the above command. I have a non-root solution here which I will try later - How do I mount a drive so that it is readable by me?

    • Job van Esch
      Job van Esch almost 11 years
      try the same command but start with "sudo ".
  • Eliah Kagan
    Eliah Kagan almost 11 years
    @bashboy To create a folder, use mkdir. This folder should probably be owned by root, plus you need to be root to add folders to /mnt. So use sudo with mkdir: sudo mkdir /mnt/NewShareFolder. I've updated my answer too, to discuss this.
  • Kapil Vyas
    Kapil Vyas over 9 years
    Can you tell me the name of the source/book? This really helped resolve my issue.