Linux Hard Disk Format Command

Q. I’ve installed a new 250GB SATA hard disk on our office CentOS Linux server. How do I format a hard disk under Linux operating system from a shell prompt?

A. There are total 4 steps involved for hard disk upgrade and installation procedure:

Step #1 : Partition the new disk using fdisk command

Following command will list all detected hard disks:

# fdisk -l | grep '^Disk'

Output:

Disk /dev/sda: 251.0 GB, 251000193024 bytes
Disk /dev/sdb: 251.0 GB, 251000193024 bytes

A device name refers to the entire hard disk. To partition the disk – /dev/sdb, enter:

# fdisk /dev/sdb

The basic fdisk commands you need are:

Output:

  • m – print help
  • p – print the partition table
  • n – create a new partition
  • d – delete a partition
  • q – quit without saving changes
  • w – write the new partition table and exit

Step#2 : Format the new disk using mkfs.ext3 command
To format Linux partitions using ext2fs on the new disk:

# mkfs.ext3 /dev/sdb1

Step#3 : Mount the new disk using mount command
First create a mount point /disk1 and use mount command to mount /dev/sdb1, enter:

# mkdir /disk1
# mount /dev/sdb1 /disk1
# df -H

Step#4 : Update /etc/fstab file
Open /etc/fstab file, enter:

# vi /etc/fstab

# blkid /dev/sdb1

Mounting-of-additional-hard-disks-in-Linux-8

The part after "UUID=" is the UUID of our partition. We copy it (without the quotation marks) and open /etc/fstabin a text editor:

# nano /etc/fstab  or,  # vi /etc/fstab

With the arrow keys, we navigate our cursor to the end of the file and paste the following line:

UUID=d6ae62ff-c9b7-4a07-aea8-a36f55c5036d       /datastore      ext4    defaults      0       0

Mounting-of-additional-hard-disks-in-Linux-9

Make sure to replace the UUID with your actual one.

  • 3 Bu dökümanı faydalı bulan kullanıcılar:
Bu cevap yeterince yardımcı oldu mu?

İlgili diğer dökümanlar

Mounting of additional hard disks in Linux

In this tutorial, we are going to mount an additional hard disk in Linux. At first, we list all...

fdisk Commands to Manage Linux Disk Partitions

fdisk stands (for “fixed disk or format disk“) is an most commonly used command-line based disk...