Linux: how do I find the devce name of my USB drive?

Around the time I reviewed Chromium OS, I managed to totally b0rk one of my thumb drives. I somehow botched the dd command, and the device became unusable. When I plugged it in, nothing would happen. Or rather nothing on the UI side. My KDE would simply ignore the drive and pretend it was not there. I didn’t want to just throw out the USB stick, so I decided to figure out what device name gets assigned to it, and then repartition it again.

How do you do that? The simplest method is to watch the log files. When you plug in a USB the device, your system should make a note of it in /var/log/messages. So you should do the following:

tail -f /var/log/messages

In case you didn’t know, the tail command prints out the last few lines of a text file, and the -f argument basically means “follow”. So tail will basically pring any new lines that are appended into the console in real time. Once you issue this command, just plug in your device. Your output should look something like this:

Dec  1 12:56:44 malekith kernel: [13631.153753] usb 2-1: new high speed USB device using ehci_hcd and address 4
Dec  1 12:56:44 malekith kernel: [13631.288125] usb 2-1: configuration #1 chosen from 1 choice
Dec  1 12:56:44 malekith kernel: [13631.288669] scsi5 : SCSI emulation for USB Mass Storage devices
Dec  1 12:56:49 malekith kernel: [13636.295004] scsi 5:0:0:0: Direct-Access     Kingston DT 101 II        1.00 PQ: 0 ANSI: 2
Dec  1 12:56:49 malekith kernel: [13636.295900] sd 5:0:0:0: Attached scsi generic sg3 type 0
Dec  1 12:56:49 malekith kernel: [13636.306962] sd 5:0:0:0: [sdc] 7831552 512-byte logical blocks: (4.00 GB/3.73 GiB)
Dec  1 12:56:49 malekith kernel: [13636.308590] sd 5:0:0:0: [sdc] Write Protect is off
Dec  1 12:56:51 malekith kernel: [13636.315523]  sdc: sdc1
Dec  1 12:56:51 malekith kernel: [13637.905840] sd 5:0:0:0: [sdc] Attached SCSI removable disk

Check out the second to last line – it says sdc1. What does that mean? That means that my b0rken thumb drive is assigned to the /dev/sdc1 device. Now that I know that I can easily run fdsk on the device to format it and rebuild the partition table that was messed up by a botched dd command.

It’s that easy. I’m putting it here for future reference more than anything else.

This entry was posted in Uncategorized. Bookmark the permalink.



One Response to Linux: how do I find the devce name of my USB drive?

  1. BigBert NEW ZEALAND Mozilla Firefox Linux says:

    Do:

    sudo fdisk -l

    will show you all devices. Then plug in your stick and repeat above.

    Reply  |  Quote

Leave a Reply

Your email address will not be published. Required fields are marked *