Linux查看硬盘信息方法总结

news/2024/12/2 20:48:57/
转载请注明文章出处:https://tlanyan.me/linux-list-disk-info-summary

本文简要总结Linux查看硬盘信息的方法,基本涵盖普通用户、系统管理员所能接触到的各种命令。

lsblk

lsblk命令用来查看接入到系统中的块设备,默认输出分区、大小、挂载点等信息,一目了然:

tlanyan@node1:~$ lsblk
sda      8:0    0 558.9G  0 disk
├─sda1   8:1    0   488M  0 part
├─sda2   8:2    0     1K  0 part
├─sda5   8:5    0   7.6G  0 part
└─sda6   8:6    0 550.8G  0 part /
sdb      8:16   0 558.9G  0 disk
├─sdb1   8:17   0     1K  0 part
└─sdb5   8:21   0 558.9G  0 part /journal
sdc      8:32   0   1.8T  0 disk /work
sr0     11:0    1  1024M  0 rom

df

df命令用来查看硬盘的使用情况,经常配合-h给出友好的输出:

tlanyan@node1:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev             24G     0   24G   0% /dev
tmpfs           4.8G  2.1M  4.8G   1% /run
/dev/sda6       542G  148G  366G  29% /
tmpfs            24G     0   24G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs            24G     0   24G   0% /sys/fs/cgroup
/dev/sdc        1.8T  1.2T  582G  67% /work
/dev/sdb5       551G  245G  278G  47% /journal

需要注意的是df只能输出已挂载的磁盘分区信息,不能显示未挂载的硬盘。

另一个相似的命令是du,用来显示占用的硬盘空间,例如统计当前目录下文件大小:du -sh *

fdisk

fdisk是常用的硬盘、分区操作工具,需要root权限执行,-l参数可以打印硬盘信息:

root@node1:~# fdisk -l
Disk /dev/sda: 558.9 GiB, 600127266816 bytes, 1172123568 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: 0xdf3a7994Device     Boot    Start        End    Sectors   Size Id Type
/dev/sda1  *        2048    1001469     999422   488M 83 Linux
/dev/sda2        1001470 1172121599 1171120130 558.4G  5 Extended
/dev/sda5        1001472   17000447   15998976   7.6G 82 Linux swap / Solaris
/dev/sda6       17002496 1172121599 1155119104 550.8G 83 LinuxDisk /dev/sdb: 558.9 GiB, 600127266816 bytes, 1172123568 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: 0x0006c4c0Device     Boot Start        End    Sectors   Size Id Type
/dev/sdb1          63 1172118464 1172118402 558.9G  5 Extended
/dev/sdb5         126 1172118464 1172118339 558.9G 83 LinuxDisk /dev/sdc: 1.8 TiB, 2000398934016 bytes, 3907029168 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: 0x7af0ba03

fdisk不支持GPT分区,需要要到下文的parted查看。

parted

parted是一个分区操作工具,需要root权限,否则输出为空:

root@node1:~# parted -l
Model: HITACHI HUS156060VLS600 (scsi)
Disk /dev/sda: 600GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:Number  Start   End     Size    Type      File system     Flags1      1049kB  513MB   512MB   primary   ext4            boot2      513MB   600GB   600GB   extended5      513MB   8704MB  8191MB  logical   linux-swap(v1)6      8705MB  600GB   591GB   logical   ext4Model: HITACHI HUS156060VLS600 (scsi)
Disk /dev/sdb: 600GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:Number  Start   End    Size   Type      File system  Flags1      32.3kB  600GB  600GB  extended5      64.5kB  600GB  600GB  logical   ext4Model: SEAGATE ST2000NM0023 (scsi)
Disk /dev/sdc: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:Number  Start  End  Size  Type  File system  Flags

lsscsi

lsscsi可以打印SCSI硬盘信息,该命令在Ubuntu中默认没有安装:

tlanyan@node1:~$ lsscsi
[0:0:0:0]    cd/dvd  PLDS     DVD+-RW DH-16ACS JD11  /dev/sr0
[6:0:0:0]    disk    HITACHI  HUS156060VLS600  E516  /dev/sda
[6:0:1:0]    disk    HITACHI  HUS156060VLS600  E516  /dev/sdb
[6:0:2:0]    disk    SEAGATE  ST2000NM0023     0003  /dev/sdc

blkid

blkid命令可以打印块设备的信息:

tlanyan@node1:~$ blkid
/dev/sda6: UUID="93875607-7910-43d3-ac02-32200cfcea1a" TYPE="ext4" PARTUUID="df3a7994-06"
/dev/sda1: UUID="90cfad05-f84b-49fd-ac60-06c5d9c7382c" TYPE="ext4" PARTUUID="df3a7994-01"
/dev/sda5: UUID="66c522a8-b0eb-4a44-9ba9-2765b70eff28" TYPE="swap" PARTUUID="df3a7994-05"
/dev/sdb5: UUID="8a400f90-2390-4b5d-9fd2-58331c1230e2" TYPE="ext4" PARTUUID="0006c4c0-05"
/dev/sdc: LABEL="M-fM-^VM-0M-eM-^MM-7" UUID="8bd7100c-4120-4cf3-8d1e-268d4cf12bac" TYPE="ext4" PTUUID="7af0ba03" PTTYPE="dos"

lshw

lshw命令用来打印硬件的详细信息,打印硬盘信息需要root权限:

root@node1:~# lshw -class disk*-disk:0description: SCSI Diskproduct: HUS156060VLS600vendor: HITACHIphysical id: 0.0.0bus info: scsi@6:0.0.0logical name: /dev/sdaversion: E516serial: LXWMTVTMsize: 558GiB (600GB)capacity: 690GiB (741GB)capabilities: 15000rpm partitioned partitioned:dosconfiguration: ansiversion=6 logicalsectorsize=512 sectorsize=512 signature=df3a7994*-disk:1description: SCSI Diskproduct: HUS156060VLS600vendor: HITACHIphysical id: 0.1.0bus info: scsi@6:0.1.0logical name: /dev/sdbversion: E516serial: LXWMTWAMsize: 558GiB (600GB)capacity: 690GiB (741GB)capabilities: 15000rpm partitioned partitioned:dosconfiguration: ansiversion=6 logicalsectorsize=512 sectorsize=512 signature=0006c4c0*-cdromdescription: DVD-RAM writerproduct: DVD+-RW DH-16ACSvendor: PLDSphysical id: 0.0.0bus info: scsi@0:0.0.0logical name: /dev/cdromlogical name: /dev/cdrwlogical name: /dev/dvdlogical name: /dev/dvdrwlogical name: /dev/sr0version: JD11capabilities: removable audio cd-r cd-rw dvd dvd-r dvd-ramconfiguration: ansiversion=5 status=nodisc

mount

mount常用来挂载硬盘、分区等,自然也就可以查看挂载信息:

tlanyan@node1:~$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=24697992k,nr_inodes=6174498,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=4944076k,mode=755)
/dev/sda6 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
/dev/sdc on /work type ext4 (rw,relatime,data=ordered)
/dev/sdb5 on /journal type ext4 (rw,relatime,data=ordered)

exportfs

exportfs命令用来查看NFS共享文件夹,需要root权限:

root@node1:~# exportfs -s
/work  192.168.1.12(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
/work  192.168.1.13(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
/opt  192.168.1.12(ro,wdelay,no_root_squash,no_subtree_check,sec=sys,ro,secure,no_root_squash,no_all_squash)
/opt  192.168.1.13(ro,wdelay,no_root_squash,no_subtree_check,sec=sys,ro,secure,no_root_squash,no_all_squash)

如果你还知道其他命令,欢迎指教。


http://www.ppmy.cn/news/498773.html

相关文章

基于Echarts+HTML5可视化数据大屏展示—智慧社区内网对比平台

机缘 从初到现在已经学习快六年了,在高中的时候就很喜欢玩电脑,但却不知道电脑到底用来干嘛只知道计算机可以查阅资料 电脑游戏 电影 shopping等等,最初接触编程是因为我的表哥,我表哥学的计算机专业,高中是半个月放假一次,每次玩手机的时候看他朋友圈都里发那些看不…

DASCTF2022.07赋能赛Crypto_复现

DASCTF2022.07赋能赛Crypto_复现 easyNTRU keywords: 格密码私钥爆破 P r o b l e m Problem Problem from Crypto.Hash import SHA3_256 from Crypto.Cipher import AES from Crypto.Util.Padding import pad from secret import flag# parameters N 10 p 3 q 512 d 3 …

echarts中的中国地图js源码(china.js)

ECharts官方已不再提供js地图下载,china.js的源码如下,只需要新建一个js文件,然后将以下js代码复制进去保存即可引用,也不用浪费积分去下载资源 (function (root, factory) {if (typeof define function && define.amd)…

fullCalendar 使用手册

fullCalendar 使用手册 标签(空格分隔): fullCalendar 仰仗网络: fullCalendar官方网站 fullCalendar改造为农历 fullCalendar的基本事件的实现 fullCalendar的基本事件的实现2 一、简述 简单的说 fullCalendar 是一个日历控件…

linux磁盘信息文件,Linux查看硬盘信息方法总结归纳

Linux查看硬盘信息方法总结归纳 lsblk lsblk命令用来查看接入到系统中的块设备,默认输出分区、大小、挂载点等信息,一目了然: tlanyan@node1:~$ lsblk sda 8:0 0 558.9G 0 disk ├─sda1 8:1 0 488M 0 part ├─sda2 8:2 0 1K 0 part ├─sda5 8:5 0 7.6G 0 part └─sda6 8…

DASCTF2022 7月赋能赛 crypto wp(DASCTF2022.07赋能赛Pwn easyheap)

文章目录DASCTF2022 7月赋能赛 crypto wp sigin ezNTRU NTRURSA 碎碎念 import hashlib import ecdsa from Crypto.Util.number import * import random import osflag = b"xxx"assert flag.startswith(bDASCTF{) and flag.endswith(b}) assert len(flag) == 40def …

HITSZ嵌入式计算(研)23年Keil模拟器项目解决方案

HITSZ嵌入式计算(研)23年Keil模拟器项目解决方案 1. 项目介绍2. Keil安装3. 创建新项目3.1 参考博文3.2 流程 4. 发送串口数据4.1 参考博文4.2 串口收发流程 5. 产生波形5.1 头文件封装5.2 初始化GPIO口5.3 产生并观察方波 6. Keil信号函数和中断6.1 中断…

Java技术-接口文档-Swagger2Swagger3接口文档UI整合

一、Swagger2完整用法 二、Swagger3完整用法 三、Swagger整合Knife4jUi import com.ikong.model.req.TestReq; import com.ikong.model.ret.TestRet; import com.jd.security.framework.common.model.Result; import io.swagger.annotations.ApiImplicitParam; import io.sw…