Create a File System on the Partition

Computers use particular kinds of file systems to store and organize data on media, like Hard Disk, CD, DVD, etc. The commonly used Linux file systems are ext2, ext3, ext4, JFS, ReiserFS, XFS, FAT (usually in Windows OS) and B-treeFS. Inorder to specify the file system to be used in each partition, we can use the mkfs (make file system) command.

mkfs.ext4 -j /dev/sdb1

What this command does is that it will make the first partition’s file system to be ext4 (format the partition to ext4). -j flag is used to allow/support journaling. It helps in throwing errors into the journal, in case of system failure.

mkfs.fat /dev/sdb2

This command is used to format the 2nd partition available in /dev/sdb2 to the FAT file system. Even though we formatted the disks, it is of no use to us, unless we mount it on a directory.

Create a file system on the partition

Disk Partitioning in Linux

Disk Partitioning is the process of dividing a disk into one or more logical areas, often known as partitions, on which the user can work separately. It is one step of disk formatting. If a partition is created, the disk will store the information about the location and size of partitions in the partition table. With the partition table, each partition can appear to the operating system as a logical disk, and users can read and write data on those disks. The main advantage of disk partitioning is that each partition can be managed separately.

Why do we need it?

  • To upgrade Hard Disk (to incorporate a new Hard Disk into the system)
  • Dual Booting (Multiple Operating Systems on the same system)
  • Efficient disk management
  • Ensure backup and security.
  • Work with different File Systems using the same system.

How to Partition Disks in Linux?

(For the purpose of demonstration Cent OS 7 and VMware are used in the screenshots of the article.)

In order to successfully partition a disk and to make it useful, we need to ensure that we have completed the below four steps, regardless of the Operating system and Hardware of the system.

  1. Attach the disk to the proper port.
  2. Create partitions in the disk.
  3. Create a file system on the partition.
  4. Mounting the file systems 

Attaching Disk:

This step points to physically connecting the disk to the system. The below screenshot specifies the system configuration of my CentOS 7. 

Initial configuration of my system

It is clearly specified that the system has only 20 GB of Hard Disk. After installing the necessary software and downloading some movies, I found that the system Hard Disk is almost completely used up. Now I will have two options in front of me, either buy a new system with a higher Hard Disk capacity or upgrade the existing one. Most of you will go for the second option, just like me, unless the system is very old. Let us upgrade the system with an additional 20 GB of Hard Disk.

In order to attach the new virtual Hard Disk in VMware, click on the “Edit virtual machine settings” link and choose the Add option on the next window. 

Attaching Disk

Choose the Hard Disk option and move forward.

Type of hardware to install

Choose the recommended disk type. (SCSI is recommended here since the Operating System that I am using is CentOS)

Select a Disk Type

Complete the attachment of the disk by specifying the required size of Hard Disk needed and choosing the recommended selections.

After attaching the new virtual Hard Disk

The final configuration shows that our system has a new Hard Disk of 20 GB size. The newly added Hard disk is of no use to our system unless we complete the remaining steps.

Similar Reads

Create Partitions in the Disk

Power on the system and log in to the system. Ensure that you are logged in as root (or any user of the sudo group). Once the system UI comes up, open the Terminal.  To view the available Hard Disks in our system, use the command lsblk or cat /proc/partitions. Both commands will display the same results, but in different ways....

Create a File System on the Partition

Computers use particular kinds of file systems to store and organize data on media, like Hard Disk, CD, DVD, etc. The commonly used Linux file systems are ext2, ext3, ext4, JFS, ReiserFS, XFS, FAT (usually in Windows OS) and B-treeFS. Inorder to specify the file system to be used in each partition, we can use the mkfs (make file system) command....

Mounting the file systems

Let us make three directories, for mounting the first, second, and third partition using the mkdir (make directory) command....

Conclusion

In this article we have discussed disk partitioning, which is the process of dividing a disk into a separate logical area that are known as partitions. One can easily understand enabling efficient disk management, facilitates dual booting, ensures backup and security by understanding this article. Proper disk partitioning is important for effective storage utilization and system administration....

Contact Us