获取linux命令硬盘信息,Linux 下使用命令获取硬盘信息
本文主要是一些和硬盘相关的命令,包括如何查看硬盘的型号,容量,还有硬盘上的分区情况,来详细了解本机硬盘的状态。
hdparm
如果想要在 Linux 下查看硬盘信息,可以使用命令 hdparm 。这个命令可以用来查看硬盘制造商,序列号等等有用信息。man hdparm 中告诉我, hdparm 命令是用来查看或者设置 SATA/IDE 设备参数的。
查看设备信息
假设本地有设备 /dev/sda 那么可以使用
hdparm -I /dev/sda
来查看该设备的信息
/dev/sda:
ATA device, with non-removable media
Model Number: Netac SSD 240G
Serial Number: 5002B725438XXXX
Firmware Revision: O1217A
Transport: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
Supported: 9 8 7 6 5
Likely used: 9
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: 468862128
Logical Sector size: 512 bytes
Physical Sector size: 512 bytes
Logical Sector-0 offset: 0 bytes
device size with M = 1024*1024: 228936 MBytes
device size with M = 1000*1000: 240057 MBytes (240 GB)
cache/buffer size = unknown
Nominal Media Rotation Rate: Solid State Device
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 = 2 Current = 2
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
Commands/features:
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set
* WRITE_BUFFER command
* READ_BUFFER command
* NOP cmd
* DOWNLOAD_MICROCODE
SET_MAX security extension
* 48-bit Address feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* FLUSH_CACHE_EXT
* SMART error logging
* SMART self-test
* General Purpose Logging feature set
* WRITE_{DMA|MULTIPLE}_FUA_EXT
* {READ,WRITE}_DMA_EXT_GPL commands
* Segmented DOWNLOAD_MICROCODE
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Gen3 signaling speed (6.0Gb/s)
* Native Command Queueing (NCQ)
* Host-initiated interface power management
* Phy event counters
* READ_LOG_DMA_EXT equivalent to READ_LOG_EXT
* DMA Setup Auto-Activate optimization
Device-initiated interface power management
* Software settings preservation
Device Sleep (DEVSLP)
* SMART Command Transport (SCT) feature set
* SCT Write Same (AC2)
* SCT Features Control (AC4)
* SCT Data Tables (AC5)
* DOWNLOAD MICROCODE DMA command
* WRITE BUFFER DMA command
* READ BUFFER DMA command
* Data Set Management TRIM supported (limit 8 blocks)
* Deterministic read ZEROs after TRIM
Security:
Master password revision code = 65534
supported
not enabled
not locked
frozen
not expired: security count
supported: enhanced erase
2min for SECURITY ERASE UNIT. 2min for ENHANCED SECURITY ERASE UNIT.
Device Sleep:
DEVSLP Exit Timeout (DETO): 40 ms (drive)
Minimum DEVSLP Assertion Time (MDAT): 31 ms (drive)
Checksum: correct
测试读取速度
hdparm 提供了一个简单的读速度测试参数
hdparm -Tt /dev/sda
结果
/dev/sda:
Timing cached reads: 25572 MB in 2.00 seconds = 12798.56 MB/sec
Timing buffered disk reads: 800 MB in 3.01 seconds = 266.08 MB/sec
能够看到 2 秒内读取了 25572M 缓存,而在 3 秒内从磁盘上物理读 800M 数据。
fdisk
fdisk 主要用来查看和修改硬盘分区表,它能够识别 GPT,MBR,BSD 等等分区表。设备可以被划分为一个或者若干逻辑磁盘,这些逻辑磁盘叫做分区。这些分区信息被包含在分区表 (partition table) 中,通常在硬盘的 sector 0 中保存。
设备名通常叫做 /dev/sda, /dev/sdb 等等,设备的名字通常指整块硬盘,分区名字通常是设备名后面加上分区的序号,比如 /dev/sda1 表示的是第一块硬盘上的一个分区。详细的信息可以在 Linux kernel 文档 Documentation/devices.txt 文件中找到。
GPT
GPT 的全称是 GUID Partition Table,全局唯一标识分区表,指的是一个实体硬盘的分区表结构布局标准。
MBR
MBR 全称为 Master Boot Record,主引导扇区, DOS type。Sector 0 是被 4 个主分区 primary partition 描述占用的,逻辑分区 (Logical partition) 从序号 5 开始。
如果要查看硬盘的分区情况,可以使用 fdisk
fdisk -l
结果
Disk /dev/loop0: 81.7 MiB, 85692416 bytes, 167368 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop1: 81.7 MiB, 85639168 bytes, 167264 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop2: 81.6 MiB, 85549056 bytes, 167088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5ad18deb
Device Boot Start End Sectors Size Id Type
/dev/sda1 63 468862127 468862065 223.6G 83 Linux
Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x29049925
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 63 629153594 629153532 300G 7 HPFS/NTFS/exFAT
/dev/sdb2 629153656 1953523711 1324370056 631.5G f W95 Ext'd (LBA)
/dev/sdb5 629153658 1153466999 524313342 250G 7 HPFS/NTFS/exFAT
/dev/sdb6 1153467063 1782588464 629121402 300G 7 HPFS/NTFS/exFAT
/dev/sdb7 1782589440 1798213631 15624192 7.5G 82 Linux swap / Solaris
/dev/sdb8 1798215680 1953523711 155308032 74.1G 83 Linux
Partition 1 does not start on physical sector boundary.
Partition 5 does not start on physical sector boundary.
Partition 6 does not start on physical sector boundary.
Disk /dev/sdc: 119.2 GiB, 128035676160 bytes, 250069680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x326f11b9
Device Boot Start End Sectors Size Id Type
/dev/sdc1 * 63 248346992 248346930 118.4G 7 HPFS/NTFS/exFAT
/dev/sdc2 248348672 250066943 1718272 839M 27 Hidden NTFS WinRE
dd
dd 工具是一个专业的测试工具,对测试结果不苛求可以用来做 IO 读写的简单评估。首先要了解两个特殊设备:
/dev/null 伪设备,回收站。写该文件不会产生 IO
/dev/zero 伪设备,会产生空字符流,对它不会产生 IO
dd 命令使用:
dd if=/dev/zero of=/tmp/test bs=1G count=1 oflag=dsync
if 用来设置 dd 命令读取的输入文件名
of dd 输出文件名
bs 设置 dd 命令读取的块大小
count dd 命令读取的块个数
oflag=dsync 使用同步 I/O 去除 caching 影响
综上
测试硬盘写速度
sync; dd if=/dev/zero of=tempfile bs=1M count=1024; sync
测试磁盘读速度
dd if=tempfile of=/dev/null bs=1M count=1024
GUI
同样在 Linux 下也可以使用 GUI 图形化的工具来查看,搜索菜单 Disks,然后就能查看当前电脑安装的硬盘了。
查看分区
使用命令 lsblk 查看。
https://en.wikipedia.org/wiki/GUID_Partition_Table ↩
获取linux命令硬盘信息,Linux 下使用命令获取硬盘信息相关推荐
- linux前一个的输出作为后一个参数,将Linux命令的结果作为下一个命令的参数
查询所有的pid并杀死. jps -l | grep bdcsc2-native-demo | awk '{print $1}' | xargs kill -9 KISS:keep it short ...
- linux vsftpd用法,Linux_LINUX系统下vsftpd 命令详解,FTP命令是Internet用户使用最频 - phpStudy...
LINUX系统下vsftpd 命令详解 FTP命令是Internet用户使用最频繁的命令之一,不论是在DOS还是UNIX操 作系统下使用FTP,都会遇到大量的FTP内部命令. 熟悉并灵活应用FTP的内 ...
- linux java读取文件夹下文件名,Java获取Linux上指定文件夹下所有第一级子文件夹...
说明:需要只获得第一级文件夹目录 package com.sunsheen.jfids.studio.monitor.utils; import java.io.BufferedReader; imp ...
- 在linux系统环境中 常用的关机命令,Linux常用基础命令整理:关机命令、查看目录下文件命令等...
整理了一些Linux常用基础命令,欢迎指正. 首先记住四个热键,学会这四个键,收益一辈子. Tab按键---命令补齐功能 Ctrl+c按键---停掉正在运行的程序 Ctrl+d按键---相当于exit ...
- 批处理常用命令总结和WindowsXP下运行命令使用大全及优化
关于批处理以及批处理常用命令的总结 [ 一.什么是批处理 ] 批处理文件图标 批处理(Batch),也称为批处理脚本.顾名思义,批处理就是对某对象进行批量的处理.批处理文件的扩展名为 bat . 目前 ...
- Windwos命令工作笔记002---windows下tree命令列出文件目录打印到文件中_过滤文件不知道怎么做啊
技术交流QQ群[JAVA,.NET,BigData,AI]:170933152 挺好用,一直想记录下来的 windows下tree命令列出文件目录树 tree [path] /f tree D:AR ...
- linux 查看显卡信号_Linux下如何查看NVIDIA显卡信息
匿名用户 1级 2015-07-28 回答 lspci | grep -i vga 这样就可以显示机器上的显卡信息,比如 [root@localhost conf]# lspci | grep -i ...
- linux(ubuntu)系统下Top命令详解
参考链接: 1. https://www.cnblogs.com/niuben/p/12017242.html 2. https://blog.csdn.net/qq_39416311/article ...
- 将windows c盘安装在linux,将WindowsC盘hda1安装在Linux文件系统的/winsys目录下,命令是()。...
_ 什么叫做可再生能源?什么叫做不可再生能源? 井筒施工时,应及时观测()等变化情况.当发现影响施工的不利地质因素时,应及时提供补充地质资料. PAEI中的A是指() 破伤风症状出现的顺序是() 下面 ...
- python输入y继续运行_python – 如何使Fabric在获取退出状态后继续运行下一个命令:1?...
我将通过编写一个简单的fabfile来安装 check_mk插件: from fabric.api import env, run, roles, execute, parallel env.role ...
最新文章
- 2022-2028年中国版权行业深度调研及投资前景预测报告
- 编写程序计算交错序列_外文翻译 | FlyMC:高度可扩展地测试分布式系统中的复杂交错...
- Android 带有字数统计的 TextInputLayout
- 通过RADIUS 服务器管理无线AP的VLAN
- 前端学习(2227):react之状态二
- 爬虫中如何获取页面编码类型
- k均值的损失函数_K-Means算法的实现
- 【Elasticsearch】搜索自己想要的东西与注释文本(字符串)插件
- python 元组的一点问题
- Java Web程序设计——图书管理系统
- matlab解超越函数,矩阵的超越函数Matlab提供的矩阵函数.PPT
- css圣杯布局与双飞翼布局_CSS布局研讨会已于2018年更新
- 大数据架构师——音乐数据中心平台离线数仓综合项目(一)
- 如何高效建设传奇的DAO
- 实验4-1-12 黑洞数 (20 分)
- oracle rfs进程过多,Oracle物理备库RFS进程消失,不能启动--解决
- 怎么画思维导图?玩转MindNow六大思维结构
- 幼儿园监控/透明装饰/安全工地/放心食堂/多媒体教室基于视频流媒体能力解决方案
- Jenkins整合dingding json pusher,发送自定义消息到钉钉群
- 李嘉诚传给年青人的53条人生忠告