Saturday, May 16, 2009

Moving your home folder to another disk (or moving it back)

In the older times, with "Mack OSe 9," many users chose to keep their personal files, work, and documents on a different physical disk from their startup disk. It was a safety measure: If one disk goes down, at least the other won't. There was no structural reason to keep files in a particular disk location, other than keeping them out of the System Folder.
I visited a client yesterday whose drive scheme was set up exactly like this, and he wanted to be (finally) upgraded to Leopard. I wasn't sure how Leopard would handle the fact that his Users folder had been moved to a different drive, so (knowing I had backups of his entire system) I cautiously proceeded with the installation.
After the installer finished, Leopard had created a fresh, blank Users folder on the startup disk with a home folder bearing the same username. This wasn't exactly the answer I was looking for. I had to link, somehow, the new Users/hisname folder with his existing user folder on the other volume.
Turns out, Leopard handles this much better than previous versions of Mac OS X. Read on to find out how.
In fact, it's as easy as opening System Preferences, holding the Control key and clicking (or right-clicking) on the account you want to change, and selecting Advanced Options.
You can see that you can easily browse for the user's existing home folder by clicking Choose next to the Home Directory field. Restart the computer, and it's done and dusted. Thanks to our own Michael Rose for this tip.
Hopefully, when you log in, the user's old Desktop, Dock, and everything else is in its place. You can then safely delete /Users/fred in the Finder by throwing it in the Trash. Note that this only changes the path for Fred's home folder; any subsequent users that you create will get home folders in the usual /Users path on the startup disk.
Now, a word of caution. In the past, some security and software updates have been confused by the fact that a user's home folder isn't on the startup disk. While most of the time there shouldn't be a problem, this user's system configuration is now an edge case, and that's where problems crop up. That's why I don't really recommend setting up a client's computer this way. If you're comfortable with the risk, then go for it.
For the truly nerdcore among us, you can also do this via the Directory Services command-line utility: dscl. Note that dscl requires root privileges, so you'll need to preface the command with 'sudo' to get it to work.
When you run dscl, the next step is to navigate to the correct directory within the Directory Services hierarchy (not a literal directory on the disk, mind), and change the value for the user's home folder. In this example, the user's name is fred, the user's new, blank home folder that Leopard created is /Users/fred and his old (correct) home folder on another volume is /Volumes/External Drive/Users/fred. [Line wraps are marked with », that command should go on one line. -- Ed.]
sudo dscl localhost
cd /Local/Default/Users
change fred dsAttrTypeNative:home /Users/fred »
"/Volumes/External Drive/Users/fred"
exit


Restart the computer, and you're good to go. You can remove the empty user folder on the startup disk by dropping into Terminal and typing sudo rm -R /Users/fred and pressing return.
My client eventually wants to change this partition scheme back to a more traditional installation. He also wants to move his data onto one large physical disk instead of two small ones (now that he has Time Machine as his safety net). When we migrate his data onto one disk, we can run this command in reverse to point his username to his home folder on the new, large startup disk.

No comments: