Customizing OS X When Using Multiple Volumes

Besides the obvious uses for multiple volumes—storing files and alternate systems—there are a few other things you can do. In the sections that follow I'll show you how to move a user folder (or all user directories) to a non-boot volume, and how to move your system swap files to a non-boot volume.

Moving a User Folder—or All User Folders—to a Non-Boot Volume

User Level:

admin

Affects:

individual user or all users

Terminal:

no

Although it's common in large network environments for user directories to be stored some-where besides the local computer (e.g., on a central server), most home users have never even considered such a setup. Nevertheless, there are a few situations where you might want to consider it. For example, you can keep your user folder(s) on a separate volume from the rest of your OS X files in order to make backing up your user folder(s) easier. Or perhaps you test a lot of software—you can keep your user folder(s) on a non-boot volume, and if your OS X installation becomes unstable, you can reformat the drive and reinstall OS X, keeping your user folder(s) intact. (After you reinstall, you'll have to reassign your home directories to their location on the alternative volume.) Or maybe you have multiple OS X startup volumes—you can use a single user folder for all of them. Whatever the case, if you want to move your user folder(s) to another volume, the next two sections will show you how.

Warning 

Do not move user folders to a removable volume. At the time of this writing, OS X does not properly handle the situation where a volume that contains user folders is not mounted. If you try to log in to an account that resides on a removable volume, and that volume is not mounted at the time, you'll not only not be able to access the account then, but you'll never be able to access it again without first using Terminal to delete a bunch of invisible files (which is too messy to get into here).

Moving a Single User Folder to a Non-Boot Volume

User Level:

admin

Affects:

individual or multiple users

Terminal:

yes

Although it's possible to move a user directory to a different volume using a combination of Terminal and NetInfo Manager, it's easier, and quicker, to do the whole shebang using Terminal.

  1. Type sudo ditto -rsrc /Users/username /Volumes/volumename/Users/username' <RETURN>, where username is the short name of the user whose folder you wish to move, and volumename is the name of the volume to which you wish to move it; provide your admin password when prompted. The ditto command copies the user folder (including any hidden files); the -rsrc option ensures that all resource forks are copied.

  2. Type sudo niutil -createprop / /Users/username home /Volumes/volumename/Users/username' <RETURN>. This command uses the niutil command to reassign your home directory from the original location to the new location. In fact, if you were to use NetInfo Manager to make this change, you'd actually be changing the home property for the user username from /Users/username to /Volumes/volumename/Users/username.

  3. If you moved your own account, log out and then back in, and make sure your user folder was copied and reassigned properly; otherwise have the user whose folder you moved log in and check. To do this, open a Finder window and click the Home button in the toolbar (or choose Go Home, or press shift+command+H); make sure that the path to the folder is /Volumes/volumename/Users/username.

  4. Assuming everything is working properly, launch Terminal and type sudo rm -dr /Users/username/ <RETURN>; provide your admin password when prompted. This command deletes your original user folder.

  5. Type sudo ln -s /Volumes/volumename/Users/username' /Users/username <RETURN>. This command creates a symbolic link (similar to an alias) from the Users folder on the boot volume to your new user folder on volumename. This step isn't absolutely necessary, but it makes it easier to access the moved user folder, since the link to the folder will show up in the standard Users directory on the boot volume.

Tip 

The only application that seems to have a problem with your user folder being located on a different volume than the boot volume is Microsoft Excel. If this bug affects you, locate the file called Carbon Registration Database from the ~/Library/Preferences/Microsoft folder of any original user folder (i.e., a user folder that is still located in /Users). Copy this file to the same folder in any new user folder (i.e., a user folder on the non-boot volume). This should allow Excel to run.

Moving All User Folders to a Non-Boot Volume

User Level:

admin

Affects:

all users

Terminal:

yes

If you want to move all user folders to another volume, the commands are similar, but not identical:

  1. Type sudo ditto -rsrc /Users /Volumes/volumename/Users' <RETURN>, where volume-name is the name of the volume to which you wish to move the user folders; provide your admin password when prompted.

  2. For each user, type sudo niutil -createprop / /Users/username home /Volumes/volumename/Users/username' <RETURN>. (In other words, you'll need to type this command once for each user.)

  3. Log out and then back in to make sure the user folders were copied and reassigned properly.

  4. Assuming everything is working properly, launch Terminal and, for each user folder except the Shared user folder, type sudo rm -dr /Users/username/ <RETURN>; provide your admin password when prompted. (Again, you'll have to use this command once for each user.)

  5. For each user (again, except for the Shared user folder), type sudo ln -s /Volumes/volumename/Users/username' /Users/username <RETURN> to create a link from the Users folder on the boot volume to your new user folder on volumename.

Note 

The reason you need to delete each user folder and link to each separately, except for the Shared folder, is that some applications require you to have the Shared folder inside the Users folder on the boot volume. If you create a new user(s) after completing this procedure, you'll need to perform Steps 2–5 for that user(s).

Using a Non-Boot Volume for System Swap Files

User Level:

admin

Affects:

computer

Terminal:

no

As mentioned earlier, one advantage of OS X is its superior memory management. Part of this memory system is the ability to use sections of the boot drive as virtual memory—hard drive space that stores less-recently-used contents of your computer's actual RAM in order to make room for data currently being used. (For the curious, this process is called paging.) When the data stored on the hard drive is needed, it's quickly moved back into real RAM. This memory trickery allows your computer to function as if it has far more memory than it actually does.

These sections of the hard drive used for temporary RAM offloading are called swap files, because the OS swaps data to and from them frequently. Although this process is very efficient, it has a few drawbacks. First, these swap files take up hard drive space that you may want to use for "real" files. Second, swap files themselves contribute to drive fragmentation (discussed in Chapter 14). The less free space you have on your boot volume, the worse each of these two drawbacks becomes. Finally, virtual memory works somewhat faster when swap files reside on a separate hard drive altogether, since the "swap file" drive can work independently from the system/data drive.

To get around these drawbacks, some users prefer to use a different volume altogether— one dedicated to the task—for swap files. By telling OS X to use a different volume for swap files, you don't have to worry about taking hard drive space away from other files, fragmenting your swap files, or contributing to fragmentation of your boot volume.

Note 

One of the advantages of having your swap files on a separate volume—speed—is only fully realized if the swap volume actually resides on a separate disk from your operating system, documents, applications, etc. Locating your swap files on a different partition of the same hard drive used as the boot volume will gain you benefits in terms of fragmentation, but will most likely result in a slight decrease in performance—the drive heads will still have to alternate between accessing swap files and other files, but will have to travel further to do so (increased average seek time, as described earlier in the chapter).

If you have an extra hard drive or driver partition, and you'd like to try this procedure, the easiest way is to use the shareware Xupport (http://www.computer-support.ch/) or Swap-SwapVM (http://www.sciencequest.org/support/computers/mac/repair_topics/application_specific/osx/swapswapvm.html) Xupport is an excellent, all-around utility that provides a nice interface to many Unix commands—I recommend it even if you don't intend to change your swap file location. Here's how to use it to move your swap files:

  1. Launch Xupport, and click the Optimize button in the Xupport toolbar. The Optimize panel will drop down.

  2. At the bottom of the Optimize panel is the "Swap file" section. From the pop-up menu, choose the volume you want OS X to use for virtual memory swap files.

  3. After you choose a volume, you'll see a dialog that tells you to press the Set button and restart your computer. Click OK, and then click the Set button.

  4. You'll get a second dialog asking if you're sure you want to change the swap file location to the chosen volume. Click OK, and then enter your admin password when prompted.

  5. Restart your Mac.

Once you restart, your Mac will store its swap files on the chosen volume. To verify this, open a new Finder window and choose Go Go to Folder (or press shift+command+G); type /Volumes/volumename/vm in the "Go to the folder" field (where volumename is the name of the volume you chose for your swap files), and then click Go. This will take you to the folder on that volume where the virtual memory swap files are stored. You should see a file named swapfile0; if you do, the procedure was successful.

Warning 

As with moving user directories, do not move your system swap files to a removable volume, as you're asking for trouble. If you remove the volume while the system is running, or if the volume is not present when the computer boots, your computer won't have its swap space available, which is a bad thing. (OS X should automatically relocate its swap file storage to the boot volume, but I've heard reports that this doesn't always happen properly.)




Mac OS X Power Tools
Mac OS X Power Tools
ISBN: 0782141927
EAN: 2147483647
Year: 2005
Pages: 152
Authors: Dan Frakes

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net