How To Add a New Disk in CentOS 7

Learn how to add a new hard drive with commands to CentOS 7 in a simple way.

Before Connecting Hard Drive

To begin with, understanding the CentOS 7 structure is necessary prior to installing new hardware. To do so, accessing root privileges and running the subsequent command is required.

fdisk -l

Once the hard disk is connected, run the same command, fdisk -l. As we can see the new hard drive, 20 GB, is assigned to the path /dev/sdb.

This name will be assigned taking into account the type of disk; if we use a virtual hard drive, it will be /dev/xvdc.

Partition the New Hard Drive in Linux

Once the new hard disk has been identified, the next step will be to partition it, for this we will use the following syntax:

fdisk /dev/sdb

Common fdisk parameters are:

n: Create a new partition.

p: Print the partition table.

d: Remove a partition.

q: It leaves without saving the changes.

w: Save the changes and exit the command.

With this in mind we will perform the following process once the fdisk /dev/sdb command has been executed:

  • Enter the letter n to create the new partition.
  • Enter the letter p to define what is a primary partition.
  • Number 1 to establish a single partition of the new disk.
  • Establish the value of the first sector which is 2048 by default.
  • Establish the value of the last sector which is by default 41943039.
  • Save the changes using the letter w.

We can see that the process is executed correctly. If we rerun fdisk -l we can look at the changes in the new disk (/dev/sdb) :

Format the New Hard Drive

The next step is to format the new hard drive with the desired file system using the command

mkfs (make file system)

mkfs.ext4 /dev/sdb1

Finally, we mount the new disk in the desired location, in this tutorial we have created a new directory called /data :

mount /dev/sdb1 /data

To ensure the mounting of the partition on a permanent basis, it is imperative to modify the file /etc/fstab with the editor of your choice and input the subsequent line. Don't forget to save the revisions.

/dev/sdb1 /data ext4 defaults 0 0

By adding the new hard drive in CentOS 7, we are now fully equipped to maximize its capabilities.

It might be interesting

Samsung i900 Omnia 3G SmartPhone

With stunning casing, high quality imaging, exceptional communication and business features, the Samsung i900 Omnia 3G SmartPhone is a nice blend of sophistication and style.

Xiaomi will unveil the Civi 1S smartphone on April 21

Earlier it became known that the company Xiaomi in the near future will present a new smartphone called Civi 1S. Today in the social network Weibo appeared the official teaser of the novelty, revealing the date of its presentation.

Google Earth to offer inside imagery!

Google well-known digital globe application Google Earth will soon offer new imagery that is being got from inside buildings. This new layer will provide ultra-high resolution artwork photos to the viewers from places like Prado Museum in Spain.

Considerable drop in online shopping spend

Things are not quite different for online shops, and just like high street, there are fewer customers willing to spend money.