Preinstallation Planning

team bbl


Before installing Linux on the system, there are several things worth considering that might help optimize the performance of the operating system and the applications that run on it later. These areas include the following:

  • Placing partitions

  • Using multiple hard drives

  • Selecting file systems

  • Converting file systems

  • Configuring RAID

Ready? Let's examine each in further detail.

Partition Placement

At a minimum, Linux requires a root and a swap partition. Where these and other frequently accessed partitions reside on disks ultimately impacts system performance. Following are some of the recommendations for placement of the root, swap, and other frequently accessed partitions that take advantage of the disk geometry:

  • Use separate partitions for root, swap, /var, /usr, and /home.

  • Most drives today pack more sectors on the outer tracks of the hard drive platter than on the inner tracks, so it's much faster to read and write data from the outer tracks. Lower-numbered partitions are usually allocated at the outer tracks (for example, /dev/hda1 is closer to the drive's outer edge than /dev/hda3), so place partitions that require frequent access first.

  • The first partition should be the swap partition (to optimize memory swap operations).

  • The next partition should be /var because log entries are frequently written to /var/log.

  • The next partition should be /usr, because base system utilities and commands are placed in /usr.

  • The root and /home partitions can reside near the end of the drive.

Now that we have considered how best to place the most frequently used partitions on a hard drive, we will look at how to take advantage of your multiple hard drivesif you have more than one in your system.

Using Multiple Hard Drives

Most systems today have more than one hard drive. If your system has only one drive, and if performance is really important to you (which is why you are reading this book in the first place!), you may need to seriously consider adding more drives to your system to improve performance. To take full advantage of multiple drives, you'll need to do the following:

  • Place frequently accessed partitions on the faster drives.

  • If the drives are relatively equal in performance, place frequently used partitions on alternate drives. For example, place /var on one drive and /usr on another drive. The swap partition should be on its own drive.

  • Consider using RAID if you have multiple drives with relatively equal performance. (This will be discussed in more detail later.)

  • Place each drive as the master device on its own I/O channel (for example, IDE) to maximize bus throughput. You will need to modify the file system table (/etc/fstab) after moving drives across I/O channels because the device name will change. If the drive contains the root or /boot partition, you need to edit the grub /boot/grub/menu.lst file as well.

When using multiple hard drives, you need to make some decisions in modifying the file system table. In the next section, we'll discuss selecting file systems.

Selecting File Systems

In addition to the original ext2 file system, new enterprise Linux distributions, such as RHEL 3, RHEL 4, and SLES 9, also support journaled file system technology, such as ext3 and ReiserFS. XFS is also included in several Linux distributions but may not be fully supported. Table 1.1 shows the general advantages and disadvantages of each type of file system.

Table 1.1. File System Types

File System Type

Comment

ext3

Easy to upgrade from existing ext2 file system

ReiserFS

Best performance with small files; fully supported by major enterprise distributions

XFS

Best performance, especially with large files


Some Linux distributions, such as Red Hat and SUSE, also include the IBM JFS (Journaled File System), which is designed for high-performance e-commerce file servers and is used on many IBM enterprise servers supporting high-speed corporate intranets. The selection of file system(s) ultimately depends on the role and the expected workload the system is supposed to handle. Careful planning before installation is highly recommended. Making the right decisions during installation can save you headaches later on.

Several mkfs and mount options might yield file system performance improvements under specific circumstances. See Chapter 11, "File System Tuning," for a complete discussion of tuning file systems for improved performance on Linux.

Converting File Systems

If the existing file system is ext2, converting it to ext3 can be done using the tune2fs command. For example, if you want to convert the existing ext2 partition /dev/hda1 to ext3, issue the following command:

 tune2fs j /dev/hda1 

Converting to a file system type other than ext3 is more time-consuming. For example, to convert /usr, which is on /dev/hdb2, to ReiserFS, do the following:

  1. Choose an empty partition that is larger than /dev/hdb2say, /dev/hdb3as a temporary partition.

  2. Format the temporary partition:

     mkreiserfs /dev/hdb3 

  3. Create a temporary directory:

     mkdir /mnt/tempfs 

  4. Copy the contents of /usr to a temporary directory:

     cp preserver=all R /usr/mnt/tempfs 

  5. Unmount /usr:

     umount /usr 

  6. Unmount /mnt/tempfs:

     umount /mnt/tempfs 

  7. Mount /usr on /dev/hdb3:

     mount /dev/hdb3 /usr 

  8. Reformat the old /usr partition:

     mkreiserfs /dev/hdb2     mount /dev/hdb2 /mnt/tempfs 

  9. Copy the contents of /usr back to its original partition:

     cp preserve=all R /usr /mnt/tempfs 

  10. Unmount /usr:

     umount /usr 

  11. Unmount /mnt/tempfs:

     umount /mnt/tempfs 

  12. Remount /usr on its original partition:

     mount /dev/hdb2 /usr 

Repeat this process for other directories you want to convert.

The final step for preinstallation planning for optimization is configuring RAID.

Configuring RAID

RAID (Redundant Array of Inexpensive Disks) lets you configure multiple physical disks into a single virtual disk, thereby taking advantage of multiple disks and I/O channels working in parallel on a disk I/O operation. Many Linux distributions, especially enterprise versions, now provide RAID support. The easiest way to configure RAID is during installation. However, RAID can be configured on a preinstalled system as well. Here's how:

  1. If new partitions are created, modify /etc/fstab appropriately. If the root and /boot partitions are on these new partitions, modify the /boot/grub/menu.lst file accordingly.

  2. If existing partitions are combined to create a new RAID partition:

    • Verify that the raidtools package is present:

       mkraid V 

    • Verify that RAID support is compiled into the kernel:

       cat /proc/mdstat 

    • Create or modify /etc/raidtab. Create the following entry for each of the RAID devices:

       /* Create RAID device md0 */ raiddev /dev/md         0    /* New RAID device */ raid-level              0    /* RAID 0 as example here */ nr-raid-disk            2    /* Assume two disks */ /* Automatically detect RAID devices on boot */ persistent-superblock  1 chunk-size             32    /* Writes 32 KB of data to each disk */ device                       /dev/hda1 raid-disk              0 device                       /dev/hdc1 raid-disk              1 

    Large chunk sizes are better when working with larger files; smaller chunk sizes are more suitable for working with smaller files.

  3. Create the RAID device:

     mkraid /dev/md0  

  4. View the status of the RAID devices:

     cat /proc/mdstat  

  5. Format the RAID device with the ReiserFS file system, for example:

     mkreiserfs /dev/md0 

  6. Modify /etc/fstab to indicate which partition(s) are on the RAID device. For example, to have /usr on the RAID device /dev/md0, make sure that the /usr line in /etc/fstab points to /dev/md0.

To squeeze the most performance out of the disk I/O subsystem, make sure that DMA and 32-bit transfers are enabled. This can be done via the hdparm utility, as follows (all commands are examples only):

  1. Verify that DMA is enabled:

     hdparm d /dev/hda  

  2. If DMS is not enabled, enable it by issuing the following command:

     hdparm dl /dev/hda  

  3. Verify that 32-bit transfers are enabled:

     hdparm c /dev/hda   

  4. If 32-bit transfers are not enabled, enable them by issuing the following command:

     hdparm cl /dev/hda 

  5. Verify the effectiveness of the options by running simple disk read tests as follows:

     hdparm Tt/dev/had 

So far, we have discussed how best to set up the disk I/O subsystem for optimal performance. Now we need to look at two key configurable kernel features that are available on the 2.6 kernel. These 2.6 kernel features can impact performance for some application workloads.

    team bbl



    Performance Tuning for Linux Servers
    Performance Tuning for Linux Servers
    ISBN: 0137136285
    EAN: 2147483647
    Year: 2006
    Pages: 254

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net