Rate Us :

Share with Friends :


Partition :

To divide the hard disk space into different drives is known as partition.

Types of partition :

By default in any OS there are three types of partition :-

  • Primary partition which is used to install OS.

  • Extended partition - after three primary partition, the remaining free space is known as extended partition.

  • Logical partition which is used to store user data.

Partitioning tools :

Pre-installation tool [at the time of installation] => Disk Druid

Post-installation tools [in Windows disk management] => fdisk and parted [ these commands are used to create, delete or check the list of partition after installation of OS]

Naming convention of hardware devices :

Sata Hard Disk - /dev/sda IDE Hard Disk - /dev/hda DVD-RW - /dev/sr0 Pen Drive or USB - /dev/sdb

[root@localhost~]#fdisk -l This command is used to check the list of partition with the size. [root@localhost~]#fdisk /dev/sda This command is used to create a partition. Command action : a - toggle a bootable flag b - edit bsd disklabel c - toggle the dos compatibility flag d - delete a partition l - list known partition types m - print this menu n - add a new partition o - create a new empty DOS partition table p - print the partition table q - quit without saving changes s - create a new empty Sun disklabel t - change a partition's system id u - change display/entry units v - verify the partition table w - write table to disk and exit x - extra functionality

[root@localhost~]#parted -l This command is also used to check the list of partition with the size. [It provide more user-friendly information]

Create a partition using fdisk command :

To check the list of partition with the size - [root@localhost~]#fdisk -l To create a partition - [root@localhost~]#fdisk /dev/sda Command (m for help): n First cylinder (3634-3917, default 3634): [Enter] (To avoid giving size of partition in cylinder) Last cylinder, +cylinders or +size{K,L,M}{3634-3917, default 3917}: +10GB Command (m for help): p [lets say we already have 9 partition available so, the new partition will be /dev/sda10] Command (m for help): w To update new partition table without restarting the OS - [root@localhost~]#partprobe /dev/sda [for CentOS 7 or RHEL 7] [root@localhost~]#partx -a /dev/sda [for CentOS 6 or RHEL 6] Format the partition to create file system - [root@localhost~]#mkfs.ext4 /dev/sda10 [ext4 is a file system] To check the partition file system with id number - [root@localhost~]#blkid /dev/sda10

Delete a partition using fdisk command :

To delete a partition - [root@localhost~]#fdisk /dev/sda Command (m for help): d Partition number (1-10): 10 Command (m for help): p Command (m for help): w

Mounting :

Mounting is a method which is used to access any device (partition, CD-ROM, USB device, network device etc.) with the help of mount point.

Mount point :

A mount point is a directory which is linking with specific device (access point).

To mount a partition : [to activate any device]

Create a directory - [root@localhost~]#mkdir /dir1 Mount the partition - [root@localhost~]#mount /dev/sda10 /dir1 To check all the mounted partition list - [root@localhost~]#mount To store data in mounted partition - [root@localhost~]#touch /dir1/file1 To deactivate the partition - [root@localhost~]#unmount /dir1

Mounting a partition permanently :

[root@localhost~]#vi /etc/fstab This command is used to mount a partition permanently. fstab (file system table) - It is used to mount the partition permanently with the help of partition name, file system, mount point & default permission. Example : [root@localhost~]#vi /etc/fstab fstab file will be opened, then press i/I/o/O/a/A (any one of them) to go to insert mode. Now go to end of the file and type : /dev/sda10 /dir1 ext4 default 0 0 Then press wq to save and exit. To update permanent mounted partition - [root@localhost~]#mount -a