pavement

Partitioning Tips and Tricks

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
m (Getting Hard Disk Information)
(Getting Hard Disk Information)
Line 15: Line 15:
  
 
==Getting Hard Disk 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 port sysutils/smartmontools to extract the model numbers.  Running as root '''smartctl -i /dev/ad4''' (available in the sysutils/smartmontools port) on my system gives output like:
+
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 the sysutils/smartmontools [[ports tree | port]]) to extract the model numbers.  Running '''smartctl -i /dev/ad4''' as root on my system gives output like this:
 
  === START OF INFORMATION SECTION ===
 
  === START OF INFORMATION SECTION ===
 
  Device Model:    WDC WD2500JB-00EVA0
 
  Device Model:    WDC WD2500JB-00EVA0

Revision as of 11:52, 11 March 2006

You may find Hard Disk Partition Sizes useful if you are setting up partitions for the first time.

Contents

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.

Use soft links to your advantage!

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.

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 the sysutils/smartmontools port) 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
Personal tools