I like partitions. Got a bunch of ’em on my laptop: several smaller ones, and a large one for data. It’s an easy way to test different OS versions.
Easy, at least, until the OS started taking up so much damn space! Now, I regularly fill up the smaller partitions. One solution is to resize them, an issue I’ll get to later.
But another solution is to move the large personal data stores that are normally replicated on each OS partition to the data partition, where they belong.
For example: my email. Mail normally stores its data in ~/Library/Mail
:
POP:
IMAP:
But I’m never prompted where I want to put this Account Directory, it always defaults to ~/Library/Mail
, and as you can see, it’s dimmed, so I can’t change it in the user interface once the account has been created. Well, there may be a way, but it probably involves throwing away all the messages I already have, which I don’t want.
All the information on my accounts is stored in the plist file at ~/Library/Preferences/com.apple.mail.plist
. Ah, that’s easy, I think to myself, I’ll just open that file in a text editor and I’ll….
Bzzzt! (Notice how I like that word?) The plist is in binary format: I wouldn’t recommend trying to modify it with TextEdit.
For this, I’ll need to open the plist file in Property List Editor, which is available, after an Xcode Tools install, at /Developer/Applications/Utilities/Property List Editor.app
.
I use the "Dump" button in the upper right-hand corner of the Editor window to get a dump of the plist file as text, and then copy that text to TextEdit (or a better editor such as BBEdit) and save it off somewhere.
Now, I need to search on every instance of ~/Library/Mail/
in that file, and change that path to the new path I want, /Volumes/Data/Mail/
. The primary location for this in the plist is: MailAccounts → <account dictionary> → AccountPath.
What’s surprising is that this isn’t the only location where I find that path. In fact, it seems that the full path in the file system to the account directory is what’s used to refer to that account throughout the plist. I make sure to change them all.
The plist also contains the path ~/Library/Mail Downloads
. I change that to /Volumes/Data/Mail/Downloads
, just to keep all my Mail data in the same Mail
folder.
Now that I’m done with the find-and-replace steps, I close Mail and back up all its data. Very important!
Next, I go to the ~/Library/Mail
folder. I find the folder called Mailboxes
, if it exists, and copy it to the new location.
I find every folder of the form ACCOUNTTYPE-username@account.domain.com
, where ACCOUNTTYPE
is IMAP or POP, etc., and account.domain.com
is your incoming mail server, and copy them over as well. I don’t copy everything in ~/Library/Mail
.
I copy the ~/Library/Mail Downloads
folder into the new Mail
folder, and rename it just Downloads
, to match what I specified in the new plist, above.
Finally, while Mail still is closed, I replace the old binary plist (which I also backed up) with my newly edited, text plist. I say a little prayer, and reopen Mail.
It works!
Finally, once I’m sure everything is working, I get rid of the Mail folders on my OS partition. I follow all the same steps as listed above for my other OS partitions (except for populating /Volumes/Data/Mail
, which I do only once with the most up-to-date data), and I’m done.
Feedback #1 If all I have is IMAP accounts, why not just go ahead and never store anything locally? Problem solved!
For one, IMAP is slow enough as it is: if I have to download all my messages from the server every time I open Mail, it’ll go even slower! For two, Mail tells me it won’t be able to check for spam under that configuration, though I haven’t verified this.
Feedback #2 If you do steps X, Y, and Z, you can get that widget to activate, and move the storage. Why not just do that?
As I said above, there may be a way to change the Account Directory value in the UI, but I suspect it only lets you do that if you empty your local storage, which I don’t want to do. If you do find some other series of steps that don’t have that drawback, let me know!
Also, remember that Mailboxes
folder I moved? That holds all the local mailboxes I made, via Mailbox→New Mailbox…. I can’t move that to my central location without delving into the Mail plist as I’ve described above.
Update: There are a couple of good comments that describe both simpler and yet more all-or-nothing solutions than the one I proposed. Have a look!
Also, I originally advised moving the folder Icons
, but it’s both not where I said it was, and you shouldn’t move it. It’s not at ~/Library/Mail/
, it’s just at ~/Library/
, and that’s a good thing, because the icons are used by more than one application. So leave ’em there!
If you want to get a text version of a binary plist, the easiest way is via ‘plutil -convert xml1’.
Oh, and why not just change your home directory to a directory on your data partition? That solves this whole problem rather nicely.
When I moved to Tiger, I backed up all my stuff, then partitioned my disk into 3: one to hold the stable OS, one to hold a beta OS, and one to hold all my user data. Works great.
I’d like to hear your experiences with resizing partitions. I was thinking about using iPartition, but I decided that I needed to get my backup strategy working anyways, so I went with Carbon Copy Cloner with an external firewire drive + burning DVDs.
I’m sure you know this, but the `defaults` command can be useful if you don’t want to go to the trouble of firing up Property List Editor. For example, `defaults read com.apple.mail | grep ‘Library’` shows me all the occurences of the path in the file; adding -n3 to the grep would show me a bit more context, so I knew what I’d need to tell `defaults write` so that it would get things moved.
In your case, you’re editing so much that the Editor is the way to go, but it can be useful in other cases.
would a symbolic link have worked?
I just moved ~/Library/Mail to /Volumes/Data/Mail and then did an
ln -s ~/Library/Mail ~/Library/Data/Mail
on each system volume. Works like a charm and it’s much less work.
That should have been
ln -s ~/Library/Mail /Volumes/Data/Mail
but you get the idea.
Eric:
Re: plist. Is it installed with the OS, or with the Xcode Tools? If it comes along with the Property List Editor, then I’d just as well use the GUI tool.
Re: home directory -> data partition…uh, because I didn’t think of it?
I mean, um, because it’s too big a step? I don’t mind having much of the data replicated, as long as the OS still works. Also, I may want to do something risky on one partition with affecting the rest.
That’s my story and I’m stickin’ to it.
Luis:
Yeah, I’m getting to the resizing partition post, but not just yet. 🙂 I was originally looking at VolumeWorks, but it seems to have gotten some bad feedback. It’s going to be impossible to please everybody with such a potentially destructive tool, of course, but iPartition looks like the way to go.
Paul:
I already knew about defaults, and didn’t use it for exactly the reasons you stated.
a:
Do you go by “a,” or would you maybe prefer something shorter? Also, see Uli’s comments.
Uli:
See my reply to Eric. Certainly both your and his ideas are much simpler to implement than mine.
plutil is part of the BSD package, so it’s part of the regular OS install.