LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Newbie
User Name
Password
Linux - Newbie This forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Thread Tools
Old 07-04-2009, 08:32 PM   #1
EmrldDrgn
Member
 
Registered: Oct 2008
Posts: 35
Thanked: 2
Test /dev/sd*, /dev/hd* for type


[Log in to get rid of this advertisement]
Is there a way to test, say, /dev/sda to see if it's a hard drive or a CD-ROM or a USB stick? Maybe get some more details about it (anything would be nice)?
EmrldDrgn is offline     Reply With Quote
Old 07-04-2009, 09:08 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 16,660
Blog Entries: 30
Thanked: 273
If /dev/sda is an USB stick then 'fdisk', 'sfdisk' or 'disktype' will work, however if it's an empty CDROM drive they won't. There's other ways like looking in /sys. Try grepping info from 'udevinfo -q all -e'?
unSpawn is online now     Reply With Quote
Thanked by:
Old 07-05-2009, 03:09 PM   #3
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,434
Thanked: 24
If you have hald running, you can also use its API to get this information. For example:
Code:
hal-get-property --udi $(hal-find-by-property --key block.device --string '/dev/sda') --key storage.drive_type
hal-get-property --udi $(hal-find-by-property --key block.device --string '/dev/sda') --key storage.bus
osor is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pseudo terminals: /dev/ptmx <-> /dev/pts/ vs. /dev/ptyp <-> /dev/ttyp rtspitz Linux - Software 0 05-17-2009 04:44 AM
OpenSUSE x86_64 does not mount /dev/tape (or /dev/st0 or /dev/nst0) yankeeinga Linux - Newbie 6 08-21-2008 01:51 PM
using flash drive changes device /dev/sr0 to /dev/sr1 for mapping to /dev/pktcdvd/0? lugoteehalt Linux - Software 3 10-24-2007 11:27 AM
/dev/audio, /dev/dsp and /dev/mixer missing in Debian Etch 1337_penguin Debian 2 04-11-2007 12:33 PM
I cannot access EITHER CD drive! And there's no /dev/hdc or /dev/hdd or /dev/cdrom! Dmalic Linux - Hardware 13 11-18-2005 08:11 PM


All times are GMT -5. The time now is 05:12 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration