Partitioning Tips and Tricks
You may find Hard Disk Partition Sizes useful if you are setting up partitions for the first time.
Make yourself a tiny little partition for /mnt
If you plan to work with removable read-write filesystems - USB drives, IDE or SCSI removables, whatever - make yourself a teeny tiny (like 5 or 10 MB or less) partition for /mnt, and mount the devices to /mnt/removable or /mnt/usbdrive or what have you. That way if a script or a command you run tries to copy a few gigs worth of data and you DON'T have your removable device properly mounted, it will fill your little throwaway /mnt partition that you don't really need (and do it very quickly), instead of you accidentally filling your root partition, which can cause system instabilities.
Don't forget that you can use ln to do really nifty things with your drives and partitions. For example if you've made a too small /usr partition and a very large /data partition, you might want to move the ports tree - which can occupy several gigs of space if you build lots of ports and aren't meticulous about cleaning out old distfiles and work directories - into the larger /data partition. But instead of trying to laboriously fix the entire system so that it looks in /data/ports instead of /usr/ports, what you can do instead is mv /usr/ports /data/ and then ln -s /data/ports /usr/ports - now it looks and works as though the ports tree is still in the default location, but in fact it's operating from the bigger partition!
Another common use for this is /var/db on servers with large databases. By default mysql places databases in /var/db, which is normally a very small partition (256MB or so) - and can be overwritten disturbingly quickly with apache logs and mailserver logs and the like, not to mention the databases themselves. Rather than recompiling or reconfiguring the database server itself to look for its database in a different location, you can simply move the databases to a different partition and soft link to them, just as was described for the ports tree in the paragraph above. Kill the database server, mv /var/db /data/db && ln -s /data/db /var/db and restart the server with no conf changes necessary, and you're in business!
Multiple Disks? Multiple /swap
If you've got two or more disks, you'll speed up performance on them by creating swap partitions on both of them -- no more moving data through the system bus to page files from disk 1 to your swap partition on disk 0. Some folks recommend that swap always be the first slice on the disk (even before / or any other partitions) because it's supposed to increase read/write times for stuff in swap; I've never noticed any real difference when I've done this, but if you have a lot of read/write-intensive operations (big databases, for e.g.,) you may want to consider this.
NOTE: as always, the best way to speed up swap is not to need it in the first place - if you've got heavy swap partition activity, and you can possibly afford to do it, add more RAM. No matter what you do with your swap partition(s), accessing them is always going to be an order of magnitude or three slower than staying in RAM.
Using RAM virtual file systems
Here are instructions on how to use RAM as /tmp (temporary) or /var file systems. tmpfs(5) is suitable for desktops, because it automatically adjusts its file size, unlike mdmfs(8).
To set up a tmpfs(5) filesystem, enter into /etc/fstab:
tmpfs /mydir2 tmpfs rw,-s1g 0 0
To use the md(4) driver, add the following, or similar variable to /etc/rc.conf:
mdmfs(8) can also be mounted through /etc/fstab:
md /mydir1 mfs rw,-s1g 0 0
mdmfs(8) can also mount /var on RAM, but this is only for operating systems that are read-only. On regular installs, files in /var are needed for the operating system to resume normally, which would be regularly flushed on a virtual /var file system.
Virtual RAM filesystem are shared with harddrive swapspace to add capacity. There must be enough combined swap and RAM capacity to contain the virtual filesystem. .iso images can be mounted on swap too. See also mdconfig and related filesystem ram manpages for more information.
Getting Hard Disk Information
Sometimes you need information about the model or manufacturing numbers of drives that are in a running system. If the hard disk supports SMART (most do), you can use the smartctl utility (available from sysutils/smartmontools ) to extract the model numbers. Running smartctl -i /dev/ad4 as root on my system gives output like this:
=== START OF INFORMATION SECTION === Device Model: WDC WD2500JB-00EVA0 Serial Number: WD-WCAEH1028140 Firmware Version: 15.05R15 Device is: In smartctl database [for details use: -P show] ATA Version is: 6 ATA Standard is: Exact ATA specification draft version not indicated Local Time is: Thu Dec 22 10:48:33 2005 CST SMART support is: Available - device has SMART capability. SMART support is: Enabled