Find all storage devices attached to a Linux machine

bash, linux, shell

Solution

`/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.

Problem

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?

Original source