How to add New disk and mount in CentOS 8?

Please follow the below steps for complete the full task

  • Create the partition

  • Format the partition by xfs file system

  • Mount the partition

  • Mount the partition at startup


Create the partition

  • Check the number of partition and disk available using below command

fdisk -l
  • Assume that we got 2 disk /dev/sda which already added and partitioned but /dev/sdb which not partitioned.

  • Start partition by the below command

fdisk /dev/sdb
  • press p for show existing partition

  • there should not be partition if the disk is very new

  • press n for new partition.

  • press p for primary partition.

  • press 1 for specify the partition number.

  • press enter

  • again press enter

  • press w for write changes of the partition to disk.

  • Now the partition is complete


Format the partition by xfs file system

  • Run the below command for find the partition

fdisk -l
  • For format the partition please run the below command

mkfs.xfs /dev/sdb1


Mount the partition

  • Create a directory called /resources by the command mkdir /resources

  • Now connect the partition with the resources directory by the below command.

mount /dev/sdb1 /resources
  • Go to the directory resources and try to create a directory if you are able to do this then the mount is success.

cd /resources
mkdir test


Mount the partition at startup

Before go to deep of the fstab lets see the format of the fstab

<file system>   <dir>       <type>  <options>       <dump>  <pass>
/dev/sdb1     /resources      xfs    defaults         1         2
  • <file system> : defines the storage device

  • <dir> : tells the mount command where it should mount the <file system> to.

  • <type> : defines the file system type of the device or partition to be mounted. ext2, ext3, reiserfs, xfs etc.

  • <options> : define particular options for filesystems.

    • defaults : default mount settings (equivalent to rw,suid,dev,exec,auto,nouser,async).

    • auto : file system will mount automatically at boot

    • rw : mount the filesystem read-write.

    • suid : allow the operation of suid, and sgid bits.

    • exec : allow the execution binaries that are on that partition (default).

    • nouser : only allow root to mount the filesystem (default).

    • async : I/O should be done asynchronously.

  • <dump> : it is used by the dump utility to decide when to make a backup. Possible entries are 0 and 1.

    • 0 : dump will ignore the file system

    • 1 : dump will make a backup.

  • <pass> : fsck reads the <pass> number and determines in which order the file systems should be checked. Possible entries are 0, 1, and 2

    • 0 : not be checked by the fsck utility.

    • 1 : the root directory

    • 2 : all other modifiable file systems;


Let’s mount the disk at startup

  • For mount the disk at startup please follow the below commands

vi /etc/fstab
  • Go to file last and add the below codes there

/dev/sdb1     /resources      xfs    defaults         1 2
  • write and exit the vi editor