Tutorial: Adding Additional Hard Drives in Linux
The Theory Behind Hard Drive Management
"How can I add one more hard disk?", "What should I do if my collegue brings a new hard disk and I have to copy my files there?", "When I was using Windows, one could see the new disk immediately and Linux is too complex!" These are some of the common questions and concerns of new Linux users, who are facing the problem of adding of a new hard drive. Some of them are so accustomed to Windows that they can not think any other way, so they come up with such statements as "I have used fdisk and format programs, but there are no such ones in Linux!"
In reality, the procedure of adding of new hard drive in Linux is not that hard and sometimes you can spend less time then you would spend to do the same thing in Windows. To illustrate this, I'll start from the very begining to explain this procedure in detail.
First of all, I need to mention that before a users tries to add any new hard disk, he should learn the basics of what "partitioning" and "file systems" are and what is the difference between Primary, Extended, and logical partitions. You should know how to add a new disk to the computer physically (which is typically covered in the hard drive's documentation). I'm going to assume you know these basics, because the focus of this article will be how to get Linux to behave with your new drive.
I'm going to start from the theory of the process.
There's not much sense in diggging into the terminology and principles of adding of a new devices in UNIX systems--there are too many different UNIX versions to try that approach. We'll just go-over Linux-specific issues.
All hard disk drives in the Linux operation system have special names, which consist of three parts, two of which are listed here:
- Two symbols "hd" or "sd" for the IDE and SCSI disk drives
- One symbol somewhere in the range from "a" to "h" for the IDE disk drives, or the range from "a" to "p" for SCSI ones.
(I have to mention that for different Linux distributions, this range could differ. For example, Red Hat Linux 7.2 uses the range "a" to "l" for the IDE disk drives, and a range from "a" to "az" (two symbol combination!) for the SCSI drives).
This second symbol defines the number of device. SCSI disk drives use sorted
numbering, which depends on the ID of device. The IDE scheme differs
a bit. Let's
look at the scheme:
- a and b - Master and Slave disks at the Primary interface of the 1st IDE controller
- c and d - Master and Slave disks at the Secondary interface of the 1st IDE controller
- e and f - Master and Slave disks at the Primary interface of the 2nd IDE controller
- g and h - Master and Slave disks at the Secondary interface of the 2nd IDE controller
...and so on.
When you're connecting a new IDE disk to the motherboard you should always be ready to remember how was it connected: which interface of what controller is being used and how was it assigned: master or slave.
When you don't have a motherboard with four IDE controllers, or your server configuration has no additional IDE controllers, you should not have to use device names starting with "hde."
The third section of the naming scheme is:
- Number of slices (partitions) - This is a number in a range from 1 to 16 for IDE hard drives and from 1 to 15 for SCSI hard drives.
All partitions are numbered next way: 1-4 - primary and extended, 5-16 (15) - logical. So, in one system we can have not more than five primary partitions and not more than 11 (10) logical partitions on one physical hard disk.
If this number is absent, this means that this name represents the entire hard drive.
To get list of disk names in a system we need to enter this command as 'root' superuser for IDE drives:
# ls /dev/hd*
# ls /dev/sd*
for SCSI drives.
If you are very new to all of this, remember that this will not generate a list of connected (attached) disks but a rather a list of disk names. With this list we wil be able to determine when and what were the last disks attached. So, don't be wondering if you get a very long list.
It's time to do some practice now. All actions should be executed with superuser 'root' priveleges. Warning: you should be very accurate so as not to damage the data on your hard drives. Backing up everything would not be a bad idea, either.
Let's take a look at some typical and usual situations.