Disk Management (1) - RHCSA

Disk management is a main task for system administrator. So first identify what are the main hard disk types available in a system.
  • SATA Hard Drives
  • SCSI Hard Drives
  • IDE Hard Drives
  • Virtual Hard Disks 

 

How Linux identify HDD ?

They use prefixes named sd , hd , vd for identifying SATA / SCSI , IDE , Virtual Disks. 
  • sd - SATA or SCSI
  • hd - IDE
  • vd - Virtual Disks
EXAMPLE:
If we use several SATA or SCSI disks in our system, system will identify them as sda , sdb , sdc and so on.
If we use several IDE disks in our system, system will identify them as hda , hdb , hdc and so on.
If we use several virtual disks in our system, system will identify them as vda , vdb , vdc and so on.
For more clarification,

Hard Disk Partitioning    

There are many reasons to partition a hard disk.
  • Security
  • Easy to get backups
  • Organization is easy 
  • Speed  
In hard disk partitioning, there are three (3)  types.
  1. Primary - Maximum 4 primary partitions in a single hard disk. This is for OS.
  2. Extended - Can have many
  3. Logical - Create inside extended partition. 
Possibilities:

[1]  ---->  One primary and remainder extended
[2]  ----> Two primary and remainder extended
[3]  ---->  Three primary and remainder extended

 How Linux systems identify partitions ? 

They use a number for that. For an example sda1 , sda2 likewise.
If we use two SATA / SCSI hard disks , system will identify them as sda and sdb . Then sda disk is chosen for partitioning. When we create one partition, system will identify this partition as sda1.
System use hard disk identifier + number . 
So this is how system identify partitions.

How to retrieve this information ?

In linux systems, we can retrieve above information using following commands.
This command is used to list down disks.
To retrieve information about Hard disk size, free spaces, mount points etc.
 To retrieve information about Hard disks and partitions in proper way. (Partition map)
To retrieve partition information in hard disk.

*** All the physical devices are in /dev folder ***

How to create a partition ? 

First you need to enter /fdisk -l command to check what are the available hard disk in the system.
Then enter following command.
<Disk> should be replaced with your disk (which is selected using fdisk -l ).
Ex: fdisk /dev/vdb
Then you will receive following.
If you are new to this , press m for help. You will receive actions that you can do.
Then press n to create a new partition.
Its already selected primary. So just press ENTER key.
Then you will be asked for a partition number. It automatically selected 1. So just press ENTER key.
 It is better to press ENTER key.
Then you will be asked for a size. I want to create 1GB partition. So I assign +1G. If you want 5GB, use +5G.
After that you will receive, Command (m for help) :  
So press w to write table to disk and exit.
For verification use lsblk command.

For creating another partition, use above procedure.

Once we created 3 primary partition, system will propose extended partition. Because if we create another primary partition, we cant create another partitions furthermore.

How to format the partition using mkfs ?

Once we created a partition we need to format. So we can use several file systems. Such as ext4, ext2, xfs etc.
mkfs.<file system>  <absolute path> ---> In above command is used to make ext4 file system in /dev/vdb1 partition.
If you want to create xfs file system, use mkfs.xfs /dev/vdb1

How to mount the partition ? 

In here we mount persistently. Before that you need to know the block id of the partition. For get block id use following command.
Then create a mount point. Mount Point is nothing but it is a directory.
  Then you need to add this block id to fstab. 
<partition> should be replaced with your partition. In fstab you need to add mount point , defaults and 0 0 . 
Then its time to mount.
When error did not occur , mount process is success.

Use following command to retrieve partition information with their file types.
 

Comments

Popular posts from this blog

Basic Configurations in Windows Server 2016 (2)

Interrupt the kernel to change the fstab - RHCSA

Controlling the boot process - RHCSA