It only makes sense then that a Unix user setting up OS X 10.2 would want to do the same thing. :) Unfortunately, up to this point, OS X hasn't made that task easy. The volinfo database and autodiskmount daemon both want to mount all slices (volumes in OS X) under /Volumes, and place them all on the desktop.
Here's what you need to do to get your swapfile off your main volumes, get your applications onto their own partition, you home directories safely off onto their own partition, and have the Apple installer love you because everything is where it expects to find them. Did I mention you'll only have to look at a single volume on your desktop too?
[Editor's note: The following article explains exactly what you need to do to accomplish the above tasks. As a result, it requires some use of the terminal, it makes some assumptions about your levels of knowledge, and finally, it's fairly involved. It may also contain advice that you may disagree with; feel free to comment on things as you see fit. Note that I have not tested this hint myself, but I thought the more advanced readers may find it of interest. If you're just starting with OS X, you may wish to save this one for much later!]
Let's begin.
I hope you're starting clean. You might want to back your home directory off onto a CD or a tape, even maybe your iDisk. Just copy it all off. If you have space, copy /Applications too. It's best if you're starting with a brand new 17" iMac out of the box like I did, but if not, backing up those two things will do. Copying /var/mail/username should back up your e-mail.
[Editor's note: Search on "back up" or "backup" here for hints on backing up; you'll want to make sure you get all the invisible files as well.]
Now we're going to wipe everything out. Pop in your OS X 10.2 installer CD, and once the installer comes up, choose the Disk Utility from the drop downs at top. Now, partition off your drive using HFS+ (Mac File System). You can do this however you like, but here's my recommendation:
- Erwin (name it whatever you like, this is where the Operating System will live)
- Applications
- Users
- Swap
- Mail (perhaps)
Alright, we have the drive partitioned. At least for me, OS X 10.2 would not install. It wanted a valid 10.x install to already be there. D'oh! Do what you need to do to get 10.2 installed on Erwin or whatever you named that first partition. Remember to customize and get rid of any Languages you don't need on BOTH installers! It wastes lots and lots of disk space. Alrighty, much waiting and installing later, you now have 10.2 installed. Now install the Developers Tools. You'll need them later.
You'll notice all of your volumes are on the desktop, and if you double click Erwin, Applications and Users are both right there. We need to fix that. Open up a terminal window and type:
% sudo ditto -v -rsrcFork /Applications /Volumes/Applications[Move Mail only if you created a partition for it, obviously.]
% sudo ditto -v -rsrcFork /Users /Volumes/Users
% sudo ditto -v -rsrcFork /var/mail /Volumes/Mail
Next, type sudo pico /etc/fstab. Right here I'm expecting to here dozens upon dozens of people yelling about autodiskmount and how Darwin doesn't use fstab right, and yadda yadda yadda...well guess what? They fixed it. Fstab is no longer slice dependant. Draw up your fstab like this:
LABEL=Users /Users hfs rw 1 2That label command will now pick up your partitions correctly no matter what
LABEL=Applications /Applications hfs rw 1 2
LABEL=Swap /Swap hfs rw 1 2
#Optional
LABEL=Mail /var/mail hfs rw 1 2
slice they show up as. Cool huh? Now we need to load it all into netinfo:
% sudo niload -m fstab / < /etc/fstabAlright, now we need to make sure that when we boot up, things are going to be handled appropriately for the swapfile, and that only our Erwin volume will show up on the desktop. Launch an editor as root on /etc/rc (i.e. sudo pico /etc/rc). Ctrl-V down to where you see this:
##Go down four lines and change this:
# Start the virtual memory system.
##
swapdir=/private/var/vmto this:
swapdir=/Swap/.vmNow scroll down a few more lines until you see this:
dynamic_pager -H 40000000 -L 160000000The above appears on one line, but is shown here on two for readability. Directly after this add these lines:
-S 80000000 -F ${swapdir}/swapfile
##That's what we needed the Developers Tools for. To make sure our swapfile will be hidden from both finder and terminal without special switches, type:
# Hide unneeded volumes from the desktop.
##
/Developer/Tools/SetFile -a V /Applications
/Developer/Tools/SetFile -a V /Users
/Developer/Tools/SetFile -a V /Swap
#Uncomment this if you're putting mail onto it's own partition.
#/Developer/Tools/SetFile -a V /var/mail
% mkdir /Volumes/Swap/.vmNow, reboot into single user mode, (hold down command-s while rebooting). Follow the on-screen instructions for running fsck and mounting /. After you do that, you'll need to run a few more commands:
% cd /Do the following if you're making a mail partition:
% mv Users Users-old
% mkdir Users
% chmod 755 Users
% mv Applications Applications-old
% mkdir Applications
% chmod 755 Applications
% mv /var/mail /var/mail-oldOkay, now for the moment of truth ... type reboot.
% mkdir /var/mail
% chmod 755 /var/mail
You might want to hold down command-V while rebooting to watch what happens and make sure that all goes well. When you get up to your desktop, you should see just Erwin on the desktop. If you double click Erwin, you should see your -old folders, and your new Applications, Users, and Swap, although the icons look like Aliases. You can now move the -old folders to the Trash, if you made Mail, you can do an rm -r /var/mail-old.
You should now be in a position to where if for some reason you need to
re-install the OS you won't lose any programs or user data. If you didn't
want to make a Mail partition, you could do something like this:
% cp /var/mail /Users/mailThat puts your e-mail on the users drive. If you only have a few users and want to be really savvy, then you could do this instead:
% rm -r /var/mail
% ln -s /Users/mail /var/mail
% cp /var/mail/username /Users/username/usernameThat puts the individual's inbox in their home directory so that if they back up their e-mail, they back up their inbox as well. :)
% rm /var/mail/username
% ln /Users/username/username /var/mail/username
Oh, and btw...those who wish to do something similar under previous versions of OSX, here are the changes to the /etc/rc file and the perl script mentioned in the swap section to give you the tools to accomplish it. Save fix_mounts to /usr/local/sbin and run sudo chmod +x fix_mounts on it. Be sure to back up your /etc/rc file before making these changes. Good luck!
fix_mounts:
#!/usr/bin/perl/etc/rc:
use File::Path;
#Fix the mounts that OS X uses by default.
print "Attempting to unmount /Volumes/Swap and mount to /Swap\n";
$slice=undef;
$mountpoint=undef;
$slice=`/bin/df | grep /Swap`;
if($slice ne undef and $slice ne ""){
@swap=split(/\s+/,$slice);
print "@swap[0] is mounted as @swap[-1].\n";
$mountpoint=@swap[0];
chomp($mountpoint);
if($mountpoint eq "/Volumes/Swap"){
if(-e "/Volumes/Swap"){
`umount -v /Volumes/Swap`;
rmtree('/Volumes/Swap');
if (! -e "/Swap") {
mkdir('/Swap');
}
`mount -w -t hfs @swap[0] /Swap`;
print "Remounted.\n";
print "$mountpoint is now mounted to /Swap\n\n";
}
}
else{
print "Action not taken, Swap appears to be mounted at
$mountpoint\n\n";
}
}
else{
print "No action taken, the specified partition does not appear to be
mounted.\n\n"
}
#Next, Applications
print "Attempting to unmount /Volumes/Applications and mount to /Applications\n";
$slice=undef;
$mountpoint=undef;
$slice=`/bin/df | grep /Applications`;
if($slice ne undef and $slice ne ""){
@swap=split(/\s+/,$slice);
print "@applications[0] is mounted as @applications[-1].\n";
$mountpoint=@applications[0];
chomp($mountpoint);
if($mountpoint eq "/Volumes/Applications"){
if(-e "/Volumes/Applications"){
`umount -v /Volumes/Applications`;
rmtree('/Volumes/Applications');
if (! -e "/Applications") {
mkdir('/Applications');
}
`mount -w -t hfs @applications[0] /Applications`;
print "Remounted.\n";
print "$mountpoint is now mounted to /Applications\n\n";
}
}
else{
print "Action not taken, Applications appears to be mounted at
$mountpoint\n\n";
}
}
else{
print "No action taken, the specified partition does not appear to be
mounted.\n\n"
}
# and Finally, Users.
print "Attempting to unmount /Volumes/Users and mount to /Users\n";
$slice=undef;
$mountpoint=undef;
$slice=`/bin/df | grep /Users`;
if($slice ne undef and $slice ne ""){
@swap=split(/\s+/,$slice);
print "@users[0] is mounted as @users[-1].\n";
$mountpoint=@users[0];
chomp($mountpoint);
if($mountpoint eq "/Volumes/Users"){
if(-e "/Volumes/Users"){
`umount -v /Volumes/Users`;
rmtree('/Volumes/Users');
if (! -e "/Users") {
mkdir('/Users');
}
`mount -w -t hfs @users[0] /Users`;
print "Remounted.\n";
print "$mountpoint is now mounted to /Users\n\n";
}
}
else{
print "Action not taken, Users appears to be mounted at
$mountpoint\n\n";
}
}
else{
print "No action taken, the specified partition does not appear to be
mounted.\n\n"
}
Make your Virtual Memory section this:
##I know that's long, but it's very effective!
# Start the virtual memory system.
##
ConsoleMessage "Starting virtual memory"
swapdir=/private/var/vm
swapdrive=/Swap/.vm
#Netboot ONLY
if [ "${netboot}" = "1" ]; then
sh /etc/rc.netboot setup_vm ${swapdir}
fi
## Get rid of any left over, unwanted swap dirs
umount -v /Volumes/Swap*
if [ -d /Volumes/Swap ]; then
ConsoleMessage "***DELETING extant Swap directory(s)***"
mount -uw /
rm -rf /Volumes/Swap*
fi
ConsoleMessage "Checking Disks - /sbin/autodiskmount -a"
/sbin/autodiskmount -a
#Unmount and remount Volumes to the correct location.
ConsoleMessage "Umounting Volumes and Remounting Correctly"
perl /usr/local/sbin/fix_mounts
#Update the volinfo database
if [ ! -f /var/db/volinfo.database ];
then Uninitialized_VSDB=-YES-;
fi
# Make sure the swapfile exists
if [ ! -d ${swapdrive} ]; then
ConsoleMessage "Creating default swap directory"
mount -uw /
mkdir -p -m 755 ${swapdrive}
chown root:wheel ${swapdrive}
else
ConsoleMessage "Prepping swap partition"
rm -rf ${swapdrive}/swap*
fi
dynamic_pager -H 40000000 -L 160000000 -S 80000000 -F ${swapdrive}/swapfile
#Now, hide the Applications, Users, and Swap from the Finder.
ConsoleMessage "Hiding Applications from Finder"
/Developer/Tools/SetFile -a V /Applications
ConsoleMessage "Hiding Users from Finder"
/Developer/Tools/SetFile -a V /Users
ConsoleMessage "Hiding Swap from Finder"
/Developer/Tools/SetFile -a V /Swap
#For debugging, show us one last time the current mounts
Console Message "Current Mounts:"
/bin/df

