Tuesday, 19 July 2016

How to Mount External Hard Drive as a partition on CentOS 6.5

First, list devices on your system using one of the following command :

#fdisk -l | grep '^Disk'

Now, assuming your new drive is “sda”, use the following command to invoke the fdisk partition utility :

#fdisk /dev/sda

To create a new partition (assuming this is a new unused drive), just type “n“. Then, save your work typing “w” and “q” to exit the utility.
Any doubt or need help about fdisk utility, just type “m“.

Let’s format the partition as traditional EXT4 Linux file system :

#mkfs.ext4 /dev/sda

Okay, the hard disk partitioning and formatting is done now.

Create a directory where you want to have your drive mounted (replace all “external_hd” value with the name you want to use ) :

#mkdir /data

#mount /dev/sda /data

You’re now ready to use it! However, this mount will not survive to a reboot. To make it permanent, you need to edit fstab :

#vi /etc/fstab

/dev/sda        /data          ext4        defaults     0 0

NOTE : If you manually mount the drive instead doing the fstab way, do not forget to manually unmount it before unplug it! Serious data loss problem may occur if you skip this step!

#umount /dev/sda

No comments:

Post a Comment