Duel Booting, mapping UIDs for different filesystems

I’m dual booting Debian & OSX on my work machine.

In OSX, users are created starting with UIDs 1000.  So the admin user is 502, I’m 501, and so on.  Also, the ‘staff’ group ID is 20.

On Debian, users are created starting with UIDs 1000.  So I’m 1000, my testing blank account is 1001, and so on.  The ‘staff’ group ID is 50.

This is a bit of a problem when I want to share files.  Since it’s just me on the computer,
technically I could just mount the drive with full read/write permission to me.  But I don’t want that.  I don’t want to be able to muck around with stuff outside my /home (or /Users/) directory without really trying hard.

The way to do it is using FUSE and bindfs.

Debian squeeze comes with FUSE installed, and has bindfs, but the version of bindfs that comes in the repo wasn’t up to date enough, so you may need to compile your own.

sudo aptitude install bindfs libfuse-dev

 Download, compile and install a new bindfs:

tar -zxvf whicheverfileversion.tar.gz
cd whicheverfileversion
sudo make install

Should now leave you with an up to date /usr/local/bin/bindfs
For the sake of example, I’ll show my set up.  /media/OSX is the original.

sudo /usr/local/bin/bindfs –map=501/1000:@20/@50 OSX OSX

Sweet! It works!

There will be quite a big performance hit from using bindfs.  Some benchmarks (linked from the bindfs page) reckon about 80%.  Not a problem for me here, since it’s fast enough.  But to be aware of.

Here’s a script which I put in /etc/init.d/ to run this on bootup.

#! /bin/sh
# Provides:          osxfixperms 
# Required-Start:    fuse
# Required-Stop:
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: remount OSX drive with correct permissions.
# Description:
do_start() {
    /usr/local/bin/bindfs –map=501/1000:@20/@50 /media/OSX /media/OSX
case “$1” in
    echo “Error: argument ‘$1’ not supported” >&2
    exit 3
    umount /media/OSX
    echo “Usage: [start|stop]” >&2
    exit 3

Which I’ve then installed (on debian) with (as root)

update-rc.d defaults

You’ll need to be mounting the OSX drive *BEFORE* this happens.  Generally, that means stuffing it in /etc/fstab in the appropriate way.  You can ask google / debian docs.  It’s fairly well documented.  Unlike using bindfs.

Easy. (ish).