You are not logged in.

#1 2015-02-11 23:45:11

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 290
Website

Detect whether device is disk or sdcard

Is there a way, given some /dev/sdX, to tell whether the device refers to a "real" disk or something as brittle as a USB flash memory stick / sd card / that kind of thing?

I found /sys/dev/block/*/removable, which apparently is a boolean describing whether the device is removable, which is close, but it still wouldn't allow me to tell whether it is a USB disk drive, for example, or an SD Card.

Offline

#2 2015-02-11 23:47:02

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Detect whether device is disk or sdcard


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2015-02-12 00:47:51

jernst
Member
From: Silicon Valley
Registered: 2014-03-04
Posts: 290
Website

Re: Detect whether device is disk or sdcard

Thanks jasonwryan: maybe that's the best we can do. The look-for-usb-in-path trick is cute, but I still can't tell usb hard drive from sd card.

Offline

#4 2015-02-12 01:45:48

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: Detect whether device is disk or sdcard

Udev info is certainly your best bet. If that's not possible, maybe the SCSI subsystem* has enough info to uniquely identify the device.

* See the contents of /proc/scsi/scsi for an idea of the info it makes available.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

Board footer

Powered by FluxBB