查找连接到Linux机器的所有存储设备[已关闭](Find all storage devices attached to a Linux machine [closed])
我需要找到附加到给定机器的所有可写存储设备, 无论它们是否被安装。
这样做的方法是尝试 /dev中与可写设备( hd* and sd* )对应的每个条目......
有没有更好的解决方案,还是应该坚持这个?
I have a need to find all of the writable storage devices attached to a given machine, whether or not they are mounted.
The dopey way to do this would be to try every entry in /dev that corresponds to a writable devices (hd* and sd*)......
Is there a better solution, or should I stick with this one?
最满意答案
/proc/partitions将列出系统识别的所有块设备和分区。 然后,您可以尝试使用file -s <device>来确定分区上存在哪种文件系统(如果有的话)。
/proc/partitions will list all the block devices and partitions that the system recognizes. You can then try using file -s <device> to determine what kind of filesystem is present on the partition, if any.
更多推荐
发布评论