Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7398341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:51:29+00:00 2026-05-29T03:51:29+00:00

Basically I need to verify that a USB Drive is connected to a certain

  • 0

Basically I need to verify that a USB Drive is connected to a certain USB Port. I have the following:

USB Drives are labeled virtually:

  • White, Green, Red

I have 3 USB Ports that are also labeled physically:

  • White, Green, Red

Using BLKID I can receive information from the drives such as

BLKID Example
/dec/sdb1: SEC_TYPE="msdos" LABEL="WHTIE" UUID="78FE-870D" TYPE="vfat"

Therefore I know a lot about the drive itself by only knowing the label. Now I using LSPCI I can get the information about the USB port as I know the ID’s of each bridge. For example:

LSPCI Example
0a.00.0 USB Controller: some info 4d88

So that last part 4d88 is the PCI ID.

So I know the PCI ID’s of each port and need to match them up to the USB Drive itself such as:

  • 4d88 = WHITE
  • 4dC0 = GREEN
  • 4d84 = RED

I don’t know how to match / check that relationship. Any help will be appreciated.

ANSWER: Thanks for all the help.

#!/bin/bash

#variables
error="ERROR : Incorrect Command use 'usb_pci.sh'"
pci="USB PCI Check Successful"

errorstatus_white_pci="ERROR : USB PCI FAILED : WHITE Drive"
errorstatus_green_pci="ERROR : USB PCI FAILED : GREEN Drive"
errorstatus_red_pci="ERROR : USB PCI FAILED : RED Drive"

pci_check_white=4dc9
pci_check_green=4d81
pci_check_red=4dc5

#Takes USB label and gets /sys/block/sd?
echo "checking path for USB Label" 
path_white=$(blkid | grep WHITE | cut -d : -f 1 | sed 's|[0-9]*$||; s|^/dev/|/sys/block/|')
echo "white: "$path_white
path_green=$(blkid | grep GREEN | cut -d : -f 1 | sed 's|[0-9]*$||; s|^/dev/|/sys/block/|')
echo "green: "$path_green
path_red=$(blkid | grep RED | cut -d : -f 1 | sed 's|[0-9]*$||; s|^/dev/|/sys/block/|')
echo "red: "$path_red

#Takes /sys/block/sd? and gets PCI Path xx:xx.x
echo "checking path to PCI path" 
pci_path_white=$(ls -l ${path_white} | xargs | cut -d / -f 8 | cut -b 6-13)
echo "white: "$pci_path_white
pci_path_green=$(ls -l ${path_green} | xargs | cut -d / -f 8 | cut -b 6-13)
echo "green: "$pci_path_green
pci_path_red=$(ls -l ${path_red} | xargs | cut -d / -f 8 | cut -b 6-13)
echo "red: "$pci_path_red

#Takes xx:xx.x and gets the PCI Device ID xxxx
echo "checking PCI path to PCI Device ID" 
pci_device_id_white=$(lspci -s ${pci_path_white} | tail -c -5)
echo "white: "$pci_device_id_white
pci_device_id_green=$(lspci -s ${pci_path_green} | tail -c -5)
echo "green: "$pci_device_id_green
pci_device_id_red=$(lspci -s ${pci_path_red} | tail -c -5)
echo "red: "$pci_device_id_red

#check if pci_device_id_xxxx = pci_check_xxxx
echo "checking PCI Device ID equals what it should" 
if [ $pci_device_id_white = $pci_check_white ] ; then
    echo "WHITE USB PCI Check Successful"
else
    echo $errorstatus_white_pci
    exit 1
fi
if [ $pci_device_id_green = $pci_check_green ] ; then
    echo "GREEN USB PCI Check Successful"
else
    echo $errorstatus_green_pci
    exit 1
fi
if [ $pci_device_id_red = $pci_check_red ] ; then
    echo "RED USB PCI Check Successful"
else
    echo $errorstatus_red_pci
    exit 1
fi
echo $pci
exit 0

Edit:

As requested dumps of lspci, lsusb, blkid.

lspci
00:00.0 Host bridge: Intel Corporation Unknown device 0104 (rev 09)
00:02.0 VGA compatible controller: Intel Corporation Unknown device 0126 (rev 09)
00:16.0 Communication controller: Intel Corporation Unknown device 1c3a (rev 04)
00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (rev 04)
00:1a.0 USB Controller: Intel Corporation Unknown device 1c2d (rev 04)
00:1b.0 Audio device: Intel Corporation Unknown device 1c20 (rev 04)
00:1c.0 PCI bridge: Intel Corporation Unknown device 1c10 (rev b4)
00:1c.2 PCI bridge: Intel Corporation Unknown device 1c14 (rev b4)
00:1c.3 PCI bridge: Intel Corporation Unknown device 1c16 (rev b4)
00:1c.5 PCI bridge: Intel Corporation Unknown device 1c1a (rev b4)
00:1d.0 USB Controller: Intel Corporation Unknown device 1c26 (rev 04)
00:1f.0 ISA bridge: Intel Corporation Unknown device 1c4f (rev 04)
00:1f.2 RAID bus controller: Intel Corporation Mobile 82801 SATA RAID Controller (rev 04)
00:1f.3 SMBus: Intel Corporation Unknown device 1c22 (rev 04)
08:00.0 PCI bridge: Integrated Device Technology, Inc. PES4T4 PCI Express Switch (rev 0e)
09:02.0 PCI bridge: Integrated Device Technology, Inc. PES4T4 PCI Express Switch (rev 0e)
09:03.0 PCI bridge: Integrated Device Technology, Inc. PES4T4 PCI Express Switch (rev 0e)
09:04.0 PCI bridge: Integrated Device Technology, Inc. PES4T4 PCI Express Switch (rev 0e)
0a:00.0 USB Controller:  Unknown device 4d88
0a:00.1 USB Controller:  Unknown device 4dc9
0a:00.2 System peripheral:  Unknown device 4dca
0a:00.3 Communication controller:  Unknown device 4d8b
0b:00.0 USB Controller:  Unknown device 4dc0
0b:00.1 USB Controller:  Unknown device 4d81
0b:00.2 System peripheral:  Unknown device 4d8e
0b:00.3 Serial controller:  Unknown device 4dcf
0c:00.0 USB Controller:  Unknown device 4d84
0c:00.1 USB Controller:  Unknown device 4dc5
0c:00.2 System peripheral:  Unknown device 4dc6
0c:00.3 Communication controller:  Unknown device 4d87
0d:00.0 SD Host controller: O2 Micro, Inc. Unknown device 8221 (rev 05)
0d:00.1 Mass storage controller: O2 Micro, Inc. Unknown device 8231 (rev 03)

lsusb
Bus 004 Device 001: ID 0000:0000  
Bus 006 Device 001: ID 0000:0000  
Bus 005 Device 001: ID 0000:0000  
Bus 001 Device 002: ID 8087:0024  
Bus 001 Device 001: ID 0000:0000  
Bus 007 Device 001: ID 0000:0000  
Bus 008 Device 001: ID 0000:0000  
Bus 003 Device 003: ID 0718:063d Imation Corp. 
Bus 003 Device 001: ID 0000:0000  
Bus 002 Device 002: ID 8087:0024  
Bus 002 Device 004: ID 0a5c:5800 Broadcom Corp. BCM5880 Secure Applications Processor
Bus 002 Device 001: ID 0000:0000  
Bus 002 Device 003: ID 413c:3012 Dell Computer Corp. Optical Wheel Mouse

blkid
/dev/mapper/VolGroup00-LogVol01: TYPE="swap" UUID="6b361baf-08ae-4f2c-933b-5028c15b6fb5" 
/dev/mapper/VolGroup00-LogVol00: UUID="d15840ac-0073-483d-b630-7d2a497eaac9" TYPE="ext3" 
/dev/sda1: LABEL="/boot" UUID="39331b93-a08d-45b5-b1ea-fcc6586be7bd" TYPE="ext3" 
/dev/VolGroup00/LogVol00: UUID="d15840ac-0073-483d-b630-7d2a497eaac9" TYPE="ext3" 
/dev/VolGroup00/LogVol01: TYPE="swap" UUID="6b361baf-08ae-4f2c-933b-5028c15b6fb5" 
/dev/sdb1: SEC_TYPE="msdos" LABEL="WHITE" UUID="78FE-870D" TYPE="vfat" 
/dev/sdc1: SEC_TYPE="msdos" LABEL="GREEN" UUID="61FE-B32E" TYPE="vfat" 
/dev/sdd1: SEC_TYPE="msdos" LABEL="RED" UUID="E5DB-4A1A" TYPE="vfat" 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:51:30+00:00Added an answer on May 29, 2026 at 3:51 am

    This is how I would do it on my system:

    Step 1: Find the device node:

    # blkid | grep MyDisk
    /dev/sdj1: LABEL="MyDisk-0" UUID="4876-5945" TYPE="vfat" 
    

    The device node is /dev/sdj1.

    Step 2: /sys is your friend:

    # ll /sys/block/sdj
    lrwxrwxrwx 1 root root 0 Feb  3 00:40 /sys/block/sdj -> ../devices/pci0000:00/0000:00:1a.7/usb1/1-2/1-2:1.0/host15/target15:0:0/15:0:0:0/block/sdj/
    

    The symbolic link target above contains a lot of useful information, including the path from your flash drive back to the PCI bridge via the SCSI and USB subsystems.

    Step 3: From the link target above isolate the PCI bus ID (00:1a.7 in this case) and check with lspci:

    # lspci | grep 00:1a.7
    00:1a.7 USB Controller: Intel Corporation 82801JI (ICH10 Family) USB2 EHCI Controller #2
    

    If in doubt, inspect the lspci output visually…

    EDIT:

    Here is an extremely crude and extremely fragile way to automate the process above:

    blkid |
        grep Label |
        cut -d : -f 1 |
        sed 's|[0-9]*$||; s|^/dev/|/sys/block/|' |
        xargs readlink |
        cut -d / -f 4 |
        xargs -n 1 lspci -s
    

    NOTE: This works on my system, but it is by no means safe (or recommended):

    1. It will break if a kernel update changes the layout of the /sys filesystem.

    2. It can break if you have a different device layout, although you should be able to adjust for that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

basically need to change the value that - admin_url() returns any idea?
I have a project i'm working on where i need to verify the files
I (Basically) need to create a background timer on iOS 4 that will allow
I basically need a url to open that will end up at the updates
I basically need to make a compiler for bibtex files, such that a given
just a quick question. First of all, let me verify that I have the
I basically need something inside a foreach loop that will skip over the first
I have a program where I basically need to load Rich Text from a
Basically need to generate custom(some different then yes no) messeges(alert) in JS , how
I basically need to highlight a particular word in a block of text. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.