Virtualbox shared folders – executable flag and automount with Windows Host and Ubuntu Guest

Having issues with files you edit in the shared folder always getting the executable flag?
Difficulties automount-ing when booting your VM?
Nosetest doesn’t run unittest files if they have the executable flag on them, and the default mount with a Windows host OS and a Ubuntu Guest OS appears to make all files unalterably executable.

WARNING: This is out of date, and probably very very wrong. Leaving it up in case there is anything useful/relevant myself in future, when shared folders decide to waste a day of my life all over again.

[Vagrant is amazing, go use it.]

This is mainly from: how to remove executable flag from files in virtual box shared folder on linux guest.
Install guest additions on unbuntu server.
Note that it will say:
Installing the Window System drivers …fail!
(Could not find the X.org or XFree86 Window System.)
This is safe to ignore.

For some reason I had to re-run this command to get it working after installing guest additions:

sudo /etc/init.d/vboxadd setup

Add user to vbox group

sudo usermod -a -G vboxsf craig

If you remove yourself from sudo group by accident (by not specifying the -a, yes I did this 😐 ), read this.

Make sure that you were added to the vboxsf group, and record the groupid.

getent group vboxsf

Get your uid:
id

To mount the folder for the current session:

Log out and back in, create the folder locally then mount the folder using the groupid and id you just got:

sudo mount -t vboxsf -o uid=1000,gid=1001,umask=007,fmode=660 <vbox_shared_folder_name_specified_in_config> <local folder name>

Note: you don’t have to use the umask & fmode settings if you don’t want to. They’ll restrict all files to read/write only. If you’re building code and want to run an executable, that file won’t have the correct executable flag permission set.

Automount the shared folder on startup:

Ubuntu Desktop

http://www.virtualbox.org/manual/ch04.html#sharedfolders
Using VirtualBox GUI specify Auto-Mount for your Shared Folder, and your folder will automatically appear within the /media folder with the prefix “sf_”. As long as you added your user to the vboxsf group you should have access. Add a symbolic link to your home folder for ease of use. Going this way means you’re stuck will all edited files having an exec flag.

Ubuntu Server

sudo vi /etc/fstab

and add this line to it using the same gid as earlier:

<vbox_shared_folder_name_specified_in_config> <absolute path to local folder name> vboxsf rw,fmode=660,umask=007,uid=0,gid=1001, 0 0

Restart and make sure everything is working.

Advertisements
Virtualbox shared folders – executable flag and automount with Windows Host and Ubuntu Guest

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s