Pregunta

I am trying to work on a django project using virtualbox. The project directory is a symlink pointing to a shared folder that resides on the host machine. The django project is created without permission issues, and I successfully host the site using Apache on the guest machine. However, when I run collectstatic I get OSError: [Errno 30] Read-only file system.

Is there another user that needs to be added the vboxsf group? My user is banjo, and apache's is www-data

Or is there another solution? I'd really like to have my files on my host computer.

This is my setup

  • Host: Xubuntu 12.10
  • Guest: Xubuntu 13.04
  • Django: 1.5.1

Here are the relevant parts from my setup steps. Also, I have enabled the django admin. It is these static files that need to be collected.

# add banjo user and apache user to shared folder owernship group
sudo gpasswd -a banjo vboxsf
sudo gpasswd -a www-data vboxsf

ln -s /media/sf_foobar foobar.com
mkdir -p foobar.com/dev
cd foobar.com/dev

mkvirtualenv foobar --no-site-packages
workon foobar

pip install django

django-admin.py startproject foobar

# settings.py
STATIC_ROOT = '/home/banjo/foobar.com/dev/foobar/static/'

python manage.py collectstatic -l

I get the following error

(foobar)virtual-machine|foobar: python manage.py collectstatic -l

You have requested to collect static files at the destination
location as specified in your settings.

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Linking '/home/banjo/.virtualenvs/foobar/local/lib/python2.7/site-packages/django/contrib/admin/static/admin/css/rtl.css'
OSError: [Errno 30] Read-only file system

This is a tree of the file system showing owner and group

virtual-machine|foobar.com: tree -L 3 -ug
.
└── [root   vboxsf]  prod
    ├── [root   vboxsf]  foobar
    │   ├── [root   vboxsf]  foobar
    │   ├── [root   vboxsf]  manage.py
    │   └── [root   vboxsf]  static
    ├── [root   vboxsf]  logs
    └── [root   vboxsf]  requirements.txt

I ran sudo chown -R banjo prod/ but that did not change ownership.

¿Fue útil?

Solución

The problem wasn't with collectstatic itself. I was using the -l flag which creates symbolic links of the static files.

The actual problem is that virtualbox 4.1.18 disallows creating symlinks on the host computer.

I found the answer on serverfault here. For more info, see this virtualbox ticket

I am reposting the solution here, for quick reference.

Run the following command on your host:

VBoxManage setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1

Or on Windows

VBoxManage.exe setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1

where VM_NAME is the name of your virtual machine (e.g Ubuntu) and SHARE_NAME the name of your shared directory (without the "sf_" prefix).

This will re-enable the previous symlink friendly behavior.

I had to reboot after doing this and then symlinking on shared folder worked!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top