How to: Linux Partitions List

Linux Partitions List

When it comes to managing storage in Linux, partitions are a crucial concept to understand. Partitions are logical divisions of a hard drive that allow you to separate data and operating systems into different areas. In this article, we will explore the Linux partitions list and how it can be used to manage storage in a Linux environment.

What is a Partition?

A partition is a logical division of a hard drive that separates data and operating systems into different areas. Each partition acts as a separate disk drive, allowing you to install a different operating system or store data separately. Partitions are created during the installation process of an operating system, and they can also be created or modified after installation.

Linux Partitions List

In Linux, the partitions list is a comprehensive list of all the partitions on a hard drive. This list can be accessed using the fdisk command. The fdisk command is a command-line tool that allows you to view and modify the partition table of a hard drive. The partitions list provides information about the size, type, and location of each partition on the hard drive.

To view the partitions list, open a terminal window and type the following command:

sudo fdisk -l

This command will display a list of all the partitions on the hard drive, along with their size, type, and location. Here is an example output of the partitions list:

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000f1c9

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   486322175   243160064   83  Linux
/dev/sda2       486324222   488396799     1036289    5  Extended
/dev/sda5       486324224   488396799     1036288   82  Linux swap / Solaris

In the example above, we can see that the hard drive /dev/sda has three partitions: /dev/sda1, /dev/sda2, and /dev/sda5. The first partition /dev/sda1 is a primary partition, and it is marked as bootable. The second partition /dev/sda2 is an extended partition, which contains a logical partition /dev/sda5.

Managing Partitions with fdisk

The fdisk command can also be used to manage partitions. To modify the partition table, you will need to run fdisk with root privileges using the sudo command. Here are some common commands used to manage partitions with fdisk:

  • n: Creates a new partition
  • d: Deletes a partition
  • p: Prints the partition table
  • w: Writes the changes to the partition table and exits

Here is an example of how to create a new partition using fdisk:

  1. Open a terminal window and type the following command:
sudo fdisk /dev/sda
  1. Type n to create a new partition.
  2. Follow the prompts to specify the partition type, starting sector, and size.
  3. Type w to write the changes to the partition table and exit.

Conclusion

The Linux partitions list is a comprehensive list of all the partitions on a hard drive. It can be accessed using the fdisk command and provides information about the size, type, and location of each partition. The fdisk command can also be used to manage partitions, allowing you to create, delete, and modify partitions as needed. Understanding how to use the partitions list and fdisk command is crucial for managing storage in a Linux environment.