Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of viewing hard disk Information by linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the method of linux to view hard disk information, the article is very detailed, has a certain reference value, interested friends must read it!

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

Viewing methods: 1, use the "df-h" command; 2, use the "lsblk" command; 3, use the "sudo lshw-class disk" command; 4, use the "fdisk-l" command; 5, use the "cat / proc/partitions" command; 6, use the "lsscsi" command.

The operating environment of this tutorial: Red Hat Enterprise Linux 6.1 system, Dell G3 computer.

Multiple hard drives can be installed on a computer, so let's take a look at how to view all the hard drive information in Linux. Two hard drives were added to the system, and the second one was not formatted or mounted.

1. Use df

The df command is used to view the usage of the hard disk in the file system, and it can also be used to list the hard disk mounted in the system. Use the-h option to output the hard disk usage in a human-readable format:

~ $df-h File system capacity used available mount point / dev/sda2 55G 3.7G 49G 8% / udev 2.0G 4.0K 2.0G 1% / devtmpfs 394M 776K 394M 1% / runnone 5.0M 05.0M 0% / run/locknone 2.0G 220K 2.0G 1% / Run/shm/dev/sda1 487M 3.3m 483m 1% / boot/efi

The df command cannot display unmounted hard drives.

2. Use lsblk

The lsblk command is used to view block devices:

$lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 60G 0 disk ├─ sda1 8:1 0 487M 0 part / boot/efi ├─ sda2 8:2 055.5G 0 part / └─ sda3 8:3 0 4G 0 part [SWAP] sdb 8:16 050G 0 disk sr0 11:0 1 1024M 0 rom

Without parameters, all hard drives are listed, the root node represents the hard disk, and the secondary node represents the partition on the disk. Use the-d option to list only the hard drive without partition information.

3. Use lshw

Lshw can print hardware details:

$sudo lshw-class disk *-disk:0 description: SCSI Disk physical id: 0.0.0 bus info: scsi@32:0.0.0 logical name: / dev/sda size: 60GiB (64GB) capabilities: gpt-1.00 partitioned partitioned:gpt configuration: guid=ff481b67-ace2-47b9-a7e8-a50d4e6a6e55 *-disk:1 description: SCSI Disk physical id: 0.1.0 Bus info: scsi@32:0.1.0 logical name: / dev/sdb size: 50GiB (53GB) *-cdrom description: DVD-RAM writer physical id: 0.0.0 bus info: scsi@3:0.0.0 logical name: / dev/cdrom logical name: / dev/cdrw logical name: / dev/dvd logical name: / dev/dvdrw logical name : / dev/sr0 capabilities: audio cd-r cd-rw dvd dvd-r dvd-ram configuration: status=open

4. Use fdisk

Fdisk is a commonly used partition table manipulation tool for formatting hard drives, partitions, etc., and can be used to print hard disk information:

$sudo fdisk-lWARNING: GPT (GUID Partition Table) detected on'/ devdeband sdaws! The util fdisk doesn't support GPT. Use GNU Parted.Disk / dev/sda: 64.4 GB, 64424509440 bytes255 heads, 63 sectors/track, 7832 cylinders, total 125829120 sectorsUnits = sector of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000 equipment start start end blocks Id system / dev/sda1 1125829119 62914559 + ee GPTDisk / dev/sdb: 53.7 GB, 53687091200 bytes255 heads 63 sectors/track, 6527 cylinders, total 104857600 sectorsUnits = sector of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk / dev/sdb doesn't contain a valid partition table

The fdisk tool does not support GPT partitioned tables and can be replaced by GNU Parted, the parted tool below.

5. Use / proc/partitions

You can view some information about the current hard drive and partition by viewing the contents of the / proc/partitions file:

$cat / proc/partitions major minor # blocks name 80 62914560 sda 8 1 498688 sda1 82 58221568 sda2 8 3 4192256 sda3 8 16 52428800 sdb 11 0 1048575 sr0

6. Use lsscsi

The lsscsi tool can print SCSI hard disk information. This tool is not installed by default in Ubuntu12.04 and needs to be installed by yourself:

Cd/dvd NECVMWar VMware SATA CD01 1. 00 / dev/sr0 [32 lsscsi 0] disk VMware, VMware Virtual S 1 / dev/sda [32 dev/sr0 0] disk VMware, VMware Virtual S 1.0 / dev/sdb is all of the contents of this article entitled "how to check hard disk Information by linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report