Format HDD in Linux

So very recently we needed to quickly get a new 3TB HDD set-up in Cent OS 7 as a backup server. We couldn’t afford the time to spend an age on it so when with the simple and powerful fdisk. I decided to write this so that I don’t forget how I did it, as is likely to happen.

  1. Identify the device, we used fdisk -l and was able to identify the drive: /dev/sdb
  2. Create the partition, fdisk /dev/sdb then use option p, n, and w (w is important as it actually makes the changes, otherwise they get lost when fdisk quits)
  3. Make the ext4 filesystem on partition, mkfs -t ext4 /dev/sdb1 (the 1 refers to the partition)
  4. Create a mount point, Simply just need to create a folder with which to mount the drive into, we used /mnt/backup_drive
  5. Mount the partition (temporily), mount /dev/sdb1 /mnt/backup_drive – this let us know it all worked
  6. Make the mount permanent, Edit fstab (I like to use nano but there are other ways to do this) nano /etc/fstab (you need to sudo for this to work) and enter a line like this: /dev/sdb1 /mnt/backup_drive     ext4   defaults   0  0
    You may see other lines similar to this, some systems refer to the drives using the UUID instead, admittedly I don’t know enough about that to comment other than I rememer reading that the UUID is very unique. When I discover more I shall post about it on here.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s