在Linux上如何查看硬盘信息

时间:2019-11-20 08:53:26  来源:igfitidea点击:

在Linux中,如何查看硬盘的总线类型,大小,型号等信息?
Linux查看硬盘驱动器信息的命令是什么?

使用lsblk命令查看硬盘信息

使用lsblk命令查看块设备信息:

# lsblk
# lsblk /dev/DISK
# lsblk /dev/sda
NAME            MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda               8:0    0  20G  0 disk 
├─sda1            8:1    0   1G  0 part /boot
└─sda2            8:2    0  19G  0 part 
  ├─centos-root 253:0    0  17G  0 lvm  /
  └─centos-swap 253:1    0   2G  0 lvm  [SWAP]

查看所有磁盘及其名称:

# ls -lF /dev/disk/by-id/
lrwxrwxrwx. 1 root root  9 Dec 29 09:14 ata-VMware_Virtual_IDE_CDROM_Drive_10000000000000000001 -> ../../sr0
lrwxrwxrwx. 1 root root 10 Dec 29 09:14 dm-name-centos-root -> ../../dm-0
lrwxrwxrwx. 1 root root 10 Dec 29 09:14 dm-name-centos-swap -> ../../dm-1
lrwxrwxrwx. 1 root root 10 Dec 29 09:14 dm-uuid-LVM-TD3OtGEIyfjUU3asC2sbi6bgWqvn1Nfl3Y2EwA3Dq1YDck35cuMMuKt2u8q64MB3 -> ../../dm-1
lrwxrwxrwx. 1 root root 10 Dec 29 09:14 dm-uuid-LVM-TD3OtGEIyfjUU3asC2sbi6bgWqvn1Nfly77P0o0WwnRt1bypDcOVBtMmO93sia4D -> ../../dm-0
lrwxrwxrwx. 1 root root 10 Dec 29 09:14 lvm-pv-uuid-22xvei-rylM-x8IX-fuVD-SRoN-EfVb-mZgWzl -> ../../sda2

Linux如何查看硬盘的UUID

执行blkid命令:

# blkid
/dev/sda1: UUID="fe41e0dd-0ec2-4d88-9f67-2289eec04da0" TYPE="xfs" 
/dev/sda2: UUID="22xvei-rylM-x8IX-fuVD-SRoN-EfVb-mZgWzl" TYPE="LVM2_member" 
/dev/sr0: UUID="2020-04-22-00-54-00-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos" 
/dev/mapper/centos-root: UUID="479e3cb1-5ccc-418e-b7c0-d025998e9996" TYPE="xfs" 
/dev/mapper/centos-swap: UUID="779ab98c-d315-4b80-b8b9-c299b66bfbd7" TYPE="swap" 

hdparm命令

查看有关/dev/sda的信息:

# hdparm -I /dev/sda

或者

$ sudo hdparm -I /dev/sda

输出示例:

/dev/sda:

ATA device, with non-removable media
        Model Number:       ST3500630AS                             
        Serial Number:      YZ845YZX03
        Firmware Revision:  3.AAK   
Standards:
        Supported: 7 6 5 4 
        Likely used: 7
Configuration:
        Logical         max     current
        cylinders       16383   16383
        heads           16      16
        sectors/track   63      63
        --
        CHS current addressable sectors:   16514064
        LBA    user addressable sectors:  268435455
        LBA48  user addressable sectors:  976773168
        device size with M = 1024*1024:      476940 MBytes
        device size with M = 1000*1000:      500107 MBytes (500 GB)
Capabilities:
        LBA, IORDY(can be disabled)
        Queue depth: 32
        Standby timer values: spec'd by Standard, no device specific minimum
        R/W multiple sector transfer: Max = 16  Current = 16
        Recommended acoustic management value: 254, current value: 0
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4 
             Cycle time: no flow control=120ns  IORDY flow control=120ns
Checksum: correct

lshw命令

使用apt-get或yum命令安装lshw命令。

查看系统中的所有磁盘和控制器:

# lshw -class disk -class storage

输出示例:

  *-ide                     
       description: IDE interface
       product: 82371AB/EB/MB PIIX4 IDE
       vendor: Intel Corporation
       physical id: 7.1
       bus info: pci@0000:00:07.1
       logical name: scsi2
       version: 01
       width: 32 bits
       clock: 33MHz
       capabilities: ide isa_compat_mode pci_native_mode bus_master emulated
       configuration: driver=ata_piix latency=64
       resources: irq:0 ioport:1f0(size=8) ioport:3f6 ioport:170(size=8) ioport:376 ioport:10c0(size=16)
     *-cdrom
          description: DVD-RAM writer
          product: VMware IDE CDR10
          vendor: NECVMWar
          physical id: 0.0.0
          bus info: scsi@2:0.0.0
          logical name: /dev/cdrom
          logical name: /dev/sr0
          version: 1.00
          capabilities: removable audio cd-r cd-rw dvd dvd-r dvd-ram
          configuration: ansiversion=5 status=ready
        *-medium
             physical id: 0
             logical name: /dev/cdrom
             capabilities: partitioned partitioned:dos
             configuration: signature=26065fed
  *-scsi
       description: SCSI storage controller
       product: 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI
       vendor: Broadcom / LSI
       physical id: 10
       bus info: pci@0000:00:10.0
       logical name: scsi0
       version: 01
       width: 64 bits
       clock: 33MHz
       capabilities: scsi bus_master rom scsi-host
       configuration: driver=mptspi latency=64 maxlatency=255 mingnt=6
       resources: irq:17 ioport:1400(size=256) memory:c8040000-c805ffff memory:c8020000-c803ffff memory:c0008000-c000bfff
     *-disk
          description: SCSI Disk
          product: VMware Virtual S
          vendor: VMware,
          physical id: 0.0.0
          bus info: scsi@0:0.0.0
          logical name: /dev/sda
          version: 1.0
          size: 20GiB (21GB)
          capabilities: 7200rpm partitioned partitioned:dos
          configuration: ansiversion=2 logicalsectorsize=512 sectorsize=512 signature=00009758

Linux查看所有磁盘设备

使用lshw命令将快速列出已安装的磁盘,包括光驱:

# lshw -short -C disk

输出示例:

H/W path              Device      Class          Description
============================================================
/0/100/7.1/0.0.0      /dev/cdrom  disk           VMware IDE CDR10
/0/100/7.1/0.0.0/0    /dev/cdrom  disk           
/0/100/10/0.0.0       /dev/sda    disk           21GB VMware Virtual S

使用fdisk命令搜索系统中的磁盘:

# fdisk -l
# fdisk -l | grep '^Disk /dev/'
# fdisk -l | grep '^Disk /dev/' | egrep -v '/dev/(loop|mapper|md)'
Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 sectors
Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors

smartctl命令

smartctl命令是SMART磁盘的控制和监视实用程序。

查看/dev/sda(SATA磁盘)的信息:

# smartctl -d scsi -a -i /dev/sda

输出示例:

=== START OF INFORMATION SECTION ===
Vendor:               VMware,
Product:              VMware Virtual S
Revision:             1.0
User Capacity:        21,474,836,480 bytes [21.4 GB]
Logical block size:   512 bytes
Device type:          disk
Local Time is:        Tue Jan  5 08:40:04 2017 EST
SMART support is:     Unavailable - device lacks SMART capability.

=== START OF READ SMART DATA SECTION ===
Current Drive Temperature:     0 C
Drive Trip Temperature:        0 C

Error Counter logging not supported

Device does not support Self Test logging