Help us understand the problem. What is going on with this article?

lsblk コマンドが便利

More than 1 year has passed since last update.

はじめに

お恥ずかしいながら、今までこのコマンドを知りませんでした。 :scream:
ただ単に、サーバで使っているディスクのデバイス名リストが欲しかっただけなのですが、df コマンドとかだとパーティションの名前になってしまい、余計な数字が末尾についてくるので困っていました。 :sweat_drops:

そこで、lsblk コマンドの登場です! :sunglasses:

lsblk コマンドについて

このコマンドは、単純に実行するだけでこんな情報がとれます。 :confetti_ball:

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0  21.9T  0 disk
├─sda1   8:1    0 488.3M  0 part /boot
├─sda2   8:2    0  11.5G  0 part [SWAP]
└─sda3   8:3    0  21.8T  0 part /

オプションもイロイロ有りますので、ウマく活用すると出力内容を変えることも可能です。たとえは取得できる情報にはこんなのがあります。 :pencil:

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
          RA  read-ahead of the device
          RO  read-only device
          RM  removable device
       MODEL  device identifier
        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

ワクワクしてきましたね。 :smile:

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away