This is a simple howto designed to show you the basics of adding a new hard disk to an existing system using fdisk and mkfs.

Applicable to Centos Versions

  • Centos All Versions

Requirements

  1. New Hard Disk supported by your system motherboard.
  2. Existing Centos base install.

Doing the Work

Once your drive is plugged, detected by the system bios and you are booted into your system open a terminal and type: su –login

  1. Finding the hard disk devices your computer sees attached.
  2. At the bottom we see: “Disk /dev/sdl doesn’t contain a valid partition table“, this is what we are looking for, now we can create the partitions. For this example, we’re taking a 250GB Maxtor hard disk and using the entire space as one large partition. If you want more than one partition on your new disk you can alter this when you choose the size of your new partitions using +sizeM (megabytes) or +sizeK (Kilobytes).
  3. Now that we’ve created the partition scheme we’d like, we need to write the changes to the disk partition table.
  4. Now we need to create a filesystem on the new partition. For this howto we will use the native linux filesystem (ext3 or type 83). Make note of the superblock backups for this new disk in case an fsck is required and the main journal is corrupted or missing. You can point fsck to a backup superblock provided you thought ahead and recorded them.
  5. Mounting the new disk on /mnt/250GB so we can put data on it and use it normally. First, we create the directory with the mkdir command. Second we mount the disk device into our newly created directory /mnt/250GB as read/write. Note: if you have trouble with directory permissions or not being allowed to write to the directory see: man chmod | man chown.
  6. Setting your drive up to automount on boot. For this we’ll edit the /etc/fstab file and add in the appropriate line save/exit. We’ll then tell the system to execute the fstab file with: mount -a  and finally we’ll use: df -h to verify that the disk is indeed mounted and the system sees it where we expect.

Troubleshooting

How to test

  1. Please rerun the commands in Step 6 if you have trouble or visit us on IRC on Freenode in #centos
  2. You may be wondering why a 250GB disk with nothing on it shows as 219GB. This space is taken by the filesystem journal. The journal is important for data integrity, it is normal for this percentage of space to be “missing” from any drive with an ext3 filesystem.
  3. Command overview:
 

Interesting reading:

The Linux Documentation Project

More Information

 

Disclaimer

We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #centos on irc.freenode.net

Added Reading:

Last Modified: 23 Feb, 2012 at 02:18:44