Changing User home directory under Mac OS X Leopard and beyond
Sunday, 31st January, 2010Yesterday I finally got around to removing my flakey superdrive from my Macbook Pro and replaced it with an optical bay hard disk (OBHC) caddy (Google NewModeUS). This meant I was able to add another 320GB drive where my superdrive once lived (much needed as I was at 92% disk usage on my system drive). I also have an Intel X25-M 80GB to install but I’ll save that for a weekend when I have more time.
In preparation to moving to SSD, I’m looking to divert as many writes as possible, to prolong the performance of the drive (no TRIM support in OS X at present – no, not in Snow Leopard either). One of the best ways to do this is to migrate my user directory to my second (magnetic) hard drive. You might argue I’m losing the performance I paid for getting an SSD but boot times and applications launches should still benefit as the OS and apps reside on my X25-M.
<notice>Before proceeding with these instructions it’s vital you have a backup of your user directory and any other data on your Mac that you want to keep.</notice>
One of the top search results in Google for how to move / change your user directory in Mac OS X recommends using a symlink. There is however a cleaner method documented back in 2002 by Dan Frakes.
First, make sure that on the new volume, the “Ignore ownership on this volume” setting—in the volume’s Get Info window—is not checked
Open Terminal and enter:
$ sudo ditto -rsrc "/Users/greg" "/Volumes/newvolume/Users/greg"
$ sudo niutil -createprop / "/users/greg" home "/Volumes/newvolume/Users/greg"
The problem being that niutil no longer exists in OS X 10.5 (Leopard) and later.
$ niutil
-bash: niutil: command not found
In Leopard and later the NetInfo Manager has been replaced the Directory Services client (dscl). Since Mac OS X 10.4 ditto also has the -rsrc arguments enabled by default.
The commands you’re looking for under Leopard (and Snow Leopard) are (substitute your own username instead of ‘greg’, and here I’m moving my user directory to my second hdd/volume ‘Data’):
$ sudo ditto "/Users/greg" "/Volumes/Data/Users/greg"
Password: (enter password)
$ dscl
Entering interactive mode... (type "help" for commands)
> cd /Local/Default/Users/
> ls
> change greg dsAttrTypeNative:home /Users/greg /Volumes/Data/Users/greg
> exit
Logout and login again, verify your home directory has moved by opening Terminal and checking the public working directory:
$ pwd
/Volumes/Data/Users/greg
Now rename your old user directory to be sure, before removing it (or leaving it if you can afford the space):
$ cd /Volumes/OSX/Users/
$ mv greg greg.old
I rebooted after this to check my machine started up without any issues. Then removed my old user directory (sudo rm -rf greg.old).
Congratulations you’ve moved your user directory.
Update: When starting Eclipse, it could not locate my workspace but I only had to browse to my new user directory (/Volumes/Data/Users/greg). VirtualBox automatically updated the path to my images created with their wizard (presumably because they use a system variable for the path). The VDIs I had manually selected required my assistance to update their location in the Virtual Media Manager.



