You are not logged in.
Pages: 1
Hey guys, when I plug in a usb stick, what's the best/most direct way to find out where it is? lsusb? dmesg? If it's mounted I can just use "mount."
I'd like to look somewhere or run something to get something like
"this-stick" "/dev/sdb5"
what do you think?
Offline
in dmesg, when you plug the USB device, it should show something like this:
...
sd 2:0:0:0: [sdc] Assuming drive cache: write through
sdc: sdc1
...
(emphasis mine).
with some scripting you could parse it and format it to your wishes.
Offline
You can run "ls /dev/disk/by-uuid" before plugging in the device and then again after it loads. The second time you run it you'll see a new file, which will be a symlink that points to the device's location.
Offline
dsr: noes, what if the OP plugs in two devices at once? What if a previously registered device hangs and then suddenly decides to mount at that moment?! ![]()
-dav7
Last edited by dav7 (2008-09-20 07:27:21)
Windows was made for looking at success from a distance through a wall of oversimplicity. Linux removes the wall, so you can just walk up to success and make it your own.
--
Reinventing the wheel is fun. You get to redefine pi.
Offline
'fdisk -l' (requires root) or 'cat /etc/blkid.tab'
Last edited by byte (2008-09-20 08:42:28)
I hate sigs. This one only exists to remind myself to get an avatar.
Offline
udev?
Offline
plug it in, dmesg | tail -n 10
Edit: Or perhaps better, make a udev rule that tells you what it's named, or that always gives it the same name.
Last edited by Mr.Elendig (2008-09-20 11:28:36)
Evil #archlinux@freenode channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
Some of the other methods mentioned in this thread might be better than my "ls /dev/disk/by-uuid" method (it works fine though). "dmesg | tail" works. So does "more /proc/partitions" (same thing as "fdisk -l" but without requiring root privileges). So does writing a udev rule, etc.
Offline
Some of the other methods mentioned in this thread might be better than my "ls /dev/disk/by-uuid" method (it works fine though). "dmesg | tail" works. So does "more /proc/partitions" (same thing as "fdisk -l" but without requiring root privileges). So does writing a udev rule, etc.
funny you should say that, because your method is my favorite. All I'm doing with it is writing a wrapper for pmount (just for fun). I'm actually using the output of a w3m directory listing because it shows symlinks. Ugly? yes. Working? Mostly. The way I have it now, if I plug in two usb devices, my wrapper mounts them both. If I plug in one and mount it, then another, and I mount it, the first one unmounts. each time I "flip the switch" the mounted state flip-flops. So I guess I'll just use one usb device at a time.
Thanks for the info everybody.
I don't suppose anyone knows how I can tell my wrapper to ignore swap partions?
Offline
I'm glad it works for you. To determine the type of a partition (e.g. linux-swap), you could do something like
# parted -l | tail -n+`expr 6 + "$1"` | head -n1 | awk '{print $6}'where $1 is the partition number (the X in /dev/sdaX). Of course you would need to install parted. I'm sure there's a cleaner solution, though.
Last edited by dsr (2008-09-21 18:01:08)
Offline
Pages: 1