Home>Article>Operation and Maintenance> How to check how many hard disks there are in Linux
In Linux, you can use the lsblk command to view how many hard disks there are. This command is used to list information about all available block devices and display the dependencies between block devices. By default, it will be displayed in a tree format. List all hard disk information and partitions, the syntax is "lsblk [options]".
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
How to check how many hard disks there are in linux
The lsblk command is used to list information about all available block devices, and it can also display the information between them. dependencies, but it does not list the RAM disk information. Block devices include hard drives, flash drives, cd-ROMs, etc. The lsblk command is included in the util-linux-ng package, which is now renamed util-linux.
This package comes with several other tools, such as dmesg. To install lsblk, download the util-linux package here. Fedora users can install this package through the command sudo yum install util-linux-ng.
Options
-a, --all Display all devices.
-b, --bytes Display the device size in bytes.
-d, --nodeps Do not display slaves or holders.
-D, --discard print discard capabilities.
-e, --exclude 4309a73696dbaeac0ddd115cebb6f9b7 Exclude devices (default: RAM disks).
-f, --fs Display file system information.
-h, --help Display help information.
-i, --ascii Use ascii characters only.
-m, --perms Display permission information.
-l, --list Use list format to display.
-n, --noheadings Does not display titles.
-o, --output 4309a73696dbaeac0ddd115cebb6f9b7 Output column.
-P, --pairs Use key="value" format to display.
-r, --raw Use raw format to display.
-t, --topology Display topology information.
Example
The lsblk command will list all block devices in a tree view by default. Open a terminal and enter the following command:
lsblk
NAME MAJ:MIN rm SIZE RO type mountpoint sda 8:0 0 232.9G 0 disk ├─sda1 8:1 0 46.6G 0 part / ├─sda2 8:2 0 1K 0 part ├─sda5 8:5 0 190M 0 part /boot ├─sda6 8:6 0 3.7G 0 part [SWAP] ├─sda7 8:7 0 93.1G 0 part /data └─sda8 8:8 0 89.2G 0 part /personal sr0 11:0 1 1024M 0 rom
The 7 column names are as follows:
NAME: This is the block device name.
MAJ:MIN: This column displays the major and minor device numbers.
RM: This column displays whether the device is removable. Note that in this example, the RM value of devices sdb and sr0 is equal to 1, which indicates that they are removable devices.
SIZE: This column lists the capacity information of the device. For example, 298.1G indicates that the device size is 298.1GB, while 1K indicates that the device size is 1KB.
RO: This item indicates whether the device is read-only. In this case, all devices have an RO value of 0, indicating that they are not read-only.
TYPE: This column displays whether the block device is a disk or a partition on the disk. In this example, sda and sdb are the disks, and sr0 is the read-only storage (rom).
MOUNTPOINT: This column indicates the mount point where the device is mounted.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of How to check how many hard disks there are in Linux. For more information, please follow other related articles on the PHP Chinese website!