Tag Archives: hfs

Permissions on HFS+ volumes

This post will show you how to enable or disable permissions on a HFS+ volume and also how to check if a volume had the permissions enabled or not.

By default when you create a HFS+ filesystem it will have the permissions/owners disabled. I'm using a macmini for backing up files from a linux system and if I want the backup to be fully consistent with the source I need filesystem permissions.

Another problem is that using rsync between a permission based and a non permission based filesystem is useless because all files will always be out of sync.

Check permissions

  1. vsdbutil -c /Volumes/YourVolume

it will "Permissions on '/Volumes/YourVolume' are enabled ( or disabled ) of just "No entry found for '/Volumes/YourVolume'" which means the permissions are disabled.

Enable Permissions

  1. vsdbutil -a /Volumes/YourVolume

Disable Permissions

Since permissions are disabled by default I don't see many wanting to disable permissions but here's how you can do it anyway:

  1. vsdbutil -d /Volumes/YourVolume

I guess this is really useful only when you want to distribute a dmg image which currently has permissions enabled.
Distributing images with permissions enabled doesn't make much sense because the user that will open the image may have a different id then the user id that owns the files in the image so he may not be able to access the files inside the image.

MacOSX case sensitivity

I just got the biggest slap from MacOSX. Yes, I was punished for my ignorance.  I had not idea that the HFS filesystem defaults to case insensitive. I thought it would be case sensitive like in Unix but no.

When I first saw it I didn't believe it. The first clue was when I ran mysql_install_db an I got some warnings about about the filesystem being case insensitive. I didn't believe it because I knew I was able to create files with lower and upper cases so I just ignored it.

The confusion comes from the fact that the HFS+ filesystem is  MyFile.txt would be the same as myfile.txt .  The filesystem preserves cases so it will remember the original file name and a ls will show that but you would be able to access the file with different names. At the first glance this seems like a neat feature but it can actually create big problems when you're interacting with files from case sensitive filesystems.

The slap came from using rsync to backup files from a Linux machine to a macmini machine.   Just imagine a directory with many files split over directories from a to z and A to Z on Linux, something like files/a , files/A, files/b, files/B .

Now rsync -avz -e ssh  files/  backup@macmini:~/files/   and you'll end up with a folder named files on macmini but it will only have the upper case subfolders. The files in the lower case subfolders would be put in the upper case subfolders. This if really bad, it can really break consistency and mess up the data ( imagine different files with the same name one in A and the other in a as just one of the possibilities, there are other like this)

So now, what ? Reformat and change the filesystem to be case sensitive and journaled for easier recovery.
Be careful the next operation will remove all data on your disk:

  1.  
  2. diskutil eraseDisk "Case-sensitive Journaled HFS+" DiskName YourDiskId

YourDiskId is the disk that you want to erase.It can be disk1, disk2,etc... Look for it using diskutil list