Wednesday, October 19, 2016

Error -50 when trying to write to an HFS+ Journaled file system

First, credit where credit is due.  The answer came from

One of my Seagate drives suddenly started acting really weird.  It wouldn't let me delete files from it, copy new files on to it, etc.  Copying files off the drive seemed to work fine, but when I tried to run Disk Utility to validate the file system, it gave an error complaining about being unable to dismount the file system - someone had it busy.

Quick trip to the Terminal and tried:

$ sudo lsof | grep VOLUMENAME

and that showed a couple of issues, OneDrive, GoogleDrive, etc keeping files open, so I quit those apps and tried again.  Same dismount problem, even though there were no open files that the system would tell me about.   Hmmm, real Unix fsck can run on a mounted filesystem, surely the hfs variant can?  Yep.  First, work out the device name with mount ...

$ mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk2s2 on /Volumes/VOLUMENAME (hfs, local, journaled)

... then run the HFS checker using that device name

$ sudo fsck_hfs -ld /dev/disk2s2

... and that claimed that the file system was fine.

Back to Google, found the thread at which suggested that the problem might be a corrupted journal.  His solution was more complicated than I needed because I don't have a hardware failure to contend with, so I tried doing it online.

Turn off journaling with Apple's hidden hfs.util tool:

$ sudo /System/Library/Filesystems/hfs.fs/Contents/Resources/hfs.util \

    -N /Volumes/VOLUMENAME

and try Disk Utility again.  Lo and behold, now it can unmount.  Let it run through the check and it gives the drive the thumbs up.  Turn journaling back on:

$ sudo /System/Library/Filesystems/hfs.fs/Contents/Resources/hfs.util \
    -J /Volumes/VOLUMENAME/
Allocated 229376K for journal file.

And we are back in business.  No idea why the journal went bad, and I'll make sure my backups of all the stuff on that drive are up to date. 

P.S. The crappy fonts and colouring in this post are a function of this wysiwyg editor that provides.

P.P.S Less than two weeks later, the same disk has died again but this time with an error that fsck does not seem to be able to fix.  Sigh.

Monday, October 10, 2016

iTunes Rants

Dear Apple,

when people tell you that iTunes is a piece of crap, this is what they mean.

I'm sure one of those numbers is correct ...

Useful Mac Hacks

If it gets in here, it has to be pretty useful.  I didn't work it out, I'm just trying to hold on to it for posterity.  Always look to the original link for details.

Add a "recent apps" icon to the dock.
defaults write persistent-others -array-add '{ "tile-data" = {"list-type" = 1; }; "tile-type" = "recents-tile";}' && \killall Dock

Note: I don't know why they include the \ in front of killall - it isn't needed, it merely escapes the 'k'.  If you wanna avoid PATH issues, use /usr/bin/killall.