5.9.6. Adding/Removing Storage


While most of the steps required to add or remove storage depend more on the system hardware than the system software, there are aspects of the procedure that are specific to your operating environment. This section explores the steps necessary to add and remove storage that are specific to Red Hat Enterprise Linux.

5.9.6.1. Adding Storage

The process of adding storage to a Red Hat Enterprise Linux system is relatively straightforward. Here are the steps that are specific to Red Hat Enterprise Linux:
  • Partitioning
  • Formatting the partition(s)
  • Updating /etc/fstab
The following sections explore each step in more detail.
5.9.6.1.1. 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 Enterprise Linux.
There is more than one way 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. In the following example, the commands necessary to perform these steps using fdisk are included:
  1. Select the new disk drive (the drive's name can be identified by following the device naming conventions outlined in Section 5.9.1, “Device Naming Conventions”). Using fdisk, this is done by including the device name when you start fdisk:
     fdisk /dev/hda 
  2. View the disk drive's partition table, to ensure that the disk drive to be partitioned is, in fact, the correct one. In our example, fdisk displays the partition table by using the p command:
     Command (m for help): p Disk /dev/hda: 255 heads, 63 sectors, 1244 cylinders Units = cylinders of 16065 * 512 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 17 136521 83 Linux /dev/hda2 18 83 530145 82 Linux swap /dev/hda3 84 475 3148740 83 Linux /dev/hda4 476 1244 6176992+ 83 Linux 
  3. Delete any unwanted partitions that may already be present on the new disk drive. This is done using the d command in fdisk:
     Command (m for help): d Partition number (1-4): 1
    The process would be repeated for all unneeded partitions present on the disk drive.
  4. Create the new partition(s), being sure to specify the desired size and file system type. Using fdisk, this is a two-step process -- first, creating the partition (using the n command):
     Command (m for help): n Command action e extended p primary partition (1-4) p  Partition number (1-4): 1 First cylinder (1-767): 1 Last cylinder or +size or +sizeM or +sizeK: +512M 
    Second, by setting the file system type (using the t command):
     Command (m for help): t Partition number (1-4): 1 Hex code (type L to list codes): 82
    Partition type 82 represents a Linux swap partition.
  5. Save your changes and exit the partitioning program. This is done in fdisk by using the w command:
     Command (m for help): w

Warning

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, resulting in lost data.
Also make sure you have decided on the best partition size. Always give this matter serious thought, because changing it later is much more difficult than taking a bit of time now to think things through.
5.9.6.1.2. Formatting the Partition(s)
Formatting partitions under Red Hat Enterprise Linux is done using the mkfs utility program. However, mkfs does not actually do the work of writing the file-system-specific information onto a disk drive; instead it passes control to one of several other programs that actually create the file system.
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.<fstype> 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 bad blocks before formatting
Once file systems have been created on all the appropriate partitions, the disk drive is 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 Enterprise Linux system to automatically mount the new file system(s) whenever it boots.
5.9.6.1.3. Updating /etc/fstab
As outlined in Section 5.9.5, “Mounting File Systems Automatically with /etc/fstab, you must add the necessary line(s) to /etc/fstab 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 commands is 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 obtains the missing information from it and completes the mount operation.
At this point you can be relatively confident that /etc/fstab is configured properly to automatically mount the new storage every time the system boots (although if you can afford a quick reboot, it would not hurt to do so -- just to be sure).
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.