August 28, 2011
Fixing NFS Trash + Keychain on OS X Lion Upgrade
I just upgraded my primary desktop at home to OS X Lion. During this process, a couple of things got messed up. First, after logging back in Keychain Access could not find my login.keychain, and any attempt to add keychains into Keychain Access failed. Second, I have my home directories NFS mounted. The method of mounting NFS directories changed so this did not carry forward between Snow Leopard to Lion. Plus afterwards, the Trash was not working for one of my NFS mounted users but it was for the other. I managed to resolve these problems and thought it would be a good idea to document them.
The first thing to fix was the NFS mounts. Obviously I cannot log in at all if my home directory is missing. I have always had a separate local administrator account, to perform system administration duties. This way, I can manage my computer without having any external dependencies like the network or my NFS server.
In OS X Lion, the way to add NFS mounts is via Disk Utility. There is an NFS Mounts... menu item and I simply added my NFS mount back. No problems and this uses automount whereas before I was using static mounts.
To fix the keychain problem, I simply restarted after my initial login. The file permissions were all correct, so I'm not sure what the original problem was. But it worked.
Now for the Trash. It took me a long time to figure out what was wrong, because my ~/.Trash directory existed and had all the correct permissions. Turns out, in /.Trashes on my Mac there was a directory named with my UID. Deleting this directory using sudo and then restarting restored normal trash behavior for my account. Previously it was always asking to delete files immediately. It may have worked as well without restarting but just logging out and back in.
There are two things to take note of. First, I ran Repair Permissions on Disk Utility and it found a lot of things to change. I'm guessing the directory structure and permissions have changed a lot in OS X Lion. Second, the auto-restore of application state, even for quit applications, can cause problems if your NFS mount is missing or flaky. For example, I had a few Terminal windows open and my shells were in NFS mounted directories. While debugging some stuff with NFS and trash, my mounts changed or were unavailable. Opening Terminal in this state would get stuck. (I probably needed my original NFS mounts to be soft rather than hard.)