订阅云计算RSS CSDN首页> 云计算

如何在Linux下得到硬盘及usb信息

发表于2009-07-30 13:09| 次阅读| 来源ChinaUnix博客| 0 条评论| 作者

摘要:如何得到硬盘的信息?用fdisk -l 可以得到系统中已安装的硬盘列表及分区情况。

如何得到硬盘的信息?
1,用fdisk -l 可以得到系统中已安装的硬盘列表及分区情况
[root@localhost lhd]# fdisk -l
Disk /dev/sda: 40.0 GB, 40060403712 bytes
255 heads, 63 sectors/track, 4870 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xf0b1ebb0
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1275    10241406    c  W95 FAT32 (LBA)
/dev/sda2            1276        4870    28876837+   f  W95 Ext'd (LBA)
/dev/sda5            1276        2550    10241406    b  W95 FAT32
/dev/sda6            2551        2575      200781   83  Linux
/dev/sda7            2576        4870    18434556   8e  Linux LVM
2,如何得到硬盘的品牌及相关信息
1,smartctl -i /dev/sda
说明: smartctl是用来控制和监视 smart disk的程序
-i 参数用来显示设备的相关信息

例:
[root@localhost lhd]# smartctl -i /dev/sda
smartctl version 5.38 [i386-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF INFORMATION SECTION ===
Device Model:     SAMSUNG MP0402H
Serial Number:    S03WJ10YC01628
Firmware Version: UC100-11
User Capacity:    40,060,403,712 bytes
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   7
ATA Standard is:  ATA/ATAPI-7 T13 1532D revision 0
Local Time is:    Wed Jan 28 23:21:47 2009 CST
==> WARNING: May need -F samsung or -F samsung2 enabled; see manual for details.
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
2,有时使用smartctl不能得到我们预期的信息,例如:
[root@dev ~]# smartctl -i /dev/sda
smartctl version 5.36 [i686-redhat-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
Device: Dell     VIRTUAL DISK     Version: 1028
Device type: disk
Local Time is: Wed Jan 28 23:09:50 2009 CST
Device does not support SMART
这种情况如何处理:

[root@dev ~]# cat /proc/scsi/scsi                  
Attached devices:                                  
Host: scsi0 Channel: 00 Id: 00 Lun: 00             
Vendor: SEAGATE  Model: ST3146855SS      Rev: S527
Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi0 Channel: 00 Id: 01 Lun: 00
Vendor: SEAGATE  Model: ST3146855SS      Rev: S527
Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi0 Channel: 01 Id: 00 Lun: 00
Vendor: Dell     Model: VIRTUAL DISK     Rev: 1028
Type:   Direct-Access                    ANSI SCSI revision: 05

3,如何得到usb设备的信息
lsusb
例如:
[root@localhost lhd]# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 046d:c00f Logitech, Inc. MouseMan Traveler/Mobile
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
查看详细信息,可以加 -v
lsusb -v
查看某一个设备:
[root@localhost lhd]# lsusb -s 003:002 -v                           
Bus 003 Device 002: ID 046d:c00f Logitech, Inc. MouseMan Traveler/Mobile
Device Descriptor:                                                     
bLength                18                                            
bDescriptorType         1                                            
bcdUSB               2.00                                            
bDeviceClass            0 (Defined at Interface level)               
bDeviceSubClass         0                                            
bDeviceProtocol         0                                            
bMaxPacketSize0         8                                            
idVendor           0x046d Logitech, Inc.                             
idProduct          0xc00f MouseMan Traveler/Mobile                   
bcdDevice           11.10                                            
iManufacturer           1 Logitech                                   
iProduct                2 USB-PS/2 Optical Mouse                     
iSerial                 0                                            
bNumConfigurations      1                                            
Configuration Descriptor:                                            
bLength                 9                                          
bDescriptorType         2                                          
wTotalLength           34                                          
bNumInterfaces          1                                          
bConfigurationValue     1                                          
iConfiguration          0                                          
bmAttributes         0xa0                                          
(Bus Powered)                                                    
Remote Wakeup
MaxPower               98mA
Interface Descriptor:
bLength                 9
bDescriptorType         4
bInterfaceNumber        0
bAlternateSetting       0
bNumEndpoints           1
bInterfaceClass         3 Human Interface Device
bInterfaceSubClass      1 Boot Interface Subclass
bInterfaceProtocol      2 Mouse
iInterface              0
HID Device Descriptor:
bLength                 9
bDescriptorType        33
bcdHID               1.10
bCountryCode            0 Not supported
bNumDescriptors         1
bDescriptorType        34 Report
wDescriptorLength      52
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x81  EP 1 IN
bmAttributes            3
Transfer Type            Interrupt
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0004  1x 4 bytes
bInterval              10
Device Status:     0x0000
(Bus Powered)

0
0
如何在Linux下得到硬盘及usb信息