Quantcast

How To Move Your Apps and User Files to a Secondary Drive

By Matthew Braga

Words!

One of the obvious benefits of having multiple hard drives is that you have more than one place to put all your stuff. In most cases, this involves creating a couple of ad-hoc folders for music or games on a secondary drive — folders that live outside your traditional home directory. But what if you’d prefer to keep everything in one place? More importantly, what if you want to move your user files or applications to another drive entirely?

The benefit here is not only speed, but reliability. If your boot disk fails, all your files are stored safely on another drive for a speedy recovery. And for those using solid-state disks, you can free up space and keep only the necessities for a speedy OS. It beats messing about with RAID.

Of course, neither Windows or OS X offer an obvious way to do this. By default, both operating systems place all their system files and folders on one drive, and one drive only, leaving you to deal with additional drives on your own. But with a bit of tweaking, it’s easy to move your applications and files to a secondary drive — leaving your computer none the wiser.

OS X 10.5.x and beyond

We’re going to start with OS X, because it actually offers a built-in solution for moving your home directory to another location — in our case, to a separate drive. First, however, we need to make a copy. Though some report Finder’s traditional drag-and-drop process works just fine, we’re going to go the safe way and use Terminal, which should preserve all our ownership and permission data. As root, issue the following command:

ditto -V /Users/Bagels /Volumes/SecondaryHD/Users/Bagels

Depending on the size of your Home folder, this might take a while. Luckily, the next stage is simple. From System Preferences, navigate to Accounts, and click the lock to make changes. Now right-click on your user account — in this case, Bagels — and click Advanced Options. The Home Directory should list the default folder, and the one we’re about to change. Navigate to the location of your copied Home folder on the secondary drive, and click open. Save, restart, and OS X should accept your new Home location as the default directory.

Moving your Applications folder, however, is a bit trickier, as OS X provides no internal method for doing so. In fact, Apple, not surprisingly, discourages the practice, and considers moving your Applications folder anywhere but the startup disk to be at your own risk. However, as far as OS X is concerned, our Applications folder will appear to be in the same place as always, thanks to some redirection trickery — despite being moved to a completely separate drive.

Of course, many applications can comfortably be run outside of OS X’s core Applications folder. In fact, there’s nothing stopping you from simply creating a folder on your secondary hard drive and storing applications there. However, not all apps will play nicely, and some Apple-specific apps will simply refuse to work when copied. With symlinks, we can sidestep this issue nicely.

As with the Home directory, we need copy our Applications to the secondary using the ditto command as follows:

ditto -V /Applications /Volumes/SecondaryHD/Applications

One completed, open Terminal and log in as root. We’re now going to rename the current Applications folder, and create a symbolic link to the new location on our secondary drive.

mv /Applications /Applications.old
ln -s /Volumes/SecondaryHD/Applications /Applications

Restart your computer, and open a few programs to verify that everything still works. There’s a chance you might encounter the odd program that refuses to run across the link, but we’ve yet to experience any problems just yet. Even to picky applications, such as Software Update, it’s as if nothing’s changed.

Windows 7

In Windows, moving your files and applications to a secondary location can be a bit trickier. After all, Microsoft doesn’t exactly make it easy. But with a bit of extra effort, we can make it work. For best results, a fresh install is recommended in case anything goes wrong, but the process should work the same on pre-existing installs. As always, make a back-up first.

In this case, we’re going to move two system folders — the Users directory and Program Files. The process is similar to our symlinks primer from last year, but on a much lower level. Called junction points, the functionality is built into NTFS, which means the links we're about to create are near-invisible to most apps. However, we have to make changes from outside Windows where files are not in use, which requires use of the recovery console. For most users, this can be accessed by pressing F8 at boot, and choosing “Repair your computer,” but is also present on a Windows install DVD.

The odd thing about the Windows Recovery Console is that it tends to move drive letters around, which can lead to confusion. For example, in Windows, the plan is to move our files and applications from Will (C:\) to Norm (E:\). However, in the recovery console, Will is E:\ and Norm is D:\. Still with us? Ultimately, it doesn’t really matter what either of these drives are called, because the junction points we create will still remain in Windows. Just keep your wits about you, and everything will be fine; your setup might be a little bit different.

First, we’ll copy the entire Users directory, using a tool called robocopy. This is important, because it retains everything from empty directories to file permissions, effectively creating a duplicate on your secondary drive. From the recovery console, issue the following command, and be sure to include the flags exactly as they appear:

robocopy "E:\Users" "D:\Users" /COPYALL /MIR /XJ

For the curious, /MIR retains file permissions and ownership, while /XJ tells robocopy to ignore pre-existing junction points which could cause strange, recursive problems. /COPYALL does exactly as the name implies, essentially creating a duplicate. Again, be absolutely sure all of these flags are present.

Now, do the same for Program Files (64-bit users will need to include the “Program Files (x86)” directory too).

robocopy "E:\Program Files" "D:\Program Files" /COPYALL /MIR /XJ
robocopy "E:\Program Files (x86)" "D:\Program Files" /COPYALL /MIR /XJ

With this process completed, we need to remove the old folders:

rmdir "E:\Users" /S /Q
rmdir "E:\Program Files" /S /Q
rmdir "E:\Program Files (x86)" /S /Q

Then, construct junction points in their place:

mklink "E:\Users" "D:\Users" /J
mklink "E:\Program Files" "D:\Program Files" /J
mklink "E:\Program Files (x86)" "D:\Program Files (x86)" /J

Now, reboot. If all goes well, you should see something similar to the image below. Both Program Files and Users directories still exist, but now possess a small shortcut icon, indicating the junction point we've just created. What's interesting is that Windows still thinks you're browsing C:\, despite your files being located on another drive entirely. The link we've created is that seamless. Try installing a few applications and you'll see what we mean.

Have any tips or suggestions? Do you have a similar setup, or something completely different? Be sure to let us know below.