UNIX System Administration Handbook - Evi Nemeth [86]
• If you intend to back up a partition, don’t make it bigger than the capacity of your backup device. See page 167.
• Try to cluster information that changes quickly on a few partitions that are backed up frequently.
• It’s a good idea to create a separate filesystem (/tmp) for temporary files because it limits the files to a finite size and saves you from having to back them up.
• If your system keeps log files in /var, it’s a good idea for /var to be a separate disk partition. Many systems ship with /var as part of a very small root partition, making it easy to fill the root and bring the machine to a halt.
Establishing logical volumes
Some systems have a “logical volume manager” that provides a sort of supercharged version of disk partitioning. We can’t cover the details of all the different volume managers and their features here, but they have some characteristics in common that are worth noting. (However, we do show the use of HP’s LVM volume manager in our HP-UX example; see page 143.)
Most volume managers let you group multiple disks or partitions into a logical volume, or metadisk, that appears to the user as a single virtual disk. The components of a logical volume can be put together in various ways. Concatenation keeps each device’s physical blocks together and lines the devices up one after another. Striping interleaves the components so that adjacent virtual blocks are actually spread over multiple physical disks. By reducing single-disk bottlenecks, striping can often provide higher bandwidth and lower latency.
Some volume managers support RAID5 (Redundant Array of Inexpensive Disks), which is striping with an extra checksum. The checksum provides enough redundancy that the logical volume’s data can be reconstructed if one of the disks goes bad. This feature can also be found in smart disk arrays, which are sometimes referred to as hardware RAID.
Mirroring is another common feature of volume managers. A mirrored volume is associated with another volume of the same size. Whenever data is written to one side of the mirror, it is duplicated on the other. Reads are split among the volumes to increase performance. If one volume experiences a hardware failure, the system automatically “fails over” to the other with no interruption in service. Once the original problem has been fixed, the two sides of the mirror must be resynchronized.
Veritas is a logical volume manager that’s supported on both Solaris and HP-UX. Sun also sells a volume manager of its own called Solstice DiskSuite. Vinum is an open source volume manager for FreeBSD; it was inspired by Veritas. Linux has an implementation of kernel RAID support and a separate open source volume manager known as Linux LVM.
Creating UNIX filesystems
Even after a hard disk has been conceptually divided into partitions, it is still not ready to hold UNIX files. The filesystem needs to add a little of its own overhead before the disk is ready for use.
To install a filesystem within a disk partition, you use either newfs or mkfs. newfs is actually just a friendly front end for mkfs. Under old versions of UNIX you had to know a lot about the characteristics of the disk, but this is no longer the case. Unless you are doing something strange, you should be able to build the filesystem by specifying nothing but the newfs command and the partition name.
We will cover the exact procedure in more detail later. The rest of this section discusses how files are placed on the disk when you build the filesystem. If you are not interested, just skip ahead to the next section and revel in blissful ignorance.
Here, we describe the Berkeley Fast File System implemented by McKusick, Joy, and Leffler for 4.2BSD. It’s used by most modern versions of UNIX. A BSD filesystem consists of five structural components:
• A set of inode storage cells
• A set of scattered “superblocks”
• A map of