Linux查看硬盘是SSD还是HDD

硬盘

固态硬盘32G,机械硬盘500G。

Linux查看硬盘是SSD还是HDD_第1张图片

测试

32G固态:

root@www:~# cat /sys/block/sda/queue/rotational
0

root@www:~# cat /sys/block/sda/uevent
MAJOR=8
MINOR=0
DEVNAME=sda
DEVTYPE=disk
PHYSDEVPATH=/devices/platform/ahci.0/ata1/host0/target0:0:0/0:0:0:0
PHYSDEVBUS=scsi
PHYSDEVDRIVER=sd

root@www:~# fdisk -lu
Disk /dev/sda: 32.0 GB, 32017047552 bytes
255 heads, 63 sectors/track, 3892 cylinders, total 62533296 sectors
Units = sectors of 1 * 512 = 512 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1              63    62524979    31262458+ 83 Linux

500G机械:

root@www:~# cat /sys/block/sda/queue/rotational 
1

root@www:~# cat /sys/block/sda/uevent
MAJOR=8
MINOR=0
DEVNAME=sda
DEVTYPE=disk
PHYSDEVPATH=/devices/platform/ahci.0/ata1/host0/target0:0:0/0:0:0:0
PHYSDEVBUS=scsi
PHYSDEVDRIVER=sd

root@www:~# fdisk -lu
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1              63     3919859     1959898+ 83 Linux
/dev/sda2         3919860   976768064   486424102+ 83 Linux

总结

查看/sys/block/sda/queue/rotational数值,1表示旋转就是机械硬盘,0非旋转就是固态硬盘。

问题

1、TF卡或者SD卡或者U盘这个数值有吗?是多少?【有值且是1】

2、怎么查看硬盘参数?【hdparm [OPTIONS] [DEVICE]】

hdparm 查看SD卡信息:

/dev/sda:
hdparm: ioctl 0x304 failed: Invalid argument
hdparm: HDIO_GET_IDENTITY: Invalid argument

3、搜索设备节点名称

~ # fdisk -l
Disk /dev/sdb: 31.1 GB, 31104958464 bytes
255 heads, 63 sectors/track, 3781 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sdb1               1        3780    30362818+ 83 Linux

Disk /dev/sda: 15.5 GB, 15502147584 bytes
255 heads, 63 sectors/track, 1884 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/sda1               1        1883    15125166  83 Linux
~ # 
~ # fdisk -l|grep "Disk /dev/sd[a-z]:.*GB"|awk -F ':' '{print$1}'|awk '{printf "
%s ",$2}'
/dev/sdb /dev/sda 
~ # 

4、总结:判断是否是硬盘:搜寻fdisk里面有容量和节点,然后使用hdparm查看硬盘信息,然后查看rotational数值。

 

你可能感兴趣的:(Linux)