On May 19, 2006, at 5:13 AM, Paul Knight wrote: > On May 19, 2006, at 12:43 AM, Alex Young wrote: > >> Dave Burt wrote: >> >> On unices, I think this does the trick: >> >> $ df -h `mount | grep '^/dev' | cut -f 3 -d ' '` >> >> Works on Linux and OS X, certainly - I don't have any other BSDs >> to check. > > It should work on most modern *nix systems, but `df -h` isn't > available on Solaris 8 and older. Incidentally, this was one of my > favorite changes in Solaris 9. (Sorry for resurrecting an old thread.) I found a solution that, based on my testing on both OSX and linux, appears to work pretty well for UNIX. I'd like to hear if this works on Solaris and FreeBSD/NetBSD/OpenBSD. def self.list_devices(path = nil) # call out to the underlying OS and figure out all the devices on the system df_output = `df -l -P #{path}` df_vals = df_output.split(/\n/) devices = [] df_vals.each do |val| next unless val =~ /(.+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(.+)\s+(.+)/ device, total, used, avail, percentage, mount_point = $1, $2, $3, $4, $5, $6 devices.push({ :device => device, :total => total, :used => used, :avail => avail, :percentage => percentage, :mount_point => mount_point }) end devices end