Linux のDisk 確認方法

Linux マシンにSD Card や USB メモリ等を複数接続した時などにどれがどのデバイスかわからなくなった時などに役立ちそうな確認方法です。
(/dev/sda… とか /dev/mmcblk0… とか)

dmesg

よく dmesg を確認します。

% dmesg
  :
[378481.925145] usb 4-1.2: new high-speed USB device number 7 using ehci-pci
[378482.022988] usb 4-1.2: New USB device found, idVendor=056e, idProduct=6009
[378482.022991] usb 4-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[378482.022993] usb 4-1.2: Product: MF-HDU2
[378482.022994] usb 4-1.2: Manufacturer: ELECOM
[378482.022995] usb 4-1.2: SerialNumber: 0708C20C90C7B761
[378482.023271] usb-storage 4-1.2:1.0: USB Mass Storage device detected
[378482.023343] scsi9 : usb-storage 4-1.2:1.0
[378483.083291] scsi 9:0:0:0: Direct-Access     ELECOM   MF-HDU2          PMAP PQ: 0 ANSI: 4
[378483.083655] sd 9:0:0:0: Attached scsi generic sg2 type 0
[378484.049829] sd 9:0:0:0: [sdc] 62554112 512-byte logical blocks: (32.0 GB/29.8 GiB)
[378484.052425] sd 9:0:0:0: [sdc] Write Protect is off
[378484.052427] sd 9:0:0:0: [sdc] Mode Sense: 23 00 00 00
[378484.055034] sd 9:0:0:0: [sdc] No Caching mode page found
[378484.055037] sd 9:0:0:0: [sdc] Assuming drive cache: write through
[378484.064057] sd 9:0:0:0: [sdc] No Caching mode page found
[378484.064060] sd 9:0:0:0: [sdc] Assuming drive cache: write through
[378484.096077]  sdc: sdc1
[378484.103442] sd 9:0:0:0: [sdc] No Caching mode page found
[378484.103449] sd 9:0:0:0: [sdc] Assuming drive cache: write through
[378484.103454] sd 9:0:0:0: [sdc] Attached SCSI removable disk

ELECOM MF-HDU2 が /dev/sdc として認識しています。
しかし、これだと画面から流れたりどのデバイスを先に刺したかが判らなくなるといったんumount して接続しなおしをしないといけません。

/dev/disk/by-id

こんなとき /dev/disk/by-id を見ると判るかもしれません。※udev 依存

% ls -lA /dev/disk/by-id
合計 0
lrwxrwxrwx 1 root root  9  2月 23 02:42 ata-INTEL_SSDSA2CW600G3_CVPR1206005W600FGN -> ../../sda
lrwxrwxrwx 1 root root 10  2月 23 02:42 ata-INTEL_SSDSA2CW600G3_CVPR1206005W600FGN-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10  2月 23 02:42 ata-INTEL_SSDSA2CW600G3_CVPR1206005W600FGN-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10  2月 23 02:42 ata-INTEL_SSDSA2CW600G3_CVPR1206005W600FGN-part5 -> ../../sda5
lrwxrwxrwx 1 root root  9  2月 26 03:53 ata-ST9500420ASG_5VJ79GDX -> ../../sdb
lrwxrwxrwx 1 root root 10  2月 23 05:05 dm-name-luks-3baf2c17-3b18-44ee-9547-cb87b88a80ab -> ../../dm-3
lrwxrwxrwx 1 root root 10  2月 23 02:42 dm-name-sdb5_crypt -> ../../dm-0
lrwxrwxrwx 1 root root 10  2月 23 02:42 dm-name-x220-root -> ../../dm-1
lrwxrwxrwx 1 root root 10  2月 23 02:42 dm-name-x220-swap_1 -> ../../dm-2
lrwxrwxrwx 1 root root 10  2月 23 02:42 dm-uuid-CRYPT-LUKS1-1b4bc14d71604ab5b3db2096a7f61be0-sdb5_crypt -> ../../dm-0
lrwxrwxrwx 1 root root 10  2月 23 05:05 dm-uuid-CRYPT-LUKS1-3baf2c173b1844ee9547cb87b88a80ab-luks-3baf2c17-3b18-44ee-9547-cb87b88a80ab -> ../../dm-3
lrwxrwxrwx 1 root root 10  2月 23 02:42 dm-uuid-LVM-L9AiiS7dZRu2WvjdUirxz9fS4OIIqRpKmuJecuwuh7tfiQxUbaGcvv9ppr7WhxZP -> ../../dm-2
lrwxrwxrwx 1 root root 10  2月 23 02:42 dm-uuid-LVM-L9AiiS7dZRu2WvjdUirxz9fS4OIIqRpKxnaP2Gj6PtwuddX1iXfyTQq0hxGbi6o3 -> ../../dm-1
lrwxrwxrwx 1 root root 13  2月 26 05:07 memstick-SD16G_0xd39a5655 -> ../../mmcblk0
lrwxrwxrwx 1 root root 15  2月 26 05:07 memstick-SD16G_0xd39a5655-part1 -> ../../mmcblk0p1
lrwxrwxrwx 1 root root  9  2月 23 02:42 scsi-SATA_INTEL_SSDSA2CW60CVPR1206005W600FGN -> ../../sda
lrwxrwxrwx 1 root root 10  2月 23 02:42 scsi-SATA_INTEL_SSDSA2CW60CVPR1206005W600FGN-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10  2月 23 02:42 scsi-SATA_INTEL_SSDSA2CW60CVPR1206005W600FGN-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10  2月 23 02:42 scsi-SATA_INTEL_SSDSA2CW60CVPR1206005W600FGN-part5 -> ../../sda5
lrwxrwxrwx 1 root root  9  2月 26 03:53 scsi-SST9500420ASG_FEDCBA9876543210 -> ../../sdb
lrwxrwxrwx 1 root root  9  2月 27 20:52 usb-ELECOM_MF-HDU2_0708C20C90C7B761-0:0 -> ../../sdc
lrwxrwxrwx 1 root root 10  2月 27 20:52 usb-ELECOM_MF-HDU2_0708C20C90C7B761-0:0-part1 -> ../../sdc1
lrwxrwxrwx 1 root root  9  2月 26 03:53 wwn-0x5000c5002998a599 -> ../../sdb
lrwxrwxrwx 1 root root  9  2月 23 02:42 wwn-0x500151795957940c -> ../../sda
lrwxrwxrwx 1 root root 10  2月 23 02:42 wwn-0x500151795957940c-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10  2月 23 02:42 wwn-0x500151795957940c-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10  2月 23 02:42 wwn-0x500151795957940c-part5 -> ../../sda5

USB 接続のデバイスだけなら以下のようにするとすっきりしますね。

% ls -l /dev/disk/by-id/usb*
lrwxrwxrwx 1 root root  9  2月 27 20:52 /dev/disk/by-id/usb-ELECOM_MF-HDU2_0708C20C90C7B761-0:0 -> ../../sdc
lrwxrwxrwx 1 root root 10  2月 27 20:52 /dev/disk/by-id/usb-ELECOM_MF-HDU2_0708C20C90C7B761-0:0-part1 -> ../../sdc1

/dev/disk の下には他にも by-label by-path by-uuid があるようです。何かの役に立つかもしれません。

  • by-label ボリュームラベルのデバイス
  • by-path デバイス名(<パスID>-:-<パーティション>)
  • by-uuid デバイスのuuid 表示

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)