Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lshw vs blockdev #5

Closed
barak opened this issue Oct 5, 2014 · 4 comments
Closed

lshw vs blockdev #5

barak opened this issue Oct 5, 2014 · 4 comments

Comments

@barak
Copy link

barak commented Oct 5, 2014

Thanks for writing this script, it is really quite useful.

One very minor suggestion. For Linux, the lshw utility is not always installed, and is also very slow. (The slowness is due to fetching all sorts of non-block-device-related info, which is then filtered out in this script by grep /dev.) The "approved" alternative would be blockdev, which (at least on Debian and derivatives thereof like Ubuntu) is in an essential package and therefore guaranteed present. It is also about 200x faster.

$ sudo time --format 'real %e' blockdev --report > /dev/null
real 0.01

$ sudo time --format 'real %e' lshw > /dev/null
real 1.83                 

You can get a list of all available block devices with blockdev --report and you can get the physical sector size of a single device with, e.g., blockdev --getpbsz /dev/sda.

@barak
Copy link
Author

barak commented Oct 5, 2014

PS, the natural language device model description can be snarfed directly,

$ cat /sys/block/sda/device/model 
SAMSUNG SSD PM81

@JElchison
Copy link
Owner

Hi @barak, thanks for your suggestion. I've implemented your recommended change. Please review/test #6. If it meets your approval, I'll close #5 and and merge #6.

n.b. blockdev is not available by default on OS X (nor is the /sys/ pseudo-file system).

@barak
Copy link
Author

barak commented Oct 7, 2014

Seems to work!

@JElchison
Copy link
Owner

Many thanks, @barak !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants