Commands To Monitor Linux Disk Partitions
Know the best commands to be able to monitor your disk partitions in Linux and be informed of your entire PC.
Today this tutorial will teach you some essential commands to know the state of the hard disks and the partitions that we have established in some of the distros of Linux. For this tutorial, we will use Ubuntu 16.04
FDISK Command
Fdisk is one of the most used and essential commands that we can use to verify the status of disks in Linux because thanks to this command we have the possibility to execute the following tasks:
- Create partitions
- Remove partitions
- Resize or change partitions
There are several parameters that allow us to have a much deeper or specific scope using Fdisk, these are:
fdisk -l
This parameter allows us to see all disk partitions in Linux detailing size, number of sectors, units per sector, etc.
fdisk -l /dev/sda
This command allows us to see the state of a particular partition indicating the number of sectors, size, ID and partition type.
We also have other options such as:
fdisk /dev/sda (d): It allows us to delete a partition within the system.
fdisk /dev/sda (n): It will enable us to create a new partition.
fdisk -s (partition ID): It allows us to validate the size of a partition.
fdisk /dev/sdb (x): It will enable us to correct the partition table .
fdisk /dev/sda (m): Display the available commands of Fdisk.
Command CFDISK
CFDisk is a simple program that will give us the possibility to see on the screen the disk partitions and from there execute administrative tasks.
Thanks to CFDisk we can create, edit and delete Linux partitions safely and completely.
Some of the parameters that we can use with CFDisk are the following:
sudo cfdisk
This command allows us to see on screen all the information associated with the current disk in Linux, its information is very complete. We can see various information such as partition type, file system type, file system ID, etc.
From this window we can execute tasks on the different partitions, it is enough to select the partition in the upper part and in the lower part to establish the respective task.
Some useful commands with CFDisk are:
cfdisk -h: Display the command help .
cfdisk -d: Delete the selected partition.
cfdisk -g: It allows to edit the geometry of the disk at the level of cylinders, sectors, heads, etc.).
cfdisk -n: It enables to create a new partition .
cfdisk -m: This parameter allows us to maximize the use of the disk for the selected partition.
cfdisk -p: Print the information in the partition table .
Command SFDISK
SFDISK is a very similar command to FDISK since it gives us the possibility to execute tasks on partitions such as creating, editing or deleting them from the system.
In addition, the SFDOSK command allows us to use partition tables such as the already known GPT, MBR, Sun and SGI.
The basic commands that we can implement with sfdisk are:
sfdisk -l: It allows us to see all the partitions of the system. As we can see, its appearance is exact to FDISK.
Other additional parameters are:
sfdisk -d: It allows us to see the partitions of a particular hard drive.
sfdisk -s: It will enable to know the size of all the partitions of the system.
sfdisk -v: Displays the version of the SFDISK command.
sfdisk -x: It allows to extend a logical partition to an extended partition.
sfdisk -T: With this parameter, we can see the IDs that are recognized by SFDISK.
Command LSBLK
The LSBLK command allows us to see on screen all the information associated with the partitions such as: Name, Mount point, etc.
The basic syntax for the use of this command is the following:
lsblk
As we can see we have detailed information about each partition of the system.
If we want to obtain much more complete information we can use the following parameter:
lsblk -fm
Command Parted
Parted is another command to manage partitions on Linux system hard drives thanks to its scope and utility. With Parted extend and edit different partition table systems such as MBR and GPT.
Additional with Parted we can execute the following tasks:
- Create and enable space for new partitions.
- Copy data to new hard drives installed on the computer.
- Redistribute the space on the hard drive in order to optimize performance.
The parameters that we can implement with Parted are the following:
sudo parted -l: Lists the current partitions of the hard drives.
It is important to keep in mind that to correctly use all the parameters of Parted we must access the command using the following syntax:
sudo parted
As we see we have the line (parted) from where we can execute some of the following parameters:
mklabel: It allows us to create a label to a certain partition.
print: Display the partition table.
select(Disc): Allows us to select the disc number to edit.
rm: Remove the selected partition.
unit: Sets the unit chosen as the default unit.
Command HWINFO
Although the main function of HWINFO is to show detailed information about the hardware of the equipment, we can use some parameters to visualize a certain value.
For example, we can use the following command to display the list of hardware elements such as disks and partitions.
There we can see the different partitions and the type of partition.
hwinfo --short –block
Command BLKID
BLKID is a command that allows us to show the different attributes of the various blocks in the system such as the name, the label and the type of file system.
The basic parameter that we will use with blkid is as follows. We can see all the information of each block.
blkid
Command PYDF
PYDF is a Python utility and is an alternative to the well-known df command.
This command allows us to visualize the amount of space used and the space available in a color environment. To installthis command in Ubuntu 16 we will use the following command:
sudo apt install pydf
The basic syntax for using pydf in Ubuntu 16 is as follows:
pydf
Some of the parameters that we can use with pydf are the following:
pydf -a: It allows us to verify which file system does not contain any block.
pydf -h: It will enable us to see the information displayed in clear language.
pydf -k: It allows to know the size of the partitions in Kilobytes.
pydf -m: It will enable to know the size of the partitions in Megabytes.
Command DF
It is another of the most used commands for the administration of partitions since this command allows us to see on the screen a complete summary of the disk space of the file system.
We can add the -hT parameter to obtain much more complete information such as disk size, free space, percentages of free space, etc. The command is the following:
df -hT
Some of the parameters to add are the following:
df -a: It includes much more complete information of the partitions.
df -l: Limit the search to the local file system.
df -t: Display the data using the type of file system.
df -v: It allows to see the version of the command.
df -help: Display the command help.
LSSCSI command
The LSSCSI command allows us to see information of the scsi and ATA devices connected to the computer, therefore, when executing it, the information of the disk partitions will be displayed. Just enter lsscsi in the terminal and we will see the following:
We have several options in Linux to verify and monitor what partitions we have available in our systems.
In this way with this command guide, we will have easy information about everything that happens on our computer.