Larry Ewing's Penguin Two Penguins Larry Ewing's Penguin

How to find the /dev node your USB flash drive is on

When you are told to use dd to write an image onto your USB flash drive, you generally want to be sure you have the _right_ device, and don't accidentally burn a 1MB image over the top of the first 1MB of your 1TB of baby videos, for instance. That would be _bad_.

Approach One Check dmesg output

If you just now plugged in the USB flash drive, you should be able to look at recent dmesg output and find the device.

$ dmesg | tail -20

You should see some lines like this:

usb 2-6: New USB device found, idVendor=0718, idProduct=0077
scsi 30:0:0:0: Direct-Access     Imation  USB Flash Drive  0.00 PQ: 0 ANSI: 2
sd 30:0:0:0: [sdb] 7897088 512-byte hardware sectors (4043 MB)
See the [sdb] above, that means this device appeared as /dev/sdb.

Approach Two Check mount output

Your Linux box probably automounts the USB flash drive after you plug it in. So you can run the mount command:

$ mount

and look for a line like this:

/dev/sdc1 on /media/disk type vfat (rw,nosuid,nodev,uhelper=hal,shortname=lower,uid=500)
If you know the /media/disk is your flash drive, and you see /dev/sdc1 or /dev/sdc on that line, for example, then you know your flash drive is /dev/sdc.

Approach Three Watch the /dev node come online

The very best way is to start without the drive plugged in, look at your devices, and then plug it in and look again, to see what changed.

USB devices come up as SCSI devices on Linux (/dev/sd?). So do this:

$ ls /dev/sd?

You probably see something like this:

/dev/sda     /dev/sdb     /dev/sdc

Now insert the USB flash drive, wait about 10 seconds, and run the command again until you see a change, like:

/dev/sda     /dev/sdb     /dev/sdc     /dev/sdd

Unless your kid sister is behind the computer playing with the printer cables you can be pretty secure in knowing that your flash drive is on /dev/sdd in this case. You can always double-check with the methods above.

Back to Linux Tips

Last modified: February 2, 2009, 2:31pm

Valid HTML 4.01!

solvency amendment