Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I determine which /dev/sdX device my usb stick is plugged into?

I am running Ubuntu 9.04.

share|improve this question
add comment

4 Answers 4

up vote 10 down vote accepted

You may want to use /dev/disk/by-id or /dev/disk/by-uuid/ instead. These never change for a given device, whatever /dev/sdXX your pluggable drives have.

share|improve this answer
Personally, I prefer to set a label on all my filesystems so I can use /dev/disk/by-label/lnxflash –  Zoredache Oct 23 '09 at 16:39
I also just stumbled on "fdisk -l" which seems to work too. –  jldupont Oct 23 '09 at 20:24
add comment

Execute sudo blkid : it will show block device names:

/dev/sdc1: UUID="004A31DB4A31CDE2" LABEL="WinGamer" TYPE="ntfs"
/dev/sdd1: LABEL="0DAY" UUID="9b14c03b-7251-434f-bbb9-eac42b2db927" TYPE="ext2"
/dev/sdg5: LABEL="QFAT" UUID="4257-E346" TYPE="vfat"
/dev/sdg6: LABEL="BACKUP-HDD" UUID="fee45c66-11bd-49fa-a62a-4a541716e8e1" TYPE="ext2"
share|improve this answer
add comment

on a command line, do a ls /media and you will usually see it.

e.g. on my system:

$ ls /media
cdrom  cdrom0  cdrom1  floppy  floppy0  LaCie

LaCie is my usb stick

failing that try

$ lsusb

on my system

$ lsusb
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 059f:1028 LaCie, Ltd 

If it shows up there but not in /media, you will need to figure out mounting, or ask another question..

Finally, I can type "mount" and look through the output for your answer, or in my case:

$ mount | grep LaCie
/dev/sdb on /media/LaCie type vfat (rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush)
share|improve this answer
add comment

It will depend. Type dmesg at the console and the output should show the USB stick being mounted.

Here is some example output:

[ 2699.328853] Initializing USB Mass Storage driver...
[ 2699.339045] scsi4 : SCSI emulation for USB Mass Storage devices
[ 2699.345916] usbcore: registered new interface driver usb-storage
[ 2699.345922] USB Mass Storage support registered.
[ 2699.350764] usb-storage: device found at 3
[ 2699.350767] usb-storage: waiting for device to settle before scanning
[ 2704.353322] usb-storage: device scan complete
[ 2704.354353] scsi 4:0:0:0: Direct-Access     USB      DISK 2.0         0403 PQ: 0 ANSI: 0 CCS
[ 2704.374592] sd 4:0:0:0: [sdb] 3981312 512-byte hardware sectors: (2.03 GB/1.89 GiB)
[ 2704.415233] sd 4:0:0:0: [sdb] Write Protect is off
[ 2704.415239] sd 4:0:0:0: [sdb] Mode Sense: 43 00 00 00
[ 2704.415242] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[ 2704.418087] sd 4:0:0:0: [sdb] 3981312 512-byte hardware sectors: (2.03 GB/1.89 GiB)
[ 2704.419100] sd 4:0:0:0: [sdb] Write Protect is off
[ 2704.419105] sd 4:0:0:0: [sdb] Mode Sense: 43 00 00 00
[ 2704.419107] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[ 2704.419114]  sdb: sdb1
[ 2704.421024] sd 4:0:0:0: [sdb] Attached SCSI removable disk
[ 2704.421093] sd 4:0:0:0: Attached scsi generic sg2 type 0

In my case its the sdb device that is assigned after I plug in a USB stick, since I have just the one internal hard drive in my laptop (sda).

share|improve this answer
Thanks! I saw the dmesg message "sdc: sdc1" which I hope is the correct path ;-) –  jldupont Oct 23 '09 at 16:12
This works, but is the ghetto way to do it. The other answers are better, IMO –  Kamil Kisiel Oct 23 '09 at 17:09
@Kamil - Your right, this IS the ghetto way to do it but its also the easiest/simplest, especially for a newcomer. If you need to script up a solution then several of the other answers would do nicely, I would imagine :-) –  faultyserver Oct 23 '09 at 21:19
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.