Linux command – lsblk

Loading

lsblk – list block devices

測試環境為 CentOS 7 x86_64

lsblk 可以列出所有關於區塊設備 (Block devices) 的資訊. lsblk 主要是去讀取 sysfs 的資訊,關於 sysfs 請參考 https://benjr.tw/20857

[root@localhost ~]# lsblk 
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0   464G  0 disk 
├─sda1        8:1    0     1G  0 part /boot
└─sda2        8:2    0   463G  0 part 
  ├─cl-root 253:0    0    50G  0 lvm  /
  ├─cl-swap 253:1    0   7.9G  0 lvm  [SWAP]
  └─cl-home 253:2    0 405.1G  0 lvm  /home
sr0          11:0    1  1024M  0 rom 

lsblk 會列出所有 區塊設備 (Block devices) 的資訊,可以使用 -d 參數,顯示主要 區塊設備 (Block devices) 的資訊.

-d, –nodeps

Don’t print slaves or holders.

[root@localhost ~]# lsblk -d
NAME MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda    8:0    0  464G  0 disk 
sr0   11:0    1 1024M  0 rom  
[root@localhost ~]# lsblk -d /dev/sda
NAME MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda    8:0    0  464G  0 disk 

其他可以用的參數

  • -b, –bytes – print SIZE in bytes rather than in human readable format
  • -f, –fs – output info about filesystems
  • -i, –ascii – use ascii characters only
  • -m, –perms – output info about permissions
  • -l, –list – use list format output
  • -t, –topology – output info about topology
  • -S, –scsi – output info about SCSI devices
  • -o, –output – output columns

-o, –output

Output columns

[root@localhost ~]# lsblk -d -o name,serial,KNAME,MODEL,STATE,type,vendor
NAME SERIAL           KNAME MODEL            STATE   TYPE VENDOR
sda  220a00015519f2d6 sda   ST EX8650        running disk Promise 
sr0  006080270406     sr0   DVD A  DS8A4S    running rom  Slimtype

–output 可以用的參數

  • NAME – device name
  • KNAME – internal kernel device name
  • MAJ:MIN – major:minor device number
  • FSTYPE – filesystem type
  • MOUNTPOINT – where the device is mounted
  • LABEL – filesystem LABEL
  • UUID – filesystem UUID
  • PARTLABEL – partition LABEL
  • PARTUUID – partition UUID
  • RA – read-ahead of the device
  • RO – read-only device
  • RM – removable device
  • MODEL – device identifier
  • SERIAL – disk serial number
  • SIZE – size of the device
  • STATE – state of the device
  • OWNER – user name
  • GROUP – group name
  • MODE – device node permissions
  • ALIGNMENT – alignment offset
  • MIN-IO – minimum I/O size
  • OPT-IO – optimal I/O size
  • PHY-SEC – physical sector size
  • LOG-SEC – logical sector size
  • ROTA – rotational device
  • SCHED – I/O scheduler name
  • RQ-SIZE – request queue size
  • TYPE – device type
  • DISC-ALN – discard alignment offset
  • DISC-GRAN – discard granularity
  • DISC-MAX – discard max bytes
  • DISC-ZERO – discard zeroes data
  • WSAME – write same max bytes
  • WWN – unique storage identifier
  • RAND – adds randomness
  • PKNAME – internal parent kernel device name
  • HCTL – Host:Channel:Target:Lun for SCSI
  • REV – device revision
  • VENDOR – device vendor
  • 沒有解決問題,試試搜尋本站其他內容

    發佈留言

    發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

    這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料