Home Operation and Maintenance Linux Operation and Maintenance How to check how many hard disks there are in Linux

How to check how many hard disks there are in Linux

Dec 31, 2021 pm 03:48 PM
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]".

How to check how many hard disks there are in Linux

#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 <list> 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 <list> 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
Copy after login
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
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

deepseek web version entrance deepseek official website entrance deepseek web version entrance deepseek official website entrance Feb 19, 2025 pm 04:54 PM

deepseek web version entrance deepseek official website entrance

Android TV Box gets unofficial Ubuntu 24.04 upgrade Android TV Box gets unofficial Ubuntu 24.04 upgrade Sep 05, 2024 am 06:33 AM

Android TV Box gets unofficial Ubuntu 24.04 upgrade

How to install deepseek How to install deepseek Feb 19, 2025 pm 05:48 PM

How to install deepseek

BitPie Bitpie wallet app download address BitPie Bitpie wallet app download address Sep 10, 2024 pm 12:10 PM

BitPie Bitpie wallet app download address

BITGet official website installation (2025 beginner's guide) BITGet official website installation (2025 beginner's guide) Feb 21, 2025 pm 08:42 PM

BITGet official website installation (2025 beginner's guide)

Zabbix 3.4 Source code compilation installation Zabbix 3.4 Source code compilation installation Sep 04, 2024 am 07:32 AM

Zabbix 3.4 Source code compilation installation

Detailed explanation: Shell script variable judgment parameter command Detailed explanation: Shell script variable judgment parameter command Sep 02, 2024 pm 03:25 PM

Detailed explanation: Shell script variable judgment parameter command

Ouyi okx installation package is directly included Ouyi okx installation package is directly included Feb 21, 2025 pm 08:00 PM

Ouyi okx installation package is directly included

See all articles