0

I have a virtual machine with Ubuntu Server 17.04 (Guest) on VBox (Win 10 as host). I have set shared folder and try to automount it. Now, when I run manually the command:

sudo mount -t vboxsf src /media/src

Everything works fine, I have the folder mounted and all the files visible/editable. So I have put this command into /etc/rc.local and restart the machine. And the folder doesn't show up... I have set the service according to these instruction and still nothing. I checked service status by systemctl status rc-local.service and got following result:

● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/rc-local.service.d
           └─debian.conf
   Active: active (exited) since Sun 2017-09-10 18:45:10 CEST; 14min ago
  Process: 1185 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   Memory: 0B
      CPU: 0
   CGroup: /system.slice/rc-local.service

Sep 10 18:45:08 ubuntu systemd[1]: Starting /etc/rc.local Compatibility...
Sep 10 18:45:10 ubuntu sudo[1192]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/mount -t vboxsf src /media/src
Sep 10 18:45:10 ubuntu sudo[1192]: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 10 18:45:10 ubuntu systemd[1]: Started /etc/rc.local Compatibility.

So it seems everything's fine. What's more interesting I added the simple touch instruction to test that rc/local is actually run so now the file is as follow:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

touch /home/moby/dupa.zbita.kurwa.jego.mac

sudo mount -t vboxsf src /media/src

exit 0

Now, the file is beeing created so the file runs, yet the folder is not mounted as I expect. I thought that I made a typo in mount command but when I run the /etc/rc.local manually (obviously it is executable) the folder appears properly.

What should I do to make this work? Of course I could enable mount command to run without password from my user and add the command into ¬/.bashrc file to make it work for now (or simply run the mount by hand) but I am wondering what's wrong and how to fix it anyway...

[edit] Screen [2] asked in comment:

1 Answers1

1

One of the benefits of using Virtualbox is ability to add guest-additions to the host making it possible to interact seamlessly between host and guest OSes.

To set this up add the guest additions via either the command line for Virtualbox installs using the official repo, or from the oracle site if using .deb files to install.

Now to setup folder sharing we need to:

  1. Add the guest additions as mentioned earlier

  2. Add the desired folder from:

    • virtualbox settings menu for the guest OS in question, or

      enter image description here

    • from the the devices menu from the launched VM

      enter image description here

      enter image description here

  3. Select the options:

    • Auto-Mount and Make -Permanent
  4. In the guest Ubuntu OS add your user to the group vboxsf:

    sudo usermod -aG vboxsf $USER
    
  5. Restart Ubuntu so the new group addition gets picked up

  6. And note the convention is to name the folder with a "sf_" so look for a file named like so sf_******** in the /media folder. Example: /media/sf_vbox_share

You don't need to manually mount that shared folder, that's what Virtualbox Guest Additions are for.

yohfdo
  • 143
George Udosen
  • 36,677