October 2011

“Journaling could not be enabled”

I struck this little jem today whilst shuffling the partitions around on my MacBook. (In my wisdom, I had made my MacOS X partitions waaay too big, and my Linux partitions waaay too small.)

The back-story is that I had made my MacOS X root and /Users partitions too big. I had successfully shrunk both, however, I discovered MacOS X’s Disk Utility does not support moving partitions, only resizing.  So, I created a new non-journalled HFS+ partition, booted into a Linux LiveCD, used rsync to clone the data.

All good and well, except after I deleted the old partition, I found I could not resize a non-journalled partition.  Fine, I hit “Enable Journaling”… no dice, it wouldn’t do it, and wouldn’t explain why.

So I was in a pickle.  The partition was too small for my needs, there was room to grow it, but it couldn’t do that unless journalling was enabled, and it wouldn’t enable it for me.

Further investigation, I fire up the Terminal and have a squiz on the command line, I spot something rather interesting:

vk4msl-mb:~ root# cd /Volumes/Home
vk4msl-mb:Home root# ls
.DS_Store		.fseventsd		Shared
.Spotlight-V100		.journal		stuartl
.TemporaryItems		.journal_info_block
.Trashes		.localized

Ohh yes, that might be a probable cause. rsync it seems, copied the .journal file over. And thus when Disk Utility open()‘s .journal (presumably with O_CREAT), the MacOS X kernel reports EEXIST (the file already exists).

I tried renaming it (with mv):

vk4msl-mb:Home root# mv .journal{,.old}
mv: rename .journal to .journal.old: Operation not permitted

Okay, that didn’t work. That said, the old partition was journalled, this one is not. So it probably doesn’t contain anything of great relevance now. It does have data:

vk4msl-mb:Home root# ls -ld .journal
----------@ 1 root  wheel  25165824 Apr  4  2011 .journal

So I decided to kiss it goodbye:

vk4msl-mb:Home root# rm .journal
override ---------  root/wheel uappnd,uchg,nodump,opaque for .journal? y
vk4msl-mb:Home root# rm .journal_info_block 
override ---------  root/wheel uappnd,uchg,opaque for .journal_info_block? y
vk4msl-mb:Home root# ls
.DS_Store	.TemporaryItems	.fseventsd	Shared
.Spotlight-V100	.Trashes	.localized	stuartl

All gone. Having done this, I now found that Disk Utility was more than happy to not only enable journalling, but grow the partition as I originally asked.

vk4msl-mb:~ root# mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
/dev/disk0s3 on /Volumes/Home (hfs, local, journaled)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk0s7 on /Volumes/Data (hfs, local)
vk4msl-mb:~ root# df -h
Filesystem      Size   Used  Avail Capacity  Mounted on
/dev/disk0s2    93Gi   20Gi   73Gi    22%    /
devfs          123Ki  123Ki    0Bi   100%    /dev
/dev/disk0s3   242Gi   82Gi  160Gi    34%    /Volumes/Home
map -hosts       0Bi    0Bi    0Bi   100%    /net
map auto_home    0Bi    0Bi    0Bi   100%    /home
/dev/disk0s7    84Gi  893Mi   83Gi     2%    /Volumes/Data

If others find themselves in this sticky situation, this might be a way out. I would strongly advise they back up any data before messing with file systems in this manner however.