0

In all likelihood this is a repeat question, but I seem to be currently experiencing difficulties forming a search query to locate an answer.

I have a vfat partition mounted to /data containing all of my media, i.e. /data/books, /data/documents, /data/downloads, /data/websites, etc. The websites sub-directory is (soft) sym-linked to from /var/www such that my Apache2 installation uses the directory as its default DocumentRoot. My fstab entry is currently set to mount /data using my user/user-group (uid=1000,gid=1000) such that I can freely make changes to any file without further hassle.

However, I need the /data/websites directory to be mounted with the www-data user (uid=33,gid=33) such that Apache and my web-documents may create, modify, and delete files in the directory. My user is a member of the www-data group (gid=33) such that I may also make changes to the files in the directory.

chgrp and chown are out of the question as they simply have no effect on a mounted vfat partition. How can I mount /data/websites with a different owner/group (uid=33,gid=33) while leaving the rest of the /data mount owned by my user (uid=1000,gid=1000)?

bosco
  • 285
  • 2
  • 11
  • 1
    Is `/data` and it's subdirectories all one partition, or are `/data/books`, `/data/documents`, etc different partitions? – ernie Aug 20 '13 at 20:58
  • Good clarifying question! `/data` corresponds to a singular partition, `/dev/sda5` on my system. All of its sub-directories reside directly upon the partition. – bosco Aug 20 '13 at 21:04

1 Answers1

2

Since FAT does not support notion of filesystem permissions at all, let alone UNIX compatible ones, Linux mounts each file in the filesystem with the same owner and group-owner, as specified in the mount command or fstab.

A couple options:

  • Don't use a vfat partition, use ext2 or ext3 (if this is an Android phone and it's rooted with Cyanogenmod, you might be able to format your card ext2 or ext3 if you look around for a howto)

  • This is convoluted but should work. Install samba if it's not already active - create shares according to the folders and permissions you wish to expose, and then mount them using mount -t cifs \\127.0.0.1\share etc. It will be messy and a bit complex but will work OK.

LawrenceC
  • 73,030
  • 15
  • 129
  • 214
  • 1
    I'll second the samba solution. From your comment, I'm guessing you're using `/dev/sda5` as common storage on a multi-boot system, so setting up samba shares, and then "re-mounting" locally to change permissions seems like the best workaround. – ernie Aug 20 '13 at 21:27
  • Spot on! Took me a spell to configure everything correctly, but it works like a charm. And you're right on target @ernie - `/dev/sda5` is indeed my common storage for a multiboot environment. Many thanks! – bosco Aug 21 '13 at 20:40