Open Source

Adding a second drive in Linux

Adding a second drive in Linux is much easier than you would imagine. In this quick how-to, Jack Wallen, Jr. outlines a quick and painless method that will get you up and running in no time.

Recently I had the pleasure of installing a second drive in my Linux machine. To be exact, I installed my old drive into a new system as a secondary drive. The new system was from PogoLinux and contained a single drive bay with space for plenty more. I was thinking it was going to be an arduous experiment, but it turned out to be as simple as plugging and playing.

Let me show you how I managed to pull this off.

The specifics
As I mentioned, the new machine was from PogoLinux and already contained one removable drive bay. I decided to add a second removable drive bay to make the machine as flexible as possible.

The current drive in the PogoLinux machine was a UDMA 100 20-GB drive, dual booting Red Hat 7 and Windows Me. The old drive was an older Western Digital 6-GB drive that already had a fine working Red Hat 6.2 installation. I was concerned that installing a second drive with an already configured OS would completely bring the system down. Thanks be to Linux, I was wrong.

After the hardware installation was complete, the first thing to deal with was the BIOS. Because the primary drive used the UDMA controller, I had to make sure the IDE controller for the newly installed drive was disabled. Once that was taken care of, the boot process went as usual.

Mounting and using the drive
After the machine booted, I ran dmesg to find out where the drive was located. Amidst the lengthy output of dmesg I came across the following:
hdd: WDC AC26400B, ATA DISK drive
hde: probing with STATUS(0x50) instead of ALTSTATUS(0xff)
hde: IBM-DTLA-307020, ATA DISK drive

which clearly indicated the old Western Digital existed (within Linux) as /dev/hdd.

With this information, I was halfway home! The next step was to create a location to which to mount the drive. Since this machine was a single user machine, I decided to mount the drive on a newly created directory in /home/jlwallen called xander. The command to create this directory is as follows:
mkdir /home/jlwallen/xander

With the new directory created, it was time to mount the drive.

Mounting of this type needs to be done by the root user. Once you have root access, you can issue a command similar to
mount -t ext2 /dev/hdd1 /home/jlwallen/xander

and the newly installed drive may or may not mount. In my case, I had a couple of issues with which I had to deal. The first was that the drive had been unmounted uncleanly and needed a check. To check this drive, I unmounted the drive with
umount /home/jlwallen/xander

ran fsck with
fsck /dev/hdd1

and found that there were, indeed, some corrupt inodes. Fortunately, fsck fixed those issues, and I attempted to remount the drive. With the command
mount -t ext2 /dev/hdd1 /home/jlwallen/xander

the drive mounted without balking.

Making it easier and cleaning it up
Okay, so I now had the ability to mount the Western Digital drive. However, running this command after every boot (and remembering to unmount should a reboot be necessary) is less than a best-case scenario. To make this as simple as possible, I first weeded down the command and then put it into /etc/fstab so the mount would automount at boot.

One issue I had to first deal with was the fact that I was mounting a drive that was taken from a completely different machine and had a complete Operating System installed. Because this drive had a complete OS installed, I didn't need the configured device files. For this, I added the -o nodev option so these special characters and devices were not interpreted. The new command looked like this:
mount -t ext2 -0 nodev /dev/hdd1 /home/jlwallen/xander

My new mount command was fine. However, there were some unnecessary variables involved. The first was the type. Since ext2 (the Linux filesystem type) was the default, I didn’t need to pass this argument. (After all, I was mounting a Linux-only drive.) Then, the command looked like this:
mount -o nodev /dev/hdd1 /home/jlwallen/xander

I was getting closer.

Since the new drive was faster (and larger), I would be using it for my primary drive and using the newly installed drive as a storage device. My new goal was to get all the important files off this drive, and then wipe it clean.

After a successful mount, I copied all needed files into a new directory (on /dev/hde) and, as root, wiped out all files and directories on /home/jlwallen/xander.

Once all the files and directories were wiped clean I could now trim down my command one more time to remove the nodev option. Then, my command looked like this:
mount /dev/hdd1 /home/jlwallen/xander

When I took a look at the directory with the command
ls -la /home/jlwallen/xander

I saw an empty directory. When I ran the filesystem report command
df -h

I saw the following:

Filesystem Size Used Avail Use% Mounted on
/dev/hde6 14G 2.9G 10G 23% /
/dev/hde1 23M 5.0M 16M 23% /boot
/dev/hdd1 5.8G 4.0k 5.4G 1% /home/jlwallen/xander

My drive was successfully mounted and could now be used as a storage facility.

Automating the process
To automate this process, I had to do two things:
  • Give my user ownership of the drive
  • Add an entry in /etc/fstab

The first point was as simple as running (as root) the command:
chown jlwallen /home/jlwallen/xander
The jlwallen user is unique to my system. For your particular system you will have your own unique username.
The second step was equally as simple. As root, I opened up /etc/fstab in my favorite text editor and added this line:
/dev/hdd1    /home/jlwallen/xander ext2 defaults  0 0

The above entry told the system:
  • The drive is located on hdd1.
  • The mount point is /home/jlwallen/xander.
  • The type is ext2.
  • To use all default arguments.
  • Not to dump the filesystem.
  • Not to check the filesystem.

Once the entry was added, I saved the file (double checked it for correctness) and rebooted the machine. Upon boot up, I noticed the drive was detected, and once the boot was completed, I ran the df command and saw the drive. (If I hadn’t seen the drive reported with df, I would have checked dmesg to see if there had been any error messages passed.)

A simple method of installing a second drive under a Linux system is within the reach of any Linux user. As I’ve shown, with a bit of patience, you can expand your system to the limits of your resources.
The authors and editors have taken care in preparation of the content contained herein but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website

Editor's Picks

Free Newsletters, In your Inbox