{"id":10882,"date":"2025-06-11T02:00:00","date_gmt":"2025-06-11T06:00:00","guid":{"rendered":"https:\/\/www.both.org\/?p=10882"},"modified":"2025-06-04T17:55:00","modified_gmt":"2025-06-04T21:55:00","slug":"what-usb-device-is-that","status":"publish","type":"post","link":"https:\/\/www.both.org\/?p=10882","title":{"rendered":"What USB device is that?"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"10882\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\r\n<\/div><\/div>\n<p>When you use Linux with a graphical desktop like GNOME or KDE, the desktop manages a lot of \u201cbehind the scenes\u201d stuff for you. One thing that I don\u2019t really think about is \u201cWhat USB device is that?\u201d when I plug in a USB flash drive. My desktop just gives me an icon that I can use to open the new drive in my file manager. It\u2019s done.<\/p>\n\n\n\n<p>But what if you\u2019re using Linux without a graphical desktop? For example, I recently started using my Raspberry Pi <a href=\"https:\/\/www.both.org\/?p=10813\">entirely from the command line<\/a>. It\u2019s a lot of fun to go back to \u201cconsole\u201d mode, but I miss having the desktop manage my USB drives for me.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"identify-the-device\">Identify the device<\/h2>\n\n\n\n<p>In one recent example, I wanted to copy a bunch of files from the Raspberry Pi so I could use them on my desktop Linux system. I have a 16GB USB flash drive that makes it handy to transfer files.<\/p>\n\n\n\n<p>Before I could <em>mount<\/em> the filesystem on the USB drive, I needed to know how to \u201cfind\u201d the device. That\u2019s an easy two-step process:<\/p>\n\n\n\n<p>First, I ran a command to store the kernel\u2019s messages to a file. The <strong>dmesg<\/strong> command will display all messages from the kernel\u2019s buffer, so run that command as root and store the results in a file. I called my file <code>d1<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># dmesg &gt; d1<\/code><\/pre>\n\n\n\n<p>Then, I plugged in the USB drive. Give it a second, and the kernel will recognize that a new USB device has been connected to the system. This information will be stored in the kernel\u2019s buffer. Run <strong>dmesg<\/strong> a second time and save the output to a new file, such as <code>d2<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># dmesg &gt; d2<\/code><\/pre>\n\n\n\n<p>Now, use the <strong>diff<\/strong> command to print the <em>differences<\/em> between those two files. In this case, the only changes between <code>d1<\/code> and <code>d2<\/code> should be the messages about the new USB device:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># diff d1 d2\n610a611,629\n&gt; &#91;  150.388971] usb 1-1.3: new high-speed USB device number 6 using dwc2\n&gt; &#91;  150.576172] usb 1-1.3: New USB device found, idVendor=03f0, idProduct=5307, bcdDevice=11.00\n&gt; &#91;  150.584344] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3\n&gt; &#91;  150.591712] usb 1-1.3: Product: v165w\n&gt; &#91;  150.595341] usb 1-1.3: Manufacturer: HP\n&gt; &#91;  150.599207] usb 1-1.3: SerialNumber: AA00000000002544\n&gt; &#91;  150.606131] usb-storage 1-1.3:1.0: USB Mass Storage device detected\n&gt; &#91;  150.615222] scsi host0: usb-storage 1-1.3:1.0\n&gt; &#91;  151.997413] scsi 0:0:0:0: Direct-Access     hp       v165w            1100 PQ: 0 ANSI: 0 CCS\n&gt; &#91;  152.006234] scsi 0:0:0:0: alua: supports implicit and explicit TPGS\n&gt; &#91;  152.012283] scsi 0:0:0:0: alua: No target port descriptors found\n&gt; &#91;  152.019941] sd 0:0:0:0: Attached scsi generic sg0 type 0\n&gt; &#91;  152.021393] sd 0:0:0:0: &#91;sda] 31690752 512-byte logical blocks: (16.2 GB\/15.1 GiB)\n&gt; &#91;  152.033700] sd 0:0:0:0: &#91;sda] Write Protect is off\n&gt; &#91;  152.038348] sd 0:0:0:0: &#91;sda] Mode Sense: 43 00 00 00\n&gt; &#91;  152.039676] sd 0:0:0:0: &#91;sda] No Caching mode page found\n&gt; &#91;  152.044785] sd 0:0:0:0: &#91;sda] Assuming drive cache: write through\n&gt; &#91;  152.072051]  sda: sda1\n&gt; &#91;  152.074753] sd 0:0:0:0: &#91;sda] Attached SCSI removable disk<\/code><\/pre>\n\n\n\n<p>This tells me that the kernel recognized my HP v165W USB flash drive as <code>sda<\/code>, which I can access as <code>\/dev\/sda<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"identify-the-partition\">Identify the partition<\/h2>\n\n\n\n<p>Now that I know the device name, I need to know what partition has the data. Actually, that\u2019s easy for me, since I created the partition on this drive, and I created only <em>one<\/em> partition. But to verify, I can use the <strong>fdisk<\/strong> command with the <code>-l<\/code> option to <em>list<\/em> the partition information on the <code>\/dev\/sda<\/code> storage device:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># fdisk -l \/dev\/sda\nDisk \/dev\/sda: 15.11 GiB, 16225665024 bytes, 31690752 sectors\nDisk model: v165w\nUnits: sectors of 1 * 512 = 512 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisklabel type: dos\nDisk identifier: 0x114afb7a\n\nDevice     Boot Start      End  Sectors  Size Id Type\n\/dev\/sda1        2048 31690751 31688704 15.1G 83 Linux<\/code><\/pre>\n\n\n\n<p>With that information, I can mount the USB flash drive so I can copy data to it. I used the <code>\/mnt<\/code> directory, which is otherwise empty and is meant as a generic mount point for short-term use cases like mine:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># mount \/dev\/sda1 \/mnt\n\n# ls \/mnt\n'copy from home_jhall'  'copy from laptop'   home   lost+found  'some music (copy)'<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"living-at-the-command-line\">Living at the command line<\/h2>\n\n\n\n<p>Using the command line to identify and access storage devices may seem primitive if you\u2019re used to a graphical desktop that does the work for you. But knowing how to identify devices like this can also be helpful as a systems administrator. Linux servers do not usually have a graphical desktop, so you need to know how to be effective at the command line. Little \u201ctricks\u201d like this can be a handy \u201ctool\u201d to add to your \u201csysadmin toolkit\u201d to navigate the system.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use kernel messages to identify which disk device you can mount.<\/p>\n","protected":false},"author":33,"featured_media":3293,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[100,644,5],"tags":[104,91,97],"class_list":["post-10882","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-command-line","category-disk-management","category-linux","tag-command-line","tag-linux","tag-sysadmin"],"modified_by":"Jim Hall","_links":{"self":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/10882","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10882"}],"version-history":[{"count":1,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/10882\/revisions"}],"predecessor-version":[{"id":10883,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/10882\/revisions\/10883"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/3293"}],"wp:attachment":[{"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10882"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}