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.
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.
- Attach the disk to the proper port.
- Create partitions in the disk.
- Create a file system on the partition.
- 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.
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.
Choose the Hard Disk option and move forward.
Choose the recommended disk type. (SCSI is recommended here since the Operating System that I am using is CentOS)
Complete the attachment of the disk by specifying the required size of Hard Disk needed and choosing the recommended selections.
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.
Contact Us