Can't rename directory by changing upper- to lower-case on hfs+ partition in Ubuntu

I'm new to Linux, and just installed Ubuntu 17.04 on a dual-boot MacBook. I'm having trouble with directories I'm creating on an hfs+ partition (created with gparted, so I can see files on it when booted into OS X). I'm assuming the confusion has to do with the hfs+ format being case-insensitive, but then, shouldn't it really be case insensitive, whether I'm working on it via Ubuntu or OS X? Here's the scenario:

  1. Created directory "DropBox" via Nautilus.
  2. Tried to rename "DropBox" to "Dropbox" but got error message: 'The item could not be renamed. The name "Dropbox" is already in use...'.
  3. Tried deleting "DropBox" (permanently, not to Trash) and creating new directory "Dropbox". When I did that, both directories appeared ("DropBox" and "Dropbox").
  4. Tried deleting "DropBox", but both directories were deleted. Looked in Terminal; while both "DropBox" and "Dropbox" are visible in Nautilus, running `ls -a shows only "DropBox".
  5. Still in Terminal, deleted "DropBox" (rm -R DropBox). As expected, this resulted in there being no dropbox folder of any sort. However, in Nautilus, I still see "Dropbox", until I try to open it, at which time I get an error that says it doesn't really exist, and then it disappears from Nautilus, too.
  6. In Terminal, re-create the directory (mkdir Dropbox). The directory is recreated as "DropBox" again, and shows up as such in Nautilus as well.

Here is the mount options for the drive: /dev/sdb2 on /data type hfsplus (rw,nosuid,nodev,noexec,relatime,umask=22,uid=0,gid=0,nls=utf8)

Dropbox is not yet synced to this directory, so I know it has nothing to do with Dropbox.

Is there any way around this issue, or is it unavoidable when using hfs+?


Solution 1:

After digging around further, I found the solution to this issue. It is actually possible to format an hfs+ partition in OS X as case-sensitive, unjournaled, though it takes two steps. There's no way to switch an existing case-insensitive partition to case-sensitive.

The option to disable journaling (or to format a vol as case-sensitive, not journaled) has been removed from the OS X Disk Utility in El Capitan (which is the version I'm running) but it can still be done:

  1. Depending on how the disk is partitioned, it might be necessary to carve out the disk space first on Linux (using gparted is the easiest way). I'm fairly sure it doesn't matter what type of partition, but just to be careful, I created it as hfs+ to make sure there were no weird access issues on the OS X side.

  2. In OS X, use Disk Utility to format the partition as HFS+ Case-Sensitive, Journaled. (It should be possible to do in Terminal using diskutil, as well, but I didn't want to take the time to hunt down the syntax for case-sensitivity).

  3. Still in OS X, in Terminal, run diskutil disableJournal /dev/volname. You can run this with the disk mounted or unmounted. (If you're not sure of the disk or volume name, diskutil list will list them all).

Side note: From the number of posted questions on the subject, it appears that mounting hfs+ as rw in Ubuntu is problematic for many. The syntax for designating mount of an hfs+ partition as rw in fstab (/etc/fstab is used by the system to mount devices at boot) is UUID=<UUID> /mountpoint hfsplus rw,exec,auto,users 0 0, assuming you want the typical options for a non-system data vol. If you want something different, this article is really helpful. You will also probably need to chown -R user /mountpoint the mountpoint.

And that's it. I tested it out back in Ubuntu, using the same "DropBox" name change test I used before, and it all looks good.