udisksctlにすべてのパーティションとブロックデバイスを一覧表示させる方法はありますか?

udisksctlにすべてのパーティションとブロックデバイスを一覧表示させる方法はありますか?

私は見たhttps://stackoverflow.com/questions/200960/find-all-storage-devices-attached-to-a-linux-machine#201091これはクールですが、udisksctlを使用して同様の効果を得ることができるかどうか疑問に思います。助けを借りて十分な指示を提供する必要があります。

[$] udisksctl help

Usage:
  udisksctl COMMAND

Commands:
  help            Shows this information
  info            Shows information about an object
  dump            Shows information about all objects
  status          Shows high-level status
  monitor         Monitor changes to objects
  mount           Mount a filesystem
  unmount         Unmount a filesystem
  unlock          Unlock an encrypted device
  lock            Lock an encrypted device
  loop-setup      Set-up a loop device
  loop-delete     Delete a loop device
  power-off       Safely power off a drive
  smart-simulate  Set SMART data for a drive

Use "udisksctl COMMAND --help" to get help on each command.

使用

[$] udisksctl status /dev/sd

すべてのハードドライブ、ペンドライブ/ SSDなどのリストを提供しますが、パーティションは提供しません。どんなアイデアがありますか?

ベストアンサー1

for disk in /dev/sd[a-z] /dev/sd[a-z][a-z]; do
  if test -b $disk; then
    echo; echo ------------------ Disk $disk ------------------
    udisksctl info -b $disk
    for partition in $disk[1-9] $disk[0-9][0-9]; do
      if test -b $partition; then
        echo; echo ------------------ Partition $partition ------------------
        udisksctl info -b $partition
      fi
    done
  fi
done

おすすめ記事