How To Partition In Linux

Linux, being an open-source operating system, gives its users high flexibility and control over their systems. One such feat offered by Linux is the ability to partition your hard drive. This blog post aims to provide a step-by-step guide on how to partition in Linux.

What is Partitioning?

Partitioning is the process of dividing a physical disk into smaller logical units known as partitions. Each partition acts as a separate disk and can be used independently of the others. This is useful for organizing data and files or for dual-booting multiple operating systems.

Tools for Disk Partitioning

There are several tools available for disk partitioning in Linux, such as fdisk, parted, and gparted. In this post, we will focus on fdisk due to its wide usage and availability in almost all Linux distributions.

Partitioning with fdisk

To start with, you need to list the available disks on your system. You can do this by entering the following command in your terminal:

sudo fdisk -l

You’ll see an output list of all your system’s disks. From there, you can choose which disk you’d like to partition.

Next, to create a new partition, you’ll want to use the fdisk command followed by the device name of the disk you want to partition. For example, if you’re partitioning the first disk, the command would look like this:

sudo fdisk /dev/sda

In fdisk utility, you can use the following commands:

  • m – to display the help menu
  • p – to print the partition table
  • n – to create a new partition
  • d – to delete a partition
  • q – to quit without saving changes
  • w – to write changes and exit

After creating the new partition, remember to format it using the mkfs command. For example, to format the new partition with the ext4 file system, the command would be:

sudo mkfs.ext4 /dev/sdaX

Replace “X” with the number of the new partition.

Conclusion

As you can see, partitioning in Linux is quite straightforward once you get the hang of it. It’s a handy skill to have, making your Linux experience more flexible and tailored to your needs. Always remember to back up your data before making any changes to your disk partitions to avoid any data loss. Happy partitioning!