lsblk command

2 분 소요

linux의 lsblk 명령어를 통해 블락 드바이스 정보를 확인 할 수 있습니다.

기본 사용법

$> lsblk
NAME                MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop1                 7:1    0    97M  1 loop /snap/core/9665
loop8                 7:8    0  96.6M  1 loop /snap/core/9804
loop6                 7:6    0  55.3M  1 loop /snap/core18/1885
loop4                 7:4    0  50.4M  1 loop /snap/bpftrace/63
loop2                 7:2    0   9.8M  1 loop /snap/helm/265
loop0                 7:0    0    55M  1 loop /snap/core18/1880
loop7                 7:7    0  26.1M  1 loop /snap/taskbook/23
sda                   8:0    0 238.5G  0 disk 
├─sda2                8:2    0     1K  0 part 
├─sda5                8:5    0   238G  0 part 
│ ├─mint--vg-swap_1 253:1    0  15.9G  0 lvm  [SWAP]
│ └─mint--vg-root   253:0    0 222.1G  0 lvm  /
└─sda1                8:1    0   487M  0 part /boot
loop5                 7:5    0  39.3M  1 loop /snap/bcc/125
loop3                 7:3    0  14.9M  1 loop /snap/skaffold/1
loop10                7:10   0   9.8M  1 loop /snap/helm/272

TLDR

$> tldr lsblk

  lsblk

  Lists information about devices.

  - List all storage devices in a tree-like format:
    lsblk

  - Also list empty devices:
    lsblk -a

  - Print the SIZE column in bytes rather than in a human-readable format:
    lsblk -b

  - Output info about filesystems:
    lsblk -f

  - Use ASCII characters for tree formatting:
    lsblk -i

  - Output info about block-device topology:
    lsblk -t

  - Exclude the devices specified by the comma-separated list of major device numbers:
    lsblk -e 1,7

Help

$> lsblk --help

Usage:
 lsblk [options] [<device> ...]

List information about block devices.

Options:
 -a, --all            print all devices
 -b, --bytes          print SIZE in bytes rather than in human readable format
 -d, --nodeps         don't print slaves or holders
 -D, --discard        print discard capabilities
 -e, --exclude <list> exclude devices by major number (default: RAM disks)
 -f, --fs             output info about filesystems
 -i, --ascii          use ascii characters only
 -I, --include <list> show only devices with specified major numbers
 -J, --json           use JSON output format
 -l, --list           use list format output
 -m, --perms          output info about permissions
 -n, --noheadings     don't print headings
 -o, --output <list>  output columns
 -O, --output-all     output all columns
 -p, --paths          print complete device path
 -P, --pairs          use key="value" output format
 -r, --raw            use raw output format
 -s, --inverse        inverse dependencies
 -S, --scsi           output info about SCSI devices
 -t, --topology       output info about topology
 -x, --sort <column>  sort output by <column>

 -h, --help     display this help and exit
 -V, --version  output version information and exit

Available columns (for --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
    PARTTYPE  partition type UUID
   PARTLABEL  partition LABEL
    PARTUUID  partition UUID
   PARTFLAGS  partition flags
          RA  read-ahead of the device
          RO  read-only device
          RM  removable device
     HOTPLUG  removable or hotplug device (usb, pcmcia, ...)
       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
        TRAN  device transport type
  SUBSYSTEMS  de-duplicated chain of subsystems
         REV  device revision
      VENDOR  device vendor

For more details see lsblk(8).