Adding/Removing Storage

Because the need for additional disk space is never-ending, a system administrator often will need to add disk space, while often removing older, smaller drives. In this section, we will go over the basic process of adding and removing storage on a Red Hat Linux system.

Adding Storage

The process of adding storage to a Red Hat Linux system is relatively straightforward. Here are the basic steps:

  1. Installing the hardware

  2. Partitioning

  3. Formatting the partition(s)

  4. Updating /etc/fstab

  5. Modifying backup schedule

Let us look at each step in more detail.

Installing the Hardware

Before anything else can be done, the new disk drive has to be in place and accessible. While there are many different hardware configurations possible, we will go through the two most common situations — adding an IDE or SCSI disk drive. Even with other configurations, the basic steps outlined here still apply.

TipTip
 

No matter what storage hardware you use, you should always consider the load a new disk drive will add to your computer's I/O subsystem. In particular, you should try to spread the disk I/O load over all available channels/buses. From a performance standpoint, this is far better than putting all disk drives on one channel and leaving another one empty and idle.

Adding IDE Disk Drives

IDE disk drives are mostly used in desktop and lower-end server systems. Nearly all systems in these classes have built-in IDE controllers with multiple IDE channels — normally two or four.

Each channel can support two devices — one master, and one slave. The two devices are connected to the channel with a single cable. Therefore, the first step is to see which channels have available space for an addition disk drive. You will find one of three situations:

  • There is a channel with only one disk drive connected to it

  • There is a channel with no disk drive connected to it

  • There is no space available

The first situation is usually the easiest, as it is very likely that the cable in place has an unused connector into which the new disk drive can be plugged. However, if the cable in place only has two connectors (one for the channel and one for the already-installed disk drive), then it will be necessary to replace the existing cable with a three-connector model.

Before installing the new disk drive, make sure that the two disk drives sharing the channel are appropriately configured (one as master and one as slave).

The second situation is a bit more difficult, if only for the reason that a cable must be purchased in order to connect a disk drive to the channel. The new disk drive may be configured as master or slave (although traditionally the first disk drive on a channel is normally configured as master).

In the third situation, there is no space left for an additional disk drive. You must then make a decision. Do you:

  • Acquire an IDE controller card, and install it

  • Replace one of the installed disk drives with the newer, larger one

Adding a controller card entails checking hardware compatibility, physical capacity, and software compatibility. Basically, the card must be compatible with your computer's bus slots, there must be an open slot for it, and it must be supported by Red Hat Linux.

Replacing an installed disk drive presents a unique problem: what to do with the data on the disk? There are a few possible approaches:

  • Write the data to a backup device and restore after installing the new disk drive

  • Use your network to copy the data to another system with sufficient free space, restoring the data after installing the new disk drive

  • Use the space occupied by a third disk drive by:

    1. Temporarily removing some other disk drive

    2. Temporarily installing the new disk drive in its place

    3. Copying the data to the new disk drive

    4. Removing the old disk drive

    5. Replacing it with the new disk drive

    6. Reinstalling the temporarily removed disk drive

  • Temporarily install the original disk drive and the new disk drive in another computer, copy the data to the new disk drive, and then install the new disk drive in the original computer

As you can see, sometimes a fair bit of effort must be expended to get the data (and the new hardware) where it needs to go. Next, we will look at working with SCSI disk drives.

Adding SCSI Disk Drives

SCSI disk drives normally are used in higher-end workstations and server systems. Unlike IDE-based systems, SCSI systems may or may not have built-in SCSI controllers; some do, while others use a separate SCSI controller card.

The capabilities of SCSI controllers (whether built-in or not) also vary widely. It may supply a narrow or wide SCSI bus. The bus speed may be normal, fast, ultra, utra2, or ultra160.

If these terms are unfamiliar to you, you will have to determine which term applies to your hardware configuration and select an appropriate new disk drive. The best resource for this information would be the documentation for your system and/or SCSI adapter.

You must then determine how many SCSI buses are available on your system, and which ones have available space for a new disk drive. The number of devices supported by a SCSI bus will vary according to the bus width:

  • Narrow (8-bit) SCSI bus — 7 devices (plus controller)

  • Wide (16-bit) SCSI bus — 15 devices (plus controller)

The first step is to see which buses have available space for an additional disk drive. You will find one of three situations:

  • There is a bus with less than the maximum number of disk drives connected to it

  • There is a bus with no disk drives connected to it

  • There is no space available on any bus

The first situation is usually the easiest, as it is likely that the cable in place has an unused connector into which the new disk drive can be plugged. However, if the cable in place does not have an unused connector, it will be necessary to replace the existing cable with one that has at least one more connector.

The second situation is a bit more difficult, if only for the reason that a cable must be purchased in order to connect a disk drive to the bus.

If there is no space left for an additional disk drive, you must make a decision. Do you:

  • Acquire and install a SCSI controller card

  • Replace one of the installed disk drives with the new one

Adding a controller card entails checking hardware compatibility, physical capacity, and software compatibility. Basically, the card must be compatible with your computer's bus slots, there must be an open slot for it, and it must be supported by Red Hat Linux.

Replacing an installed disk drive presents a unique problem: what to do with the data on the disk? There are a few possible approaches:

  • Write the data to a backup device, and restore after installing the new disk drive

  • Use your network to copy the data to another system with sufficient free space, and restore after installing the new disk drive

  • Use the space occupied by a third disk drive by:

    1. Temporarily removing some other disk drive

    2. Temporarily installing the new disk drive in its place

    3. Copying the data to the new disk drive

    4. Removing the old disk drive

    5. Replacing it with the new disk drive

    6. Reinstalling the temporarily removed disk drive

  • Temporarily install the original disk drive and the new disk drive in another computer, copy the data to the new disk drive, and then install the new disk drive in the original computer

Once you have an available connector in which to plug the new disk drive, you must make sure that the drive's SCSI ID is set appropriately. To do this, you must know what all of the other devices on the bus (including the controller) are using for their SCSI IDs. The easiest way to do this is to access the SCSI controller's BIOS. This is normally done by pressing a specific key sequence during the system's power-up sequence. You can then view the SCSI controller's configuration, along with the devices attached to all of its buses.

Next, you must consider proper bus termination. When adding a new disk drive, the rule is actually quite simple — if the new disk drive is the last (or only) device on the bus, it must have termination enabled. Otherwise, termination must be disabled.

At this point, you can move on to the next step in the process — partitioning your new disk drive.

Partitioning

Once the disk drive has been installed, it is time to create one or more partitions to make the space available to Red Hat Linux. There are several different ways of doing this:

  • Using the command-line fdisk utility program

  • Using parted, another command-line utility program

Although the tools may be different, the basic steps are the same:

  1. Select the new disk drive (the drive's name can be found by following the device naming conventions outlined in the Section called Device Naming Conventions

  2. View the disk drive's partition table, to ensure that the disk drive to be partitioned is, in fact, the correct one

  3. Delete any unwanted partitions that may already be present on the new disk drive

  4. Create the new partition(s), being sure to specify the desired size and file system type

  5. Save your changes and exit the partitioning program

WarningWarning
 

When partitioning a new disk drive, it is vital that you are sure the disk drive you are about to partition is the correct one. Otherwise, you may inadvertently partition a disk drive that is already in use, which will result in lost data.

Also make sure you have decided on the best partition size. Always give this matter serious thought, because changing it later will be much more difficult.

Formatting the Partition(s)

At this point, the new disk drive has one or more partitions that have been written to it. However, before the space contained within those partitions can be used, the disk drive must first be formatted. By formatting, you are selecting a specific file system to be used — this is the step that turns that blank space into an EXT3 file system, for example. As such, this is a pivotal time in the life of this disk drive; the choices you make here cannot be changed later without going through a great deal of work.

This is the time to look at the mkfs.<fstype> man page for the file system you have selected. For example, look at the mkfs.ext3 man page to see the options available to you when creating a new ext3 file system. In general, the mkfs.* programs provide reasonable defaults for most configurations; however here are some of the options that system administrators most commonly change:

  • Setting a volume label for later use in /etc/fstab

  • On very large hard disks, setting a lower percentage of space reserved for the super-user

  • Setting a non-standard block size and/or bytes per inode for configurations that must support either very large or very small files

  • Checking for back blocks before formatting

The disk drive is now properly configured for use.

Next, it is always best to double-check your work by manually mounting the partition(s) and making sure everything is in order. Once everything checks out, it is time to configure your Red Hat Linux system to automatically mount the new file system(s) whenever it boots.

Updating /etc/fstab

As outlined in the Section called Mounting File Systems Automatically with /etc/fstab, you must add the necessary line(s) to /etc/fstab in order to ensure that the new file system(s) are mounted whenever the system reboots. Once you have updated /etc/fstab, test your work by issuing an "incomplete" mount, specifying only the device or mount point. Something similar to one of the following will be sufficient:

mount /home
mount /dev/hda3

(Replacing /home or /dev/hda3 with the mount point or device for your specific situation.)

If the appropriate /etc/fstab entry is correct, mount will obtain the missing information from it, and complete the file system mount.

At this point you can be relatively confident that the new file system will be there the next time the system boots (although if you can afford a quick reboot, it would not hurt to do so — just to be sure).

Next, we will look at the one of the most commonly-forgotten steps in the process of adding a new file system.

Modifying the Backup Schedule

Assuming that the new file system is more than a temporary storage area requiring no backups, this is the time to make the necessary changes to your backup procedures to ensure that the new file system will be backed up. The exact nature of what you will need to do to make this happen depends on the way that backups are performed on your system. However, there are some points to keep in mind while making the necessary changes:

  • Consider what the optimal frequency of backups should be

  • Determine what backup style would be most appropriate (full backups only, full with incrementals, full with differentials, etc.)

  • Consider the impact of the new file system on your backup media usage, particularly as the new file system starts to fill

  • Judge whether the additional backup will cause the backups to take too long and start using time outside of your backup window

  • Make sure that these changes are communicated to the people that need to know (other system administrators, operations personnel, etc.)

Once all this is done, your new disk space is ready for use.

Removing Storage

Removing disk space from a system is straightforward, with the steps being similar to the installation sequence (except, of course, in reverse):

  1. Move any data to be saved off the disk drive

  2. Remove the disk drive from the backup system

  3. Remove the disk drive's partitions from /etc/fstab

  4. Erase the contents of the disk drive

  5. Remove the disk drive

As you can see, compared to the installation process, there are a few extra steps here.

Moving Data Off the Disk Drive

Should there be any data on the disk drive that must be saved, the first thing to do is to determine where the data should go. The decision here depends mainly on what is going to be done with the data. For example, if the data is no longer going to be actively used, it should be archived, probably in the same manner as your system backups. This means that now is the time to consider appropriate retention periods for this final backup.

On the other hand, if the data will still be used, then the data will need to reside on the system most appropriate for that usage. Of course, if this is the case, perhaps it would be easiest to move the data by simply reinstalling the disk drive on the new system. If you do this, you should make a full backup of the data before doing so — people have dropped disk drives full of valuable data (losing everything) while doing nothing more than walking across a room.

Erase the Contents of the Disk Drive

No matter whether the disk drive has valuable data or not, it is a good idea to always erase a disk drive's contents prior to reassigning or relinquishing control of it. While the obvious reason is to make sure that no information remains on the disk drive, it is also a good time to check the disk drive's health by performing a read-write test for bad blocks on the entire drive.

Doing this under Red Hat Linux is simple. After unmounting all of the disk drive's partitions, issue the following command (while logged in as root):

badblocks -ws /dev/fd0

You will see the following output while badblocks runs:

Writing pattern 0xaaaaaaaa: done                        
Reading and comparing: done                        
Writing pattern 0x55555555: done                        
Reading and comparing: done                        
Writing pattern 0xffffffff: done                        
Reading and comparing: done                        
Writing pattern 0x00000000: done                        
Reading and comparing: done                        

In this example, a diskette (/dev/fd0) was erased; however, erasing a hard disk is done the same way, using full-device access (for example, /dev/hda for the first IDE hard disk)

ImportantImportant
 

Many companies (and government agencies) have specific methods of erasing data from disk drives and other data storage media. You should always be sure you understand and abide by these requirements; in many cases there are legal ramifications if you fail to do so. The example above should in no way be considered the ultimate method of wiping a disk drive.