Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was playing around with a USB stick (booting archlinux with qemu off of it and trying to perform an installation on the same stick at the same time -- brave, I know, but I was just messing around).

Now, after failing to boot and install at the same time, it seems I have sort of messed up my stick. What I think happened is that I used cfdisk to wipe everything on it and create one big partition, but formatting it then failed, so now there's a big partition with no filesystem.

Just to make it clear: I'm not worried for my stick, I know I can recover it at any point.

What I find intriguing is that after plugging the stick into my computer (using Ubuntu), there's no (terminal) way to find out what block device (/dev/sdx) it has associated. The only way I could determine that was with GParted:

GParted showing /dev/sdc

But blkid shows the following:

/dev/sda1: UUID="12F695CFF695B387" LABEL="System Reserved" TYPE="ntfs" 
/dev/sda2: UUID="A0BAA6EABAA6BC62" TYPE="ntfs" 
/dev/sdb1: UUID="546aec8b-9ad6-4571-b07a-adba63e25820" TYPE="ext4" 
/dev/sdb2: UUID="2a8b82d8-6c6e-4053-a446-bab970d93d7c" TYPE="swap" 
/dev/sdb3: UUID="7cbede7d-c930-4e59-9d1b-01f2d79bd092" TYPE="ext4"

No trace of /dev/sdc. My question is: if I didn't have a graphical interface (to use GParted), how would I have known which block device is my stick?

share|improve this question
up vote 4 down vote accepted

There are several methods to discover a device node.

  • Examine kernel output with the dmesg command.
  • Try fdisk -l. (This should spit out partition tables for all attached drives.)
  • Examine the output of lshw -short (ls hardware), or use similar commands like lspci or lsusb, depending on what you know about the device you seek. If lshw isn't available on your system, install the lshw package to get it.
  • Examine the sys filesystem manually. (For example, use ls /sys/block/ or ls -d /sys/block/s* and look for unfamiliar device names.)
  • Examine the /dev directory manually. (For example, use ls /dev/sd* and look for unfamiliar device names.)

As I understand it, blkid only looks at partitions, not raw drive devices. (This is probably an oversimplication.) The lshw command and similar are better for obtaining direct hardware information.

share|improve this answer
You can also use testdisk to recreate partition table pointing to filesystems found by testdisk. – Vi. Apr 4 '10 at 17:16
I knew about most of these but didn't know I could use them in this way. Thanks. – Felix Apr 4 '10 at 19:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .