Home >System Tutorial >LINUX >How to check the number of partitions in a Linux system
How to check the number of partitions in the Linux system
In the Linux system, we can check the number of partitions that already exist in the system through commands. Checking the number of partitions is very important for system management and monitoring, and can help us better understand the storage structure and usage of the system.
The following is the specific method to check the number of partitions in a Linux system, as well as the corresponding code examples:
fdisk It is a command line tool used to manage disk partitions and is very commonly used in Linux systems. We can use the fdisk command to view the number of partitions that exist in the system.
sudo fdisk -l
Output result example:
Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 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 Disklabel type: dos Disk identifier: 0x00000000 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 2097151 2095104 1G 83 Linux /dev/sda2 2097152 20971519 18874368 9G 8e Linux LVM
In this example, we can see two partitions that already exist in the system: /dev/sda1 and /dev/sda2.
lsblk is a command line tool used to list block device information and can also be used to view the number of partitions in the system.
sudo lsblk
Output result example:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 10G 0 disk |-sda1 8:1 0 1G 0 part / |-sda2 8:2 0 9G 0 part /mnt
In this example, you can also see the two partitions that already exist in the system: sda1 and sda2.
Through the above two methods, we can easily check the number of partitions in the Linux system to better understand the storage structure and usage of the system. This is very helpful for system management and monitoring.
The above is the detailed content of How to check the number of partitions in a Linux system. For more information, please follow other related articles on the PHP Chinese website!