How do I figure out which /dev is a USB flash drive?











up vote
155
down vote

favorite
51












I want to mount a USB drive, two of them and I need two different mount points. Unfortunately, the Linux kernel underwent a name change and I can't figure out which /dev location is the right one. Is there a way to look through dmesg or /proc or somewhere else to find out which device node is a USB drive.



(I'm using ArchLinux if that helps any.../dev/sda is the first hard drive, /dev/sr0 is a dvd drive, etc.)



edit: The USB drive is connected to a USB hub. I looked through dmesg and it says the hub was connected and it scanned for the 3 devices connected to it. Still can't see where my USB drive is though.










share|improve this question















migrated from stackoverflow.com Nov 27 '11 at 10:56


This question came from our site for professional and enthusiast programmers.











  • 1




    Can't see it? Maybe wait for a bit. Or try another USB port. See what differences there is in 'lsusb'
    – Nick Devereaux
    Mar 10 '09 at 23:02










  • Might want to rephrase the question somewhat - not all usb devices are disks, after all.
    – Arafangion
    Mar 10 '09 at 23:23






  • 3




    The df command shows you where it was mounted
    – Will Sheppard
    Aug 28 '13 at 14:09

















up vote
155
down vote

favorite
51












I want to mount a USB drive, two of them and I need two different mount points. Unfortunately, the Linux kernel underwent a name change and I can't figure out which /dev location is the right one. Is there a way to look through dmesg or /proc or somewhere else to find out which device node is a USB drive.



(I'm using ArchLinux if that helps any.../dev/sda is the first hard drive, /dev/sr0 is a dvd drive, etc.)



edit: The USB drive is connected to a USB hub. I looked through dmesg and it says the hub was connected and it scanned for the 3 devices connected to it. Still can't see where my USB drive is though.










share|improve this question















migrated from stackoverflow.com Nov 27 '11 at 10:56


This question came from our site for professional and enthusiast programmers.











  • 1




    Can't see it? Maybe wait for a bit. Or try another USB port. See what differences there is in 'lsusb'
    – Nick Devereaux
    Mar 10 '09 at 23:02










  • Might want to rephrase the question somewhat - not all usb devices are disks, after all.
    – Arafangion
    Mar 10 '09 at 23:23






  • 3




    The df command shows you where it was mounted
    – Will Sheppard
    Aug 28 '13 at 14:09















up vote
155
down vote

favorite
51









up vote
155
down vote

favorite
51






51





I want to mount a USB drive, two of them and I need two different mount points. Unfortunately, the Linux kernel underwent a name change and I can't figure out which /dev location is the right one. Is there a way to look through dmesg or /proc or somewhere else to find out which device node is a USB drive.



(I'm using ArchLinux if that helps any.../dev/sda is the first hard drive, /dev/sr0 is a dvd drive, etc.)



edit: The USB drive is connected to a USB hub. I looked through dmesg and it says the hub was connected and it scanned for the 3 devices connected to it. Still can't see where my USB drive is though.










share|improve this question















I want to mount a USB drive, two of them and I need two different mount points. Unfortunately, the Linux kernel underwent a name change and I can't figure out which /dev location is the right one. Is there a way to look through dmesg or /proc or somewhere else to find out which device node is a USB drive.



(I'm using ArchLinux if that helps any.../dev/sda is the first hard drive, /dev/sr0 is a dvd drive, etc.)



edit: The USB drive is connected to a USB hub. I looked through dmesg and it says the hub was connected and it scanned for the 3 devices connected to it. Still can't see where my USB drive is though.







linux usb






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 24 '12 at 21:50









Kzqai

1,31931116




1,31931116










asked Sep 16 '08 at 3:51









Rudolf Olah

9082811




9082811




migrated from stackoverflow.com Nov 27 '11 at 10:56


This question came from our site for professional and enthusiast programmers.






migrated from stackoverflow.com Nov 27 '11 at 10:56


This question came from our site for professional and enthusiast programmers.










  • 1




    Can't see it? Maybe wait for a bit. Or try another USB port. See what differences there is in 'lsusb'
    – Nick Devereaux
    Mar 10 '09 at 23:02










  • Might want to rephrase the question somewhat - not all usb devices are disks, after all.
    – Arafangion
    Mar 10 '09 at 23:23






  • 3




    The df command shows you where it was mounted
    – Will Sheppard
    Aug 28 '13 at 14:09
















  • 1




    Can't see it? Maybe wait for a bit. Or try another USB port. See what differences there is in 'lsusb'
    – Nick Devereaux
    Mar 10 '09 at 23:02










  • Might want to rephrase the question somewhat - not all usb devices are disks, after all.
    – Arafangion
    Mar 10 '09 at 23:23






  • 3




    The df command shows you where it was mounted
    – Will Sheppard
    Aug 28 '13 at 14:09










1




1




Can't see it? Maybe wait for a bit. Or try another USB port. See what differences there is in 'lsusb'
– Nick Devereaux
Mar 10 '09 at 23:02




Can't see it? Maybe wait for a bit. Or try another USB port. See what differences there is in 'lsusb'
– Nick Devereaux
Mar 10 '09 at 23:02












Might want to rephrase the question somewhat - not all usb devices are disks, after all.
– Arafangion
Mar 10 '09 at 23:23




Might want to rephrase the question somewhat - not all usb devices are disks, after all.
– Arafangion
Mar 10 '09 at 23:23




3




3




The df command shows you where it was mounted
– Will Sheppard
Aug 28 '13 at 14:09






The df command shows you where it was mounted
– Will Sheppard
Aug 28 '13 at 14:09












13 Answers
13






active

oldest

votes

















up vote
77
down vote



accepted










Easiest way: Look at the output of dmesg after connecting the USB device. It should show you what /dev node was assigned to it.






share|improve this answer



















  • 2




    dmesg works great, but I have a case where dmesg does not show the /dev node: [421963.864281] usb 3-6: new high-speed USB device number 32 using xhci_hcd What does this mean? How can I mount this device? The device shows up on lsusb...
    – modulitos
    Apr 25 '16 at 5:58








  • 1




    Actually, I figured it out. There was a kernel update since my last reboot that was causing this problem. After a reboot, my usb mounts just fine. Hopefully this helps someone!
    – modulitos
    Apr 25 '16 at 6:39




















up vote
53
down vote













As long as you are running udev, you can do this easily by referencing /dev/disk/by-id/usb-manufacturername_serialnumber. These appear as symbolic links which you can either directly reference within your fstab, or which you can dereference using readlink -e to determine the associated block device.



Here's a real world example. On my machine, I have 3 USB hard drives connected. These each show up in /dev/disk/by-id with unique serial numbers (although they share a common manufacturer string). I have created symbolic links to each of these three unique entries, and can now quickly determine which drive is which (and which device is associated with each drive) by running readlink -e linkname. For example, running readlink -e /root/disk2 on my machine currently displays "/dev/sde", while readlink -e /root/disk3 produces no output whatsoever.






share|improve this answer

















  • 13




    Short and simply: for devlink in /dev/disk/by-id/usb*; do readlink -f ${devlink}; done
    – Felipe Alcacibar
    Nov 25 '15 at 14:02




















up vote
51
down vote













All of these are good suggestions, but the quickest and least verbose method is to just type the following in the terminal:



mount


which will give a list of all the mounted devices (this assumes the USB drive is mounted, which is usually the case with modern Linux distros).






share|improve this answer



















  • 4




    No, it doesn't magically mount your device. You have to specify it with mount /dev/id /mount/point, so that doesn't work.
    – polym
    Jul 22 '14 at 14:02






  • 9




    My answer addresses the user's question 'Is there a way to look through dmesg or /proc or somewhere else to find out which device node is a USB drive.', and is not intended to provide guidance on the practicality of mounting a drive under Linux.
    – AnotherLongUsername
    Jul 23 '14 at 14:43










  • This answer solved an almost identical question for me.
    – Matthew Brown aka Lord Matt
    Oct 10 '14 at 11:04










  • I think automount behavior depends alot on the distro type.
    – jiggunjer
    Feb 2 '16 at 2:08






  • 1




    df too, i suppose.
    – Alexey
    May 26 '16 at 16:11


















up vote
24
down vote













Try the command udevinfo -q all -n /dev/sda, where /dev/sda is the path to your disk. This gives you a boatload of info about the disk you're looking at - there's an entry that tells you about the bus it's connected to.



This of course saves you from having to grep through dmesg and/or logs.



Update



udevadm info --query=all -n /dev/sda 


From at least Jul 2010 [1]udevinfo was substituted in Debian (and derived) by udevadm info with a little transient with which there were symlinks soon deprecated and removed (you can still found them in old not updated machine). Always from [1] we can read:




In udev 117, udevadm was introduced and udevinfo and other programs turned into compatibility symlinks. The symlinks were deprecated in udev 128 and removed for good in udev 147.







share|improve this answer



















  • 8




    In Debian, udevinfo is renamed udevadm.
    – Steve Pomeroy
    Aug 23 '11 at 14:44






  • 8




    On Ubuntu, the command seems to be "udevadm info --query=all -n /dev/sda"
    – machineghost
    Dec 13 '11 at 6:06










  • I suppose they renamed the command at some point - when I wrote the answer (ages ago) the command worked on the ubuntu system that I posted it from ;)
    – Eltariel
    Dec 15 '11 at 5:08










  • Command works still in ubuntu, udevadm info --query=all -n /dev/ttyUSB1
    – Siddharth
    Jun 4 '13 at 8:43








  • 1




    udevadm info --query=all -n /dev/ttyUSB in Fedora too.
    – slm
    Oct 26 '13 at 14:50


















up vote
23
down vote













the simplest method to see what's going on is just typing (as root of course):



blkid -c /dev/null


this gives you a complete overview about all block devices even if not mounted






share|improve this answer





















  • Not all distro have this. Which were you using?
    – New Alexandria
    Sep 19 '15 at 17:26










  • This outputs nothing on my Raspbian distro.
    – Igor G.
    Aug 8 '16 at 6:17










  • Command not found: blkid
    – Igor G.
    Sep 28 '16 at 17:13










  • No output from this command on Ubuntu 14.04 64-bit.
    – gbmhunter
    Apr 17 '17 at 18:15


















up vote
11
down vote













/dev/disk/by-* is the easiest way in this case, if for some reason you want to make life more interesting you can use HAL.



To list all devices you use:



hal-device


To get a specific property you use (this will return /dev/sd* on a USB storage device):



hal-get-property --udi $UDI --key block.device


There is also:



hal-find-by-capability
hal-find-by-property


If you want to make it even more complicated you can relatively easy write yourself a HAL based auto mounter, which can be quite handy if you want to automate things completly.



And just for completeness there are also:



lsusb -v
lshw


Which provides some general information about USB and your hardware in general.






share|improve this answer

















  • 2




    /dev/disk/by-id/*usb* is very helpful.
    – Rob
    Dec 12 '11 at 18:56










  • /dev/disk/by-label ftw. Thanks :)
    – Triptych
    Jun 17 '13 at 13:25


















up vote
8
down vote













sudo fdisk -l


And just analyse the result.






share|improve this answer

















  • 1




    fdisk man page "If no devices are given, those mentioned in /proc/partitions (if that exists) are used." Running fdisk may not be an option... Based on one Debian system that I know doesn't have it installed, my guess is that some GPT systems might not install the unneeded software. Still, checking /proc/partitions ought to be an option.
    – TOOGAM
    Nov 10 '15 at 7:33










  • This was the only option that worked fine for me. I am sorry if it didn't work for you!
    – Felipe
    Nov 10 '15 at 21:52


















up vote
8
down vote













Use



ls -l /dev/disk/by-id/usb*


Under the default udev rules, that will show you most usb devices and it will show you the symlink to their block-device name on the system.



If that doesn't work, look at /dev/disk/by-id/ directly.






share|improve this answer






























    up vote
    6
    down vote













    For USB devices you can simply do



    REMOVABLE_DRIVES=""
    for _device in /sys/block/*/device; do
    if echo $(readlink -f "$_device")|egrep -q "usb"; then
    _disk=$(echo "$_device" | cut -f4 -d/)
    REMOVABLE_DRIVES="$REMOVABLE_DRIVES $_disk"
    fi
    done
    echo Removable drives found: "$REMOVABLE_DRIVES"





    share|improve this answer



















    • 1




      +1. Simple and concise script to do the task automatically.
      – leesei
      Nov 18 '15 at 14:28


















    up vote
    2
    down vote













    Take a look at the tree under /dev/disk. It lists disks and their partitions (file systems) by various schemes.






    share|improve this answer




























      up vote
      2
      down vote













      /var/log/message if dmesg no longer has the information.






      share|improve this answer




























        up vote
        0
        down vote













        If you unplug the USB drive and plug it back in, you should see it initialize from the kernel (dmesg)






        share|improve this answer




























          up vote
          0
          down vote













          Based on the excellent answer from stormlash and with a dependency on udev to populate the "/dev/disk/by-id/usb" device tree, you could define a predicate (Bash) as follows:



          is_usb_device() {
          local device_path=$1 # such as /dev/sdc
          for devlink in /dev/disk/by-id/usb*; do
          if [ "$(readlink -f "$devlink")" = "$device_path" ]; then
          return 0
          fi
          done
          return 1
          }


          And then use it:



          if is_usb_device "/dev/sdg"; then
          echo "/dev/sdg is a usb device"
          else
          echo "/dev/sdg is not a usb device"
          fi





          share|improve this answer




















            protected by nhinkle Jan 2 '13 at 5:58



            Thank you for your interest in this question.
            Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



            Would you like to answer one of these unanswered questions instead?














            13 Answers
            13






            active

            oldest

            votes








            13 Answers
            13






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            77
            down vote



            accepted










            Easiest way: Look at the output of dmesg after connecting the USB device. It should show you what /dev node was assigned to it.






            share|improve this answer



















            • 2




              dmesg works great, but I have a case where dmesg does not show the /dev node: [421963.864281] usb 3-6: new high-speed USB device number 32 using xhci_hcd What does this mean? How can I mount this device? The device shows up on lsusb...
              – modulitos
              Apr 25 '16 at 5:58








            • 1




              Actually, I figured it out. There was a kernel update since my last reboot that was causing this problem. After a reboot, my usb mounts just fine. Hopefully this helps someone!
              – modulitos
              Apr 25 '16 at 6:39

















            up vote
            77
            down vote



            accepted










            Easiest way: Look at the output of dmesg after connecting the USB device. It should show you what /dev node was assigned to it.






            share|improve this answer



















            • 2




              dmesg works great, but I have a case where dmesg does not show the /dev node: [421963.864281] usb 3-6: new high-speed USB device number 32 using xhci_hcd What does this mean? How can I mount this device? The device shows up on lsusb...
              – modulitos
              Apr 25 '16 at 5:58








            • 1




              Actually, I figured it out. There was a kernel update since my last reboot that was causing this problem. After a reboot, my usb mounts just fine. Hopefully this helps someone!
              – modulitos
              Apr 25 '16 at 6:39















            up vote
            77
            down vote



            accepted







            up vote
            77
            down vote



            accepted






            Easiest way: Look at the output of dmesg after connecting the USB device. It should show you what /dev node was assigned to it.






            share|improve this answer














            Easiest way: Look at the output of dmesg after connecting the USB device. It should show you what /dev node was assigned to it.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jul 22 '14 at 14:13









            polym

            11311




            11311










            answered Sep 16 '08 at 3:53









            zigdon

            1,273813




            1,273813








            • 2




              dmesg works great, but I have a case where dmesg does not show the /dev node: [421963.864281] usb 3-6: new high-speed USB device number 32 using xhci_hcd What does this mean? How can I mount this device? The device shows up on lsusb...
              – modulitos
              Apr 25 '16 at 5:58








            • 1




              Actually, I figured it out. There was a kernel update since my last reboot that was causing this problem. After a reboot, my usb mounts just fine. Hopefully this helps someone!
              – modulitos
              Apr 25 '16 at 6:39
















            • 2




              dmesg works great, but I have a case where dmesg does not show the /dev node: [421963.864281] usb 3-6: new high-speed USB device number 32 using xhci_hcd What does this mean? How can I mount this device? The device shows up on lsusb...
              – modulitos
              Apr 25 '16 at 5:58








            • 1




              Actually, I figured it out. There was a kernel update since my last reboot that was causing this problem. After a reboot, my usb mounts just fine. Hopefully this helps someone!
              – modulitos
              Apr 25 '16 at 6:39










            2




            2




            dmesg works great, but I have a case where dmesg does not show the /dev node: [421963.864281] usb 3-6: new high-speed USB device number 32 using xhci_hcd What does this mean? How can I mount this device? The device shows up on lsusb...
            – modulitos
            Apr 25 '16 at 5:58






            dmesg works great, but I have a case where dmesg does not show the /dev node: [421963.864281] usb 3-6: new high-speed USB device number 32 using xhci_hcd What does this mean? How can I mount this device? The device shows up on lsusb...
            – modulitos
            Apr 25 '16 at 5:58






            1




            1




            Actually, I figured it out. There was a kernel update since my last reboot that was causing this problem. After a reboot, my usb mounts just fine. Hopefully this helps someone!
            – modulitos
            Apr 25 '16 at 6:39






            Actually, I figured it out. There was a kernel update since my last reboot that was causing this problem. After a reboot, my usb mounts just fine. Hopefully this helps someone!
            – modulitos
            Apr 25 '16 at 6:39














            up vote
            53
            down vote













            As long as you are running udev, you can do this easily by referencing /dev/disk/by-id/usb-manufacturername_serialnumber. These appear as symbolic links which you can either directly reference within your fstab, or which you can dereference using readlink -e to determine the associated block device.



            Here's a real world example. On my machine, I have 3 USB hard drives connected. These each show up in /dev/disk/by-id with unique serial numbers (although they share a common manufacturer string). I have created symbolic links to each of these three unique entries, and can now quickly determine which drive is which (and which device is associated with each drive) by running readlink -e linkname. For example, running readlink -e /root/disk2 on my machine currently displays "/dev/sde", while readlink -e /root/disk3 produces no output whatsoever.






            share|improve this answer

















            • 13




              Short and simply: for devlink in /dev/disk/by-id/usb*; do readlink -f ${devlink}; done
              – Felipe Alcacibar
              Nov 25 '15 at 14:02

















            up vote
            53
            down vote













            As long as you are running udev, you can do this easily by referencing /dev/disk/by-id/usb-manufacturername_serialnumber. These appear as symbolic links which you can either directly reference within your fstab, or which you can dereference using readlink -e to determine the associated block device.



            Here's a real world example. On my machine, I have 3 USB hard drives connected. These each show up in /dev/disk/by-id with unique serial numbers (although they share a common manufacturer string). I have created symbolic links to each of these three unique entries, and can now quickly determine which drive is which (and which device is associated with each drive) by running readlink -e linkname. For example, running readlink -e /root/disk2 on my machine currently displays "/dev/sde", while readlink -e /root/disk3 produces no output whatsoever.






            share|improve this answer

















            • 13




              Short and simply: for devlink in /dev/disk/by-id/usb*; do readlink -f ${devlink}; done
              – Felipe Alcacibar
              Nov 25 '15 at 14:02















            up vote
            53
            down vote










            up vote
            53
            down vote









            As long as you are running udev, you can do this easily by referencing /dev/disk/by-id/usb-manufacturername_serialnumber. These appear as symbolic links which you can either directly reference within your fstab, or which you can dereference using readlink -e to determine the associated block device.



            Here's a real world example. On my machine, I have 3 USB hard drives connected. These each show up in /dev/disk/by-id with unique serial numbers (although they share a common manufacturer string). I have created symbolic links to each of these three unique entries, and can now quickly determine which drive is which (and which device is associated with each drive) by running readlink -e linkname. For example, running readlink -e /root/disk2 on my machine currently displays "/dev/sde", while readlink -e /root/disk3 produces no output whatsoever.






            share|improve this answer












            As long as you are running udev, you can do this easily by referencing /dev/disk/by-id/usb-manufacturername_serialnumber. These appear as symbolic links which you can either directly reference within your fstab, or which you can dereference using readlink -e to determine the associated block device.



            Here's a real world example. On my machine, I have 3 USB hard drives connected. These each show up in /dev/disk/by-id with unique serial numbers (although they share a common manufacturer string). I have created symbolic links to each of these three unique entries, and can now quickly determine which drive is which (and which device is associated with each drive) by running readlink -e linkname. For example, running readlink -e /root/disk2 on my machine currently displays "/dev/sde", while readlink -e /root/disk3 produces no output whatsoever.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 16 '08 at 19:29







            stormlash















            • 13




              Short and simply: for devlink in /dev/disk/by-id/usb*; do readlink -f ${devlink}; done
              – Felipe Alcacibar
              Nov 25 '15 at 14:02
















            • 13




              Short and simply: for devlink in /dev/disk/by-id/usb*; do readlink -f ${devlink}; done
              – Felipe Alcacibar
              Nov 25 '15 at 14:02










            13




            13




            Short and simply: for devlink in /dev/disk/by-id/usb*; do readlink -f ${devlink}; done
            – Felipe Alcacibar
            Nov 25 '15 at 14:02






            Short and simply: for devlink in /dev/disk/by-id/usb*; do readlink -f ${devlink}; done
            – Felipe Alcacibar
            Nov 25 '15 at 14:02












            up vote
            51
            down vote













            All of these are good suggestions, but the quickest and least verbose method is to just type the following in the terminal:



            mount


            which will give a list of all the mounted devices (this assumes the USB drive is mounted, which is usually the case with modern Linux distros).






            share|improve this answer



















            • 4




              No, it doesn't magically mount your device. You have to specify it with mount /dev/id /mount/point, so that doesn't work.
              – polym
              Jul 22 '14 at 14:02






            • 9




              My answer addresses the user's question 'Is there a way to look through dmesg or /proc or somewhere else to find out which device node is a USB drive.', and is not intended to provide guidance on the practicality of mounting a drive under Linux.
              – AnotherLongUsername
              Jul 23 '14 at 14:43










            • This answer solved an almost identical question for me.
              – Matthew Brown aka Lord Matt
              Oct 10 '14 at 11:04










            • I think automount behavior depends alot on the distro type.
              – jiggunjer
              Feb 2 '16 at 2:08






            • 1




              df too, i suppose.
              – Alexey
              May 26 '16 at 16:11















            up vote
            51
            down vote













            All of these are good suggestions, but the quickest and least verbose method is to just type the following in the terminal:



            mount


            which will give a list of all the mounted devices (this assumes the USB drive is mounted, which is usually the case with modern Linux distros).






            share|improve this answer



















            • 4




              No, it doesn't magically mount your device. You have to specify it with mount /dev/id /mount/point, so that doesn't work.
              – polym
              Jul 22 '14 at 14:02






            • 9




              My answer addresses the user's question 'Is there a way to look through dmesg or /proc or somewhere else to find out which device node is a USB drive.', and is not intended to provide guidance on the practicality of mounting a drive under Linux.
              – AnotherLongUsername
              Jul 23 '14 at 14:43










            • This answer solved an almost identical question for me.
              – Matthew Brown aka Lord Matt
              Oct 10 '14 at 11:04










            • I think automount behavior depends alot on the distro type.
              – jiggunjer
              Feb 2 '16 at 2:08






            • 1




              df too, i suppose.
              – Alexey
              May 26 '16 at 16:11













            up vote
            51
            down vote










            up vote
            51
            down vote









            All of these are good suggestions, but the quickest and least verbose method is to just type the following in the terminal:



            mount


            which will give a list of all the mounted devices (this assumes the USB drive is mounted, which is usually the case with modern Linux distros).






            share|improve this answer














            All of these are good suggestions, but the quickest and least verbose method is to just type the following in the terminal:



            mount


            which will give a list of all the mounted devices (this assumes the USB drive is mounted, which is usually the case with modern Linux distros).







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 12 '14 at 10:27









            Community

            1




            1










            answered Sep 4 '12 at 18:51









            AnotherLongUsername

            63565




            63565








            • 4




              No, it doesn't magically mount your device. You have to specify it with mount /dev/id /mount/point, so that doesn't work.
              – polym
              Jul 22 '14 at 14:02






            • 9




              My answer addresses the user's question 'Is there a way to look through dmesg or /proc or somewhere else to find out which device node is a USB drive.', and is not intended to provide guidance on the practicality of mounting a drive under Linux.
              – AnotherLongUsername
              Jul 23 '14 at 14:43










            • This answer solved an almost identical question for me.
              – Matthew Brown aka Lord Matt
              Oct 10 '14 at 11:04










            • I think automount behavior depends alot on the distro type.
              – jiggunjer
              Feb 2 '16 at 2:08






            • 1




              df too, i suppose.
              – Alexey
              May 26 '16 at 16:11














            • 4




              No, it doesn't magically mount your device. You have to specify it with mount /dev/id /mount/point, so that doesn't work.
              – polym
              Jul 22 '14 at 14:02






            • 9




              My answer addresses the user's question 'Is there a way to look through dmesg or /proc or somewhere else to find out which device node is a USB drive.', and is not intended to provide guidance on the practicality of mounting a drive under Linux.
              – AnotherLongUsername
              Jul 23 '14 at 14:43










            • This answer solved an almost identical question for me.
              – Matthew Brown aka Lord Matt
              Oct 10 '14 at 11:04










            • I think automount behavior depends alot on the distro type.
              – jiggunjer
              Feb 2 '16 at 2:08






            • 1




              df too, i suppose.
              – Alexey
              May 26 '16 at 16:11








            4




            4




            No, it doesn't magically mount your device. You have to specify it with mount /dev/id /mount/point, so that doesn't work.
            – polym
            Jul 22 '14 at 14:02




            No, it doesn't magically mount your device. You have to specify it with mount /dev/id /mount/point, so that doesn't work.
            – polym
            Jul 22 '14 at 14:02




            9




            9




            My answer addresses the user's question 'Is there a way to look through dmesg or /proc or somewhere else to find out which device node is a USB drive.', and is not intended to provide guidance on the practicality of mounting a drive under Linux.
            – AnotherLongUsername
            Jul 23 '14 at 14:43




            My answer addresses the user's question 'Is there a way to look through dmesg or /proc or somewhere else to find out which device node is a USB drive.', and is not intended to provide guidance on the practicality of mounting a drive under Linux.
            – AnotherLongUsername
            Jul 23 '14 at 14:43












            This answer solved an almost identical question for me.
            – Matthew Brown aka Lord Matt
            Oct 10 '14 at 11:04




            This answer solved an almost identical question for me.
            – Matthew Brown aka Lord Matt
            Oct 10 '14 at 11:04












            I think automount behavior depends alot on the distro type.
            – jiggunjer
            Feb 2 '16 at 2:08




            I think automount behavior depends alot on the distro type.
            – jiggunjer
            Feb 2 '16 at 2:08




            1




            1




            df too, i suppose.
            – Alexey
            May 26 '16 at 16:11




            df too, i suppose.
            – Alexey
            May 26 '16 at 16:11










            up vote
            24
            down vote













            Try the command udevinfo -q all -n /dev/sda, where /dev/sda is the path to your disk. This gives you a boatload of info about the disk you're looking at - there's an entry that tells you about the bus it's connected to.



            This of course saves you from having to grep through dmesg and/or logs.



            Update



            udevadm info --query=all -n /dev/sda 


            From at least Jul 2010 [1]udevinfo was substituted in Debian (and derived) by udevadm info with a little transient with which there were symlinks soon deprecated and removed (you can still found them in old not updated machine). Always from [1] we can read:




            In udev 117, udevadm was introduced and udevinfo and other programs turned into compatibility symlinks. The symlinks were deprecated in udev 128 and removed for good in udev 147.







            share|improve this answer



















            • 8




              In Debian, udevinfo is renamed udevadm.
              – Steve Pomeroy
              Aug 23 '11 at 14:44






            • 8




              On Ubuntu, the command seems to be "udevadm info --query=all -n /dev/sda"
              – machineghost
              Dec 13 '11 at 6:06










            • I suppose they renamed the command at some point - when I wrote the answer (ages ago) the command worked on the ubuntu system that I posted it from ;)
              – Eltariel
              Dec 15 '11 at 5:08










            • Command works still in ubuntu, udevadm info --query=all -n /dev/ttyUSB1
              – Siddharth
              Jun 4 '13 at 8:43








            • 1




              udevadm info --query=all -n /dev/ttyUSB in Fedora too.
              – slm
              Oct 26 '13 at 14:50















            up vote
            24
            down vote













            Try the command udevinfo -q all -n /dev/sda, where /dev/sda is the path to your disk. This gives you a boatload of info about the disk you're looking at - there's an entry that tells you about the bus it's connected to.



            This of course saves you from having to grep through dmesg and/or logs.



            Update



            udevadm info --query=all -n /dev/sda 


            From at least Jul 2010 [1]udevinfo was substituted in Debian (and derived) by udevadm info with a little transient with which there were symlinks soon deprecated and removed (you can still found them in old not updated machine). Always from [1] we can read:




            In udev 117, udevadm was introduced and udevinfo and other programs turned into compatibility symlinks. The symlinks were deprecated in udev 128 and removed for good in udev 147.







            share|improve this answer



















            • 8




              In Debian, udevinfo is renamed udevadm.
              – Steve Pomeroy
              Aug 23 '11 at 14:44






            • 8




              On Ubuntu, the command seems to be "udevadm info --query=all -n /dev/sda"
              – machineghost
              Dec 13 '11 at 6:06










            • I suppose they renamed the command at some point - when I wrote the answer (ages ago) the command worked on the ubuntu system that I posted it from ;)
              – Eltariel
              Dec 15 '11 at 5:08










            • Command works still in ubuntu, udevadm info --query=all -n /dev/ttyUSB1
              – Siddharth
              Jun 4 '13 at 8:43








            • 1




              udevadm info --query=all -n /dev/ttyUSB in Fedora too.
              – slm
              Oct 26 '13 at 14:50













            up vote
            24
            down vote










            up vote
            24
            down vote









            Try the command udevinfo -q all -n /dev/sda, where /dev/sda is the path to your disk. This gives you a boatload of info about the disk you're looking at - there's an entry that tells you about the bus it's connected to.



            This of course saves you from having to grep through dmesg and/or logs.



            Update



            udevadm info --query=all -n /dev/sda 


            From at least Jul 2010 [1]udevinfo was substituted in Debian (and derived) by udevadm info with a little transient with which there were symlinks soon deprecated and removed (you can still found them in old not updated machine). Always from [1] we can read:




            In udev 117, udevadm was introduced and udevinfo and other programs turned into compatibility symlinks. The symlinks were deprecated in udev 128 and removed for good in udev 147.







            share|improve this answer














            Try the command udevinfo -q all -n /dev/sda, where /dev/sda is the path to your disk. This gives you a boatload of info about the disk you're looking at - there's an entry that tells you about the bus it's connected to.



            This of course saves you from having to grep through dmesg and/or logs.



            Update



            udevadm info --query=all -n /dev/sda 


            From at least Jul 2010 [1]udevinfo was substituted in Debian (and derived) by udevadm info with a little transient with which there were symlinks soon deprecated and removed (you can still found them in old not updated machine). Always from [1] we can read:




            In udev 117, udevadm was introduced and udevinfo and other programs turned into compatibility symlinks. The symlinks were deprecated in udev 128 and removed for good in udev 147.








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 26 '15 at 8:46









            Hastur

            13k53266




            13k53266










            answered Sep 16 '08 at 3:59









            Eltariel

            38715




            38715








            • 8




              In Debian, udevinfo is renamed udevadm.
              – Steve Pomeroy
              Aug 23 '11 at 14:44






            • 8




              On Ubuntu, the command seems to be "udevadm info --query=all -n /dev/sda"
              – machineghost
              Dec 13 '11 at 6:06










            • I suppose they renamed the command at some point - when I wrote the answer (ages ago) the command worked on the ubuntu system that I posted it from ;)
              – Eltariel
              Dec 15 '11 at 5:08










            • Command works still in ubuntu, udevadm info --query=all -n /dev/ttyUSB1
              – Siddharth
              Jun 4 '13 at 8:43








            • 1




              udevadm info --query=all -n /dev/ttyUSB in Fedora too.
              – slm
              Oct 26 '13 at 14:50














            • 8




              In Debian, udevinfo is renamed udevadm.
              – Steve Pomeroy
              Aug 23 '11 at 14:44






            • 8




              On Ubuntu, the command seems to be "udevadm info --query=all -n /dev/sda"
              – machineghost
              Dec 13 '11 at 6:06










            • I suppose they renamed the command at some point - when I wrote the answer (ages ago) the command worked on the ubuntu system that I posted it from ;)
              – Eltariel
              Dec 15 '11 at 5:08










            • Command works still in ubuntu, udevadm info --query=all -n /dev/ttyUSB1
              – Siddharth
              Jun 4 '13 at 8:43








            • 1




              udevadm info --query=all -n /dev/ttyUSB in Fedora too.
              – slm
              Oct 26 '13 at 14:50








            8




            8




            In Debian, udevinfo is renamed udevadm.
            – Steve Pomeroy
            Aug 23 '11 at 14:44




            In Debian, udevinfo is renamed udevadm.
            – Steve Pomeroy
            Aug 23 '11 at 14:44




            8




            8




            On Ubuntu, the command seems to be "udevadm info --query=all -n /dev/sda"
            – machineghost
            Dec 13 '11 at 6:06




            On Ubuntu, the command seems to be "udevadm info --query=all -n /dev/sda"
            – machineghost
            Dec 13 '11 at 6:06












            I suppose they renamed the command at some point - when I wrote the answer (ages ago) the command worked on the ubuntu system that I posted it from ;)
            – Eltariel
            Dec 15 '11 at 5:08




            I suppose they renamed the command at some point - when I wrote the answer (ages ago) the command worked on the ubuntu system that I posted it from ;)
            – Eltariel
            Dec 15 '11 at 5:08












            Command works still in ubuntu, udevadm info --query=all -n /dev/ttyUSB1
            – Siddharth
            Jun 4 '13 at 8:43






            Command works still in ubuntu, udevadm info --query=all -n /dev/ttyUSB1
            – Siddharth
            Jun 4 '13 at 8:43






            1




            1




            udevadm info --query=all -n /dev/ttyUSB in Fedora too.
            – slm
            Oct 26 '13 at 14:50




            udevadm info --query=all -n /dev/ttyUSB in Fedora too.
            – slm
            Oct 26 '13 at 14:50










            up vote
            23
            down vote













            the simplest method to see what's going on is just typing (as root of course):



            blkid -c /dev/null


            this gives you a complete overview about all block devices even if not mounted






            share|improve this answer





















            • Not all distro have this. Which were you using?
              – New Alexandria
              Sep 19 '15 at 17:26










            • This outputs nothing on my Raspbian distro.
              – Igor G.
              Aug 8 '16 at 6:17










            • Command not found: blkid
              – Igor G.
              Sep 28 '16 at 17:13










            • No output from this command on Ubuntu 14.04 64-bit.
              – gbmhunter
              Apr 17 '17 at 18:15















            up vote
            23
            down vote













            the simplest method to see what's going on is just typing (as root of course):



            blkid -c /dev/null


            this gives you a complete overview about all block devices even if not mounted






            share|improve this answer





















            • Not all distro have this. Which were you using?
              – New Alexandria
              Sep 19 '15 at 17:26










            • This outputs nothing on my Raspbian distro.
              – Igor G.
              Aug 8 '16 at 6:17










            • Command not found: blkid
              – Igor G.
              Sep 28 '16 at 17:13










            • No output from this command on Ubuntu 14.04 64-bit.
              – gbmhunter
              Apr 17 '17 at 18:15













            up vote
            23
            down vote










            up vote
            23
            down vote









            the simplest method to see what's going on is just typing (as root of course):



            blkid -c /dev/null


            this gives you a complete overview about all block devices even if not mounted






            share|improve this answer












            the simplest method to see what's going on is just typing (as root of course):



            blkid -c /dev/null


            this gives you a complete overview about all block devices even if not mounted







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 2 '13 at 8:37









            toh

            40945




            40945












            • Not all distro have this. Which were you using?
              – New Alexandria
              Sep 19 '15 at 17:26










            • This outputs nothing on my Raspbian distro.
              – Igor G.
              Aug 8 '16 at 6:17










            • Command not found: blkid
              – Igor G.
              Sep 28 '16 at 17:13










            • No output from this command on Ubuntu 14.04 64-bit.
              – gbmhunter
              Apr 17 '17 at 18:15


















            • Not all distro have this. Which were you using?
              – New Alexandria
              Sep 19 '15 at 17:26










            • This outputs nothing on my Raspbian distro.
              – Igor G.
              Aug 8 '16 at 6:17










            • Command not found: blkid
              – Igor G.
              Sep 28 '16 at 17:13










            • No output from this command on Ubuntu 14.04 64-bit.
              – gbmhunter
              Apr 17 '17 at 18:15
















            Not all distro have this. Which were you using?
            – New Alexandria
            Sep 19 '15 at 17:26




            Not all distro have this. Which were you using?
            – New Alexandria
            Sep 19 '15 at 17:26












            This outputs nothing on my Raspbian distro.
            – Igor G.
            Aug 8 '16 at 6:17




            This outputs nothing on my Raspbian distro.
            – Igor G.
            Aug 8 '16 at 6:17












            Command not found: blkid
            – Igor G.
            Sep 28 '16 at 17:13




            Command not found: blkid
            – Igor G.
            Sep 28 '16 at 17:13












            No output from this command on Ubuntu 14.04 64-bit.
            – gbmhunter
            Apr 17 '17 at 18:15




            No output from this command on Ubuntu 14.04 64-bit.
            – gbmhunter
            Apr 17 '17 at 18:15










            up vote
            11
            down vote













            /dev/disk/by-* is the easiest way in this case, if for some reason you want to make life more interesting you can use HAL.



            To list all devices you use:



            hal-device


            To get a specific property you use (this will return /dev/sd* on a USB storage device):



            hal-get-property --udi $UDI --key block.device


            There is also:



            hal-find-by-capability
            hal-find-by-property


            If you want to make it even more complicated you can relatively easy write yourself a HAL based auto mounter, which can be quite handy if you want to automate things completly.



            And just for completeness there are also:



            lsusb -v
            lshw


            Which provides some general information about USB and your hardware in general.






            share|improve this answer

















            • 2




              /dev/disk/by-id/*usb* is very helpful.
              – Rob
              Dec 12 '11 at 18:56










            • /dev/disk/by-label ftw. Thanks :)
              – Triptych
              Jun 17 '13 at 13:25















            up vote
            11
            down vote













            /dev/disk/by-* is the easiest way in this case, if for some reason you want to make life more interesting you can use HAL.



            To list all devices you use:



            hal-device


            To get a specific property you use (this will return /dev/sd* on a USB storage device):



            hal-get-property --udi $UDI --key block.device


            There is also:



            hal-find-by-capability
            hal-find-by-property


            If you want to make it even more complicated you can relatively easy write yourself a HAL based auto mounter, which can be quite handy if you want to automate things completly.



            And just for completeness there are also:



            lsusb -v
            lshw


            Which provides some general information about USB and your hardware in general.






            share|improve this answer

















            • 2




              /dev/disk/by-id/*usb* is very helpful.
              – Rob
              Dec 12 '11 at 18:56










            • /dev/disk/by-label ftw. Thanks :)
              – Triptych
              Jun 17 '13 at 13:25













            up vote
            11
            down vote










            up vote
            11
            down vote









            /dev/disk/by-* is the easiest way in this case, if for some reason you want to make life more interesting you can use HAL.



            To list all devices you use:



            hal-device


            To get a specific property you use (this will return /dev/sd* on a USB storage device):



            hal-get-property --udi $UDI --key block.device


            There is also:



            hal-find-by-capability
            hal-find-by-property


            If you want to make it even more complicated you can relatively easy write yourself a HAL based auto mounter, which can be quite handy if you want to automate things completly.



            And just for completeness there are also:



            lsusb -v
            lshw


            Which provides some general information about USB and your hardware in general.






            share|improve this answer












            /dev/disk/by-* is the easiest way in this case, if for some reason you want to make life more interesting you can use HAL.



            To list all devices you use:



            hal-device


            To get a specific property you use (this will return /dev/sd* on a USB storage device):



            hal-get-property --udi $UDI --key block.device


            There is also:



            hal-find-by-capability
            hal-find-by-property


            If you want to make it even more complicated you can relatively easy write yourself a HAL based auto mounter, which can be quite handy if you want to automate things completly.



            And just for completeness there are also:



            lsusb -v
            lshw


            Which provides some general information about USB and your hardware in general.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 24 '09 at 22:36









            Grumbel

            2,09842031




            2,09842031








            • 2




              /dev/disk/by-id/*usb* is very helpful.
              – Rob
              Dec 12 '11 at 18:56










            • /dev/disk/by-label ftw. Thanks :)
              – Triptych
              Jun 17 '13 at 13:25














            • 2




              /dev/disk/by-id/*usb* is very helpful.
              – Rob
              Dec 12 '11 at 18:56










            • /dev/disk/by-label ftw. Thanks :)
              – Triptych
              Jun 17 '13 at 13:25








            2




            2




            /dev/disk/by-id/*usb* is very helpful.
            – Rob
            Dec 12 '11 at 18:56




            /dev/disk/by-id/*usb* is very helpful.
            – Rob
            Dec 12 '11 at 18:56












            /dev/disk/by-label ftw. Thanks :)
            – Triptych
            Jun 17 '13 at 13:25




            /dev/disk/by-label ftw. Thanks :)
            – Triptych
            Jun 17 '13 at 13:25










            up vote
            8
            down vote













            sudo fdisk -l


            And just analyse the result.






            share|improve this answer

















            • 1




              fdisk man page "If no devices are given, those mentioned in /proc/partitions (if that exists) are used." Running fdisk may not be an option... Based on one Debian system that I know doesn't have it installed, my guess is that some GPT systems might not install the unneeded software. Still, checking /proc/partitions ought to be an option.
              – TOOGAM
              Nov 10 '15 at 7:33










            • This was the only option that worked fine for me. I am sorry if it didn't work for you!
              – Felipe
              Nov 10 '15 at 21:52















            up vote
            8
            down vote













            sudo fdisk -l


            And just analyse the result.






            share|improve this answer

















            • 1




              fdisk man page "If no devices are given, those mentioned in /proc/partitions (if that exists) are used." Running fdisk may not be an option... Based on one Debian system that I know doesn't have it installed, my guess is that some GPT systems might not install the unneeded software. Still, checking /proc/partitions ought to be an option.
              – TOOGAM
              Nov 10 '15 at 7:33










            • This was the only option that worked fine for me. I am sorry if it didn't work for you!
              – Felipe
              Nov 10 '15 at 21:52













            up vote
            8
            down vote










            up vote
            8
            down vote









            sudo fdisk -l


            And just analyse the result.






            share|improve this answer












            sudo fdisk -l


            And just analyse the result.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 10 '15 at 2:47









            Felipe

            401159




            401159








            • 1




              fdisk man page "If no devices are given, those mentioned in /proc/partitions (if that exists) are used." Running fdisk may not be an option... Based on one Debian system that I know doesn't have it installed, my guess is that some GPT systems might not install the unneeded software. Still, checking /proc/partitions ought to be an option.
              – TOOGAM
              Nov 10 '15 at 7:33










            • This was the only option that worked fine for me. I am sorry if it didn't work for you!
              – Felipe
              Nov 10 '15 at 21:52














            • 1




              fdisk man page "If no devices are given, those mentioned in /proc/partitions (if that exists) are used." Running fdisk may not be an option... Based on one Debian system that I know doesn't have it installed, my guess is that some GPT systems might not install the unneeded software. Still, checking /proc/partitions ought to be an option.
              – TOOGAM
              Nov 10 '15 at 7:33










            • This was the only option that worked fine for me. I am sorry if it didn't work for you!
              – Felipe
              Nov 10 '15 at 21:52








            1




            1




            fdisk man page "If no devices are given, those mentioned in /proc/partitions (if that exists) are used." Running fdisk may not be an option... Based on one Debian system that I know doesn't have it installed, my guess is that some GPT systems might not install the unneeded software. Still, checking /proc/partitions ought to be an option.
            – TOOGAM
            Nov 10 '15 at 7:33




            fdisk man page "If no devices are given, those mentioned in /proc/partitions (if that exists) are used." Running fdisk may not be an option... Based on one Debian system that I know doesn't have it installed, my guess is that some GPT systems might not install the unneeded software. Still, checking /proc/partitions ought to be an option.
            – TOOGAM
            Nov 10 '15 at 7:33












            This was the only option that worked fine for me. I am sorry if it didn't work for you!
            – Felipe
            Nov 10 '15 at 21:52




            This was the only option that worked fine for me. I am sorry if it didn't work for you!
            – Felipe
            Nov 10 '15 at 21:52










            up vote
            8
            down vote













            Use



            ls -l /dev/disk/by-id/usb*


            Under the default udev rules, that will show you most usb devices and it will show you the symlink to their block-device name on the system.



            If that doesn't work, look at /dev/disk/by-id/ directly.






            share|improve this answer



























              up vote
              8
              down vote













              Use



              ls -l /dev/disk/by-id/usb*


              Under the default udev rules, that will show you most usb devices and it will show you the symlink to their block-device name on the system.



              If that doesn't work, look at /dev/disk/by-id/ directly.






              share|improve this answer

























                up vote
                8
                down vote










                up vote
                8
                down vote









                Use



                ls -l /dev/disk/by-id/usb*


                Under the default udev rules, that will show you most usb devices and it will show you the symlink to their block-device name on the system.



                If that doesn't work, look at /dev/disk/by-id/ directly.






                share|improve this answer














                Use



                ls -l /dev/disk/by-id/usb*


                Under the default udev rules, that will show you most usb devices and it will show you the symlink to their block-device name on the system.



                If that doesn't work, look at /dev/disk/by-id/ directly.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 25 '15 at 15:25









                Hastur

                13k53266




                13k53266










                answered Sep 16 '08 at 4:18









                DJ Capelis

                1813




                1813






















                    up vote
                    6
                    down vote













                    For USB devices you can simply do



                    REMOVABLE_DRIVES=""
                    for _device in /sys/block/*/device; do
                    if echo $(readlink -f "$_device")|egrep -q "usb"; then
                    _disk=$(echo "$_device" | cut -f4 -d/)
                    REMOVABLE_DRIVES="$REMOVABLE_DRIVES $_disk"
                    fi
                    done
                    echo Removable drives found: "$REMOVABLE_DRIVES"





                    share|improve this answer



















                    • 1




                      +1. Simple and concise script to do the task automatically.
                      – leesei
                      Nov 18 '15 at 14:28















                    up vote
                    6
                    down vote













                    For USB devices you can simply do



                    REMOVABLE_DRIVES=""
                    for _device in /sys/block/*/device; do
                    if echo $(readlink -f "$_device")|egrep -q "usb"; then
                    _disk=$(echo "$_device" | cut -f4 -d/)
                    REMOVABLE_DRIVES="$REMOVABLE_DRIVES $_disk"
                    fi
                    done
                    echo Removable drives found: "$REMOVABLE_DRIVES"





                    share|improve this answer



















                    • 1




                      +1. Simple and concise script to do the task automatically.
                      – leesei
                      Nov 18 '15 at 14:28













                    up vote
                    6
                    down vote










                    up vote
                    6
                    down vote









                    For USB devices you can simply do



                    REMOVABLE_DRIVES=""
                    for _device in /sys/block/*/device; do
                    if echo $(readlink -f "$_device")|egrep -q "usb"; then
                    _disk=$(echo "$_device" | cut -f4 -d/)
                    REMOVABLE_DRIVES="$REMOVABLE_DRIVES $_disk"
                    fi
                    done
                    echo Removable drives found: "$REMOVABLE_DRIVES"





                    share|improve this answer














                    For USB devices you can simply do



                    REMOVABLE_DRIVES=""
                    for _device in /sys/block/*/device; do
                    if echo $(readlink -f "$_device")|egrep -q "usb"; then
                    _disk=$(echo "$_device" | cut -f4 -d/)
                    REMOVABLE_DRIVES="$REMOVABLE_DRIVES $_disk"
                    fi
                    done
                    echo Removable drives found: "$REMOVABLE_DRIVES"






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 18 '15 at 17:25









                    leesei

                    1033




                    1033










                    answered Aug 24 '12 at 17:37









                    lemsx1

                    6911




                    6911








                    • 1




                      +1. Simple and concise script to do the task automatically.
                      – leesei
                      Nov 18 '15 at 14:28














                    • 1




                      +1. Simple and concise script to do the task automatically.
                      – leesei
                      Nov 18 '15 at 14:28








                    1




                    1




                    +1. Simple and concise script to do the task automatically.
                    – leesei
                    Nov 18 '15 at 14:28




                    +1. Simple and concise script to do the task automatically.
                    – leesei
                    Nov 18 '15 at 14:28










                    up vote
                    2
                    down vote













                    Take a look at the tree under /dev/disk. It lists disks and their partitions (file systems) by various schemes.






                    share|improve this answer

























                      up vote
                      2
                      down vote













                      Take a look at the tree under /dev/disk. It lists disks and their partitions (file systems) by various schemes.






                      share|improve this answer























                        up vote
                        2
                        down vote










                        up vote
                        2
                        down vote









                        Take a look at the tree under /dev/disk. It lists disks and their partitions (file systems) by various schemes.






                        share|improve this answer












                        Take a look at the tree under /dev/disk. It lists disks and their partitions (file systems) by various schemes.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Sep 16 '08 at 3:55









                        Ted Percival

                        22914




                        22914






















                            up vote
                            2
                            down vote













                            /var/log/message if dmesg no longer has the information.






                            share|improve this answer

























                              up vote
                              2
                              down vote













                              /var/log/message if dmesg no longer has the information.






                              share|improve this answer























                                up vote
                                2
                                down vote










                                up vote
                                2
                                down vote









                                /var/log/message if dmesg no longer has the information.






                                share|improve this answer












                                /var/log/message if dmesg no longer has the information.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Sep 16 '08 at 3:56







                                Allan Wind





























                                    up vote
                                    0
                                    down vote













                                    If you unplug the USB drive and plug it back in, you should see it initialize from the kernel (dmesg)






                                    share|improve this answer

























                                      up vote
                                      0
                                      down vote













                                      If you unplug the USB drive and plug it back in, you should see it initialize from the kernel (dmesg)






                                      share|improve this answer























                                        up vote
                                        0
                                        down vote










                                        up vote
                                        0
                                        down vote









                                        If you unplug the USB drive and plug it back in, you should see it initialize from the kernel (dmesg)






                                        share|improve this answer












                                        If you unplug the USB drive and plug it back in, you should see it initialize from the kernel (dmesg)







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Sep 16 '08 at 3:53









                                        Howler

                                        1373




                                        1373






















                                            up vote
                                            0
                                            down vote













                                            Based on the excellent answer from stormlash and with a dependency on udev to populate the "/dev/disk/by-id/usb" device tree, you could define a predicate (Bash) as follows:



                                            is_usb_device() {
                                            local device_path=$1 # such as /dev/sdc
                                            for devlink in /dev/disk/by-id/usb*; do
                                            if [ "$(readlink -f "$devlink")" = "$device_path" ]; then
                                            return 0
                                            fi
                                            done
                                            return 1
                                            }


                                            And then use it:



                                            if is_usb_device "/dev/sdg"; then
                                            echo "/dev/sdg is a usb device"
                                            else
                                            echo "/dev/sdg is not a usb device"
                                            fi





                                            share|improve this answer

























                                              up vote
                                              0
                                              down vote













                                              Based on the excellent answer from stormlash and with a dependency on udev to populate the "/dev/disk/by-id/usb" device tree, you could define a predicate (Bash) as follows:



                                              is_usb_device() {
                                              local device_path=$1 # such as /dev/sdc
                                              for devlink in /dev/disk/by-id/usb*; do
                                              if [ "$(readlink -f "$devlink")" = "$device_path" ]; then
                                              return 0
                                              fi
                                              done
                                              return 1
                                              }


                                              And then use it:



                                              if is_usb_device "/dev/sdg"; then
                                              echo "/dev/sdg is a usb device"
                                              else
                                              echo "/dev/sdg is not a usb device"
                                              fi





                                              share|improve this answer























                                                up vote
                                                0
                                                down vote










                                                up vote
                                                0
                                                down vote









                                                Based on the excellent answer from stormlash and with a dependency on udev to populate the "/dev/disk/by-id/usb" device tree, you could define a predicate (Bash) as follows:



                                                is_usb_device() {
                                                local device_path=$1 # such as /dev/sdc
                                                for devlink in /dev/disk/by-id/usb*; do
                                                if [ "$(readlink -f "$devlink")" = "$device_path" ]; then
                                                return 0
                                                fi
                                                done
                                                return 1
                                                }


                                                And then use it:



                                                if is_usb_device "/dev/sdg"; then
                                                echo "/dev/sdg is a usb device"
                                                else
                                                echo "/dev/sdg is not a usb device"
                                                fi





                                                share|improve this answer












                                                Based on the excellent answer from stormlash and with a dependency on udev to populate the "/dev/disk/by-id/usb" device tree, you could define a predicate (Bash) as follows:



                                                is_usb_device() {
                                                local device_path=$1 # such as /dev/sdc
                                                for devlink in /dev/disk/by-id/usb*; do
                                                if [ "$(readlink -f "$devlink")" = "$device_path" ]; then
                                                return 0
                                                fi
                                                done
                                                return 1
                                                }


                                                And then use it:



                                                if is_usb_device "/dev/sdg"; then
                                                echo "/dev/sdg is a usb device"
                                                else
                                                echo "/dev/sdg is not a usb device"
                                                fi






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Nov 29 at 19:02









                                                user30747

                                                21025




                                                21025

















                                                    protected by nhinkle Jan 2 '13 at 5:58



                                                    Thank you for your interest in this question.
                                                    Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                                    Would you like to answer one of these unanswered questions instead?



                                                    Popular posts from this blog

                                                    Index of /

                                                    Tribalistas

                                                    Listed building