Unlike the way OS X comes out of the box, FreeBSD usually has you do a single large partition, and then seperate the partition out into 'slices'. This gives you a simple way to overwrite the operating system, and keep installed applications or home directories, even configuration files safe.
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:
% 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
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
% 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
% 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
#!/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"
}
##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
Mac OS X Hints
http://hints.macworld.com/article.php?story=20021011053443661