Eventually, you will need to expand your system's storage capacity. Your users will demand more space for their files or the latest applications will require more space than you've allocated. One way to satisfy this demand is to install additional hard drives.
(You could purchase an entirely new machine, but that might be overkill as well as outside your budget.)
- Purchasing a new hard drive
When purchasing a new hard drive, you must consider drive interface, performance, capacity, and price. In addition, your new hard drive must match your system's interface support. If you have an IDE interface, then you must purchase an IDE drive. The same is true for SCSI. If you have both types of interface, then the choice is yours. Choose reputable vendors, adequate capacity, disks with a high transfer rate, and price within your budget.
About the only time the average computer user is not concerned with running out of storage space is the first day a PC is in use.
After you start installing programs, copying over gigabytes of backup archives, and filling folders with photos,
music, and videos, and those initially large gigabytes appear to offer less storage than originally thought.
It may take a month, it may take a year, or it may take two, but no matter how much free storage you start out with,
you are eventually going to need more. About the only time the average computer user is not concerned with running out of storage space is the first day a PC is in use. Start installing programs, copying over tons of backup archives, and filling folders with photos, music, and videos, and all those initially voluminous gigabytes can melt away before your eyes. It may take a month, it may take a year, or it may take two, but no matter how much free storage you start out with, you're eventually going to need more. Remember the old axiom: Data always expands to fill available space.
There are several steps involved in installing a new hard drive into your Linux machine. The following table outlines the installment steps::
1. |
Physically install your hard drive. |
You will need to turn off your Linux system to do this, so you should notify your users of the expected down time. |
2. |
Prepare the drive according to the manufacturer's guidelines. |
For a SCSI drive, this might involve low-level formatting of the drive from the SCSI controller's BIOS. |
3. |
Create the hard drive's partition table using the fdisk or cfdisk programs. |
As you create partitions, you will add both Linux ext2 and swap partitions. |
4. |
Initialize the new ext2 partitions with the mke2fs command. |
This command places filesystem information onto the partition so that you can store data there. The syntax of this command is mke2fs <partition> ; for example, mke2fs /dev/hdb1 .
|
5. |
Initialize the new swap partitions with the mkswap command. |
This command prepares the swap space for Linux's use. The syntax of this command is mkswap <partition> ; for example, mkswap /dev/hdb2 . |
6. |
Edit /etc/fstab , adding new entries for the partitions. |
For example, to add an automounting floppy drive you would add the line /dev/fd0 /mnt/floppy ext2 noauto,owner 0 0 to the /etc/fstab file. |
7. |
Make the directories for each of the mount points you specified in /etc/fstab . |
To make a directory, use the command mkdir <directory name> . |
8. |
To gain immediate access to your new filesystems, mount them with the mount command. |
The syntax of this command is mount <partition> ; for example, mount /dev/hdb1 .
|
9. |
Enable the new swap partitions using swapon -a . |
The option -a enables all swap found in the /etc/fstab file. |
The commands fdisk, cfdisk, and mke2fs are destructive. fdisk and cfdisk update the disk's partition table. If you mistakenly type the wrong
device name, you will lose access to all existing data on modified partitions! mke2fs places a new, formatted filesystem onto the partition.
If you mistakenly type the wrong partition name, then you will overwrite all existing data!
The Simulation below walks you through adding a 3.2GB IDE hard drive to an existing Linux system.
Here's an updated version of the text for 2025, reflecting modern practices, technologies, and conventions for adding a storage drive to a Linux system. You are installing a new storage drive to provide extra space on your web server. The drive will have a single partition for `/webfiles` to store your web-related data, allocating 1.0 GB to this partition initially and leaving the remaining space for future expansion.
In addition, to maximize system performance, you will add a new swap partition. You decide to allocate 128 MB for swap.
The following instructions assume you are using modern storage tools and conventions.
-
Step 1: Identify the New Drive
Modern Linux systems often use /dev/sdX
naming for drives (e.g., /dev/sdb
for the second drive). Identify the new drive using the following command:
lsblk
Look for the drive without partitions. Assume the new drive is /dev/sdb
.
-
Step 2: Partition the Drive with
fdisk
-
Open the fdisk
tool for the new drive:
sudo fdisk /dev/sdb
-
Inside fdisk
, create the first partition:
- Press
n
to create a new partition.
- Choose
p
for a primary partition.
- Press
Enter
to accept the default partition number (1).
- Set the size to
+1G
for a 1.0 GB partition.
- Press
Enter
to complete the process.
-
Create the second partition for swap:
- Press
n
to create another new partition.
- Choose
p
for a primary partition.
- Press
Enter
to accept the default partition number (2).
- Set the size to
+128M
for a 128 MB partition.
- Press
Enter
to complete.
-
Change the type of the second partition to swap:
- Press
t
to change the partition type.
- Select partition 2 when prompted.
- Enter
82
for Linux swap.
-
Write the changes to the disk:
- Press
w
to write the changes and exit fdisk
.
-
Step 3: Format the Partitions
-
Format the /webfiles
partition with the ext4 filesystem:
sudo mkfs.ext4 /dev/sdb1
-
Initialize the swap partition:
sudo mkswap /dev/sdb2
-
Step 4: Mount and Activate the Partitions
-
Create a mount point for /webfiles
:
sudo mkdir -p /webfiles
-
Mount the partition:
sudo mount /dev/sdb1 /webfiles
-
Activate the swap partition:
sudo swapon /dev/sdb2
-
Step 5: Make the Changes Persistent
-
Update the /etc/fstab
file to ensure the partitions are mounted at boot:
sudo nano /etc/fstab
Add the following lines:
/dev/sdb1 /webfiles ext4 defaults 0 2
/dev/sdb2 none swap sw 0 0
- Save and exit the editor.
-
Step 6: Verify the Setup
-
Check the mounted partition:
df -h
-
Verify the active swap space:
free -m
Notes
-
Modern systems often use UUIDs or labels in /etc/fstab
for reliability. To find the UUID of the partitions, use:
blkid
-
With virtualization and cloud environments becoming more prevalent, consider alternatives like Logical Volume Manager (LVM) or disk management tools for advanced configurations.
Before moving on to the next lesson, read the following section to check your knowledge of installing a new hard drive.
- Intall harddrive in Redhat
- Physically install your hard drive.
- Prepare the drive according to the manufacturer's guidelines.
- Create the hard drive's partition table using the
fdisk
or cfdisk programs
.
- Initialize the new ext2 partitions with the
mke2fs
command.
- Initialize the new
swap
partitions with the mkswap
command.
- Edit
/etc/fstab
, adding new entries for the partitions.
- Make the directories for each of the mount points you specified in
/etc/fstab
.
- To gain immediate access to your new filesystems, mount them with the
mount
command.
- Enable the new
swap
partitions using swapon -a
.
The next lesson concludes this module.