나는 보았다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