Fedora Linux Support Community & Resources Center
  #1  
Old 25th May 2012, 06:17 AM
sluge Offline
Registered User
 
Join Date: Jun 2009
Location: Russia,52
Posts: 93
windows_7ie
Question how to determine USB drive?

Hello!
Is any way to 100% determine that some of sda, sdb, sdc, etc is a USB key, USB hard drive, memory card's reader or other USB device using shell commands?
Reply With Quote
  #2  
Old 25th May 2012, 06:23 AM
hadrons123 Offline
'The Blue Dragon'
 
Join Date: Jan 2011
Location: Pitt,PA
Posts: 1,260
linuxfirefox
Re: how to determine USB drive?

dmesg output shall give an idea.
__________________
LENOVO Y580 FHD Intel® Core™ i7-3630QM CPU @ 2.40GHz × 8 |660M GTX NVIDIA | 16 GB SSD
Reply With Quote
  #3  
Old 25th May 2012, 09:47 AM
satanselbow Offline
Registered User
 
Join Date: Apr 2011
Location: Upminster, Essex, UK
Posts: 169
linuxchrome
Wink Re: how to determine USB drive?

Give all your filesystems / USB sticks labels and you won't lose track of what is what

Code:
sudo blkid
would also spew some useful info in addition to the dmesg command above
Reply With Quote
  #4  
Old 25th May 2012, 10:33 AM
pjfg
Guest
 
Posts: n/a
linuxopera
Re: how to determine USB drive?

lsscsi gives nice readable output:

$ lsscsi
[0:0:0:0] disk ATA Hitachi HDP72505 GM4O /dev/sda
[1:0:0:0] cd/dvd Optiarc DVD RW AD-7241S 1.03 /dev/sr0
[2:0:0:0] disk ATA Hitachi HDP72505 GM4O /dev/sdb
[3:0:0:0] disk ATA OCZ-AGILITY3 2.15 /dev/sdc
[8:0:0:0] disk Generic USB SD Reader 1.00 /dev/sdd
[8:0:0:1] disk Generic USB CF Reader 1.01 /dev/sde
[8:0:0:2] disk Generic USB SM Reader 1.02 /dev/sdf
[8:0:0:3] disk Generic USB MS Reader 1.03 /dev/sdg

It is even more clear which bus the storage device is on if you you the -v flag.

If you don't already have just install with "yum install lsscsi"
Reply With Quote
  #5  
Old 25th May 2012, 12:58 PM
DBelton Offline
Administrator
 
Join Date: Aug 2009
Posts: 7,320
linuxfirefox
Re: how to determine USB drive?

actually, if you use lsscsi, the regular output (as shown above) doesn't tell you is it is usb or not. What you see is what happens to be pulled from the drive itself in the 2 fields.

Code:
[root@tower20 ~]# lsscsi
[2:0:0:0]    disk    ATA      ST3500630AS      3.AA  /dev/sda 
[2:0:1:0]    disk    ATA      WDC WD2001FASS-0 05.0  /dev/sdb 
[3:0:0:0]    cd/dvd  TSSTcorp CDW/DVD TS-H493A CD07  /dev/sr0 
[4:0:0:0]    disk    Seagate  BlackArmorDAS35  412D  /dev/sdc 
[5:0:0:0]    disk    PNY      USB 2.0 FD       8192  /dev/sdd
But, if you use lsscsi --transport (or lsscsi -t) then it will tell you if it is USB and even what USB bus and port it is on.

Code:
[root@tower20 ~]# lsscsi -t
[2:0:0:0]    disk    ata:                            /dev/sda 
[2:0:1:0]    disk    ata:                            /dev/sdb 
[3:0:0:0]    cd/dvd  ata:                            /dev/sr0 
[4:0:0:0]    disk    usb: 1-4:1.0                    /dev/sdc 
[5:0:0:0]    disk    usb: 1-6:1.0                    /dev/sdd
You could read that in and test that third field to see if it is equal to usb
Reply With Quote
  #6  
Old 25th May 2012, 01:38 PM
pjfg
Guest
 
Posts: n/a
linuxopera
Re: how to determine USB drive?

Quote:
Originally Posted by DBelton View Post
actually, if you use lsscsi, the regular output (as shown above) doesn't tell you is it is usb or not. What you see is what happens to be pulled from the drive itself in the 2 fields.

Code:
[root@tower20 ~]# lsscsi
[2:0:0:0]    disk    ATA      ST3500630AS      3.AA  /dev/sda 
[2:0:1:0]    disk    ATA      WDC WD2001FASS-0 05.0  /dev/sdb 
[3:0:0:0]    cd/dvd  TSSTcorp CDW/DVD TS-H493A CD07  /dev/sr0 
[4:0:0:0]    disk    Seagate  BlackArmorDAS35  412D  /dev/sdc 
[5:0:0:0]    disk    PNY      USB 2.0 FD       8192  /dev/sdd
But, if you use lsscsi --transport (or lsscsi -t) then it will tell you if it is USB and even what USB bus and port it is on.

Code:
[root@tower20 ~]# lsscsi -t
[2:0:0:0]    disk    ata:                            /dev/sda 
[2:0:1:0]    disk    ata:                            /dev/sdb 
[3:0:0:0]    cd/dvd  ata:                            /dev/sr0 
[4:0:0:0]    disk    usb: 1-4:1.0                    /dev/sdc 
[5:0:0:0]    disk    usb: 1-6:1.0                    /dev/sdd
You could read that in and test that third field to see if it is equal to usb
Or use the -v flag like I said. It outputs the bus to which the device is attached from /sys
Reply With Quote
  #7  
Old 25th May 2012, 03:00 PM
sea Offline
"Shells" (of a sub world)
 
Join Date: May 2011
Location: Confoederatio Helvetica (Swissh)
Age: 34
Posts: 3,483
linuxchrome
Re: how to determine USB drive?

Another nice command is: lsblk
Code:
[simon@l670 ~]$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 298,1G  0 disk 
├─sda1   8:1    0   400M  0 part 
├─sda2   8:2    0  99,7G  0 part 
├─sda3   8:3    0   125G  0 part /home
├─sda4   8:4    0     1K  0 part 
├─sda5   8:5    0  31,4G  0 part /
├─sda6   8:6    0   768M  0 part [SWAP]
└─sda7   8:7    0  15,9G  0 part 
sr0     11:0    1  1024M  0 rom
__________________
Laptop: Toshiba satellite p50-a-11 CPU: Intel i7 8*2400 MHz GPU: GeForce GT 745M RAM: 8192 MB Distro: Fedora (Rawhide) DE: Awesome
Text User Interface (TUI) // Windows 8+ & Fedora 20+ Dualboot
Reply With Quote
Reply

Tags
determine, drive, usb

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you determine what's in your path royeo Using Fedora 2 8th June 2007 11:24 AM
how to determine PCI ID of ndiswrapper?? wahaha Servers & Networking 0 9th March 2007 08:46 PM
How can I determine my architecture? atrain_old Installation, Upgrades and Live Media 2 1st March 2007 03:30 AM
How to determine whether it is FC3 or FC2? Fedora_Linux EOL (End Of Life) Versions 12 8th June 2005 10:31 PM


Current GMT-time: 21:42 (Wednesday, 22-10-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Aleksandrovskoye Photos - Tulangan Utara Instagram Photos - Montigny-les-Metz Travel Photos