---
title: Mounting Shared Folder in VirtualBox on OS X for ESP8266 SDK
date: 2014-12-06T20:55:18+00:00
modified: 2014-12-06T21:06:43+00:00
image:: https://kaspars.net/wp-content/uploads/2014/12/esp8266-shared-folder-correct-permissions.png
permalink: https://kaspars.net/blog/esp8266-mount-shared-folder-virtualbox-os-x
post_type: post
author:
  name: Kaspars
  avatar: https://reverse.kaspars.net/gravatar/avatar/92bfcd3a8c3a21a033a6484d32c25a40b113ec6891f674336081513d5c98ef76?s=96&d=mm&r=g
category:
  - Electronics
post_tag:
  - ESP8266
  - How to
---

# Mounting Shared Folder in VirtualBox on OS X for ESP8266 SDK

Espressif have packaged the [GCC-based toolchain for ESP8266](https://github.com/esp8266/esp8266-wiki/wiki/Toolchain) as a [VirtualBox appliance running lubuntu](http://bbs.espressif.com/viewtopic.php?f=5&t=2&sid=1e6c0f3619369ae8ef767bc037a3cc29) which makes it super easy to get started with compiling your own firmware for the module.

All your code is expected to go in a shared folder on your host machine (OS X or Windows) that you mount to the virtual machine by running the `mount.sh` script at `/home/esp8266`:

```
#!/bin/sh
sudo mount -t vboxsf share /mnt/Share
```

The problem with this script is that all files in that shared folder will be owned by `root:root` and the compiler running as user `esp8266` will fail to create new files and include the necessary libraries. I am not sure if this is an issue only when running OS X as the VirtualBox host.

![VirtualBox shared folder files owned by root in ESP8266 SDK](https://kaspars.net/wp-content/uploads/2014/12/esp8266-shared-folder-permissions-root-os-x.png?strip=all&quality=90&resize=659,464)

The solution is to [specify the correct owner (user and group) for the mounted files](http://askubuntu.com/a/123156/115808). We figure that out by running `umask && id` from the terminal:

```
$ umask && id
0002
uid=1000(esp8266) gid=1000(esp8266) groups=1000(esp8266),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),118(sambashare)
```

![User and group permissions for ESP8266 build tools](https://kaspars.net/wp-content/uploads/2014/12/esp8266-user-mask-group-permissions.png?strip=all&quality=90&resize=667,260)

Then we modify the `mount.sh` script to include the following option:

```
#!/bin/sh
sudo mount -t vboxsf <strong>-o umask=0002,gid=1000,uid=1000</strong> share /mnt/Share
```

and mount the shared folder by running

```
$ ./mount.sh
```

Which results in shared folder being mounted with the correct permissions:

![Correct user and group permissions for ESP8266 build tools and SDK](https://kaspars.net/wp-content/uploads/2014/12/esp8266-shared-folder-correct-permissions.png?strip=all&quality=90&resize=667,464)