What drive is usb in linux

USB device detection on /dev directory on Linux

Using the lsusb command in Linux I have come to know about bus and device numbers, along with its name of newly attached USB devices.

But how can I know on which device directory (/dev/*) USB device get attached in Linux using command lines only?

2 Answers 2

It’s not a rule that every device has to show up directly under /dev/, but some device classes will be nested under sub-directories inside /dev/

USB device drivers are a bit different, If you connect a valid USB device, USB HCI would read the VID:PID and will tell the usb-core that the device with VID:PID combination is connected.

If the usbcore detects any registered driver for the VID:PID combination, it will couple it with the device, and the device file creation would happen accordingly

The device will show in /dev/bus/usb/. even if, the corresponding driver is not present, to indicate that the device was detected.

You need to have the device driver to have the device in action/operation.

You can verify whether a device driver is coupled to the device through

Each detected USB device will have an entry here, and also shows the «Driver=» field, to show which driver is associated with your device.

Now, IFF there is a driver, that makes an entry in appropriate /dev tree, you will find the device there.

NOT every device will show up directly under /dev/ in the first level. say, your mouse/keyboard will not show-up directly under /dev, but inside /dev/input/

Likewise, IF the connected USB device is a char/block device, it MAY show up there, that too have exceptions.

If your device is and ethernet/wifi device, the interface device will NOT show up under /dev/, cross-check with your existing eth0, wlan0, they will not appear directly under /dev/, but will in /proc/net/devices

sda/b/c shows up under /dev directly, because they are block devices and are managed by udev, as such.

Источник

How to detect an USB device?

I got a scenario, where a software works only when you insert the USB device provided by the software vendor in windows operating system. Im trying to find the content stored in the USB device. In windows operating system, the USB device icon is not shown in My_Computer. I thought, I can see the content or atleast detect the USB device in Ubuntu.

Also in ubuntu, the drive is not detected. I tried «sudo fdisk -l» to know the file system, but its not useful. The drive is not detected at all.

I wanted to know, how the software works only when the USB drive is inserted and it wont when it is not inserted. Do they have any files stored in the USB device? In any case, how can we detect such kind of device in Ubuntu?

5 Answers 5

To detect your USB device, in a terminal, you can try:

lsusb , example:

or this powerful tool, lsinput ,
1st install it, and then try it, it lists all input devices including your USB device :

udevadm , with this command line, you need to unplug the device before using the command and then plug it to see it:

But it might not work. In my case I m trying to make my Leapfrog Tag run on Ubuntu without success.

If the device in question is a software protection dongle, it may not be a mass storage device.

A likely alternate device for it to implement would be an ethernet controller ; the software can communicate with the device via the network adapter, which won’t appear as a drive. Or the device could implement a serial port, or another device for which the drivers are included with the operating system.

Читайте также:  Установить qbittorrent linux mint

In any case, this is not an appropriate forum to ask about circumventing the copy protection on Windows software, even if you are trying to do it using Ubuntu.

What also works nice when your PC hardware has difficulties with usb events is running a cronjob.

This forces a complete scan of the connected USB devices.
Each minute the situation is updated.

If you want to detect how a USB device is being loaded- with excellent granularity- here are (2) ways:

udevadm monitor : This will show you the USB device being loaded as the USB Bus sees it.

udevadm is part of the default package udev on 18.04 LTS; no need to install it.

Execute udevadm monitor BEFORE you insert the USB device however.

Specimen output loading a USB flash drive shown below. Skip to the last line and you can even see what device it loaded as (sda1):

dmesg (which prints the Kernel ring buffer) will also give you granular visibility into the loading of your USB device.

However, dmesg in contrast to udevadm monitor shows you how loading of your external USB device from the Kernel’s perspective

Specimen output from dmesg -this time from a USB external CD drive- shown below. The «1-2» refers to its’ location on the USB bus: First bus, second port. Had I connected the CD drive to the other port, it would have reported «1-1«:

Источник

Detect and mount devices

I upgraded Ubuntu today and everything works smooth except that Ubuntu doesn’t detect any other storage devices. My / and /home partitions work fine, but my other partitions are just not detected. I wouldn’t mind, except the same problem goes with USB sticks.

When I plug in a USB stick, the light goes on, but the computer detects nothing. Just to be clear, my mouse and keyboard are connected via USB and work fine.

Any idea how to solve this issue? None of the suggestions I found on the internet have any effect.

6 Answers 6

Solution 1: Try the Disks program (if you run Ubuntu with a GUI).

(check that the gnome-disk-utility package is installed) (make sure that udisks2 package is installed)

Hit SUPER A to open the Application Lens and type Disks in the Search Applications field.

( SUPER is probably the key with the Windows icon.)

In Disks you can play with the automount options. .

You have to click on the little icon with the two gears and choose ‘Edit Mount Options’.

Solution 2: Using the CLI (for a headless installation)

Step 1. Check the blockdevices and the file systems that are assigned to those block devices.

Here you see the blokdevice sdb with partition /sdb1. But it’s not mounted. There’s no file assigned to it.

Step 2. What kind of device is sdb?

So the USB stick — the block device /sdb — has the logical name /dev/sdb. And the FAT32 filesystem on that stick has the logical name /dev/sdb1.

Step 3. Mounting the USB-stick

We will mount /dev/sdb1 to /media/usbstick

Read the manpage of mount for other options.

Step 4. Did it work?

Yes, we can see that the filesystem on the USB stick is mounted to /media/usbstick

Addendum : if there are no logical names like /dev/sdb, you should first create them. See this information about setting up and controling loop devices with the losetup command

sudo lsusb will tell you what USB devices Linux detects. Whether a USB storage device mounts, or is detected, are separate issues. sudo lsusb -v will give verbose output, possibly more information than you want if the OS truly doesn’t recognize the device.

Alternatively, you could compare the lists of devices in /dev before and after plugging in the USB device. There are many ways to do it; I would probably just use:

This will give you a number of recognized devices. Doing it before and after plugging in a device will tell you if the OS assigned the device in /dev/ .

Another option would be to look at what is happening in dmesg when you plug in the USB device. dmesg may tell you things like how a device failed.

Читайте также:  Windows is currently running in safe mode so direct3d support cannot be installed

If the USB device you are having trouble mounting, is on the lsusb list, then you can try mounting the device. At this point it would be good to know the filesystem type. sudo fdisk -l will tell you the filesystem type, in the form of an ID. You may have to look up the ID number. There are lots of references online for that. Once you know the device listing, that is, /dev/hda1 and the filesystem type you can try to mount the device manualy with the mount command.

You may have to make sure the location you want to mount the device on exists. If the OS recognizes the file system, then mount might just work if the file system is not a native file system type; you may have to specify flags for mounting.

Post back your output from dmesg (not all of it, only from around when the USB device is plugged in), and sudo lsusb .

You may find Linux / UNIX: Device files helpful if trying to determine device type.

I am writing this assuming all your unrecognized devices are block type devices. There are many ways to approach this type of problem and many possible solutions. More specific information is needed to provide a solution.

There are also many GUI applications that can do the same thing. You might try looking for the plugged-in hardware in the «Disk Utility».

Источник

4 Useful Way to Know Plugged USB Device Name in Linux

As a newbie, one of the many things you should master in Linux is identification of devices attached to your system. It may be your computer’s hard disk, an external hard drive or removable media such USB drive or SD Memory card.

Using USB drives for file transfer is so common today, and for those (new Linux users) who prefer to use the command line, learning the different ways to identify a USB device name is very important, when you need to format it.

Once you attach a device to your system such as a USB, especially on a desktop, it is automatically mounted to a given directory, normally under /media/username/device-label and you can then access the files in it from that directory. However, this is not the case with a server where you have to manually mount a device and specify its mount point.

Linux identifies devices using special device files stored in /dev directory. Some of the files you will find in this directory include /dev/sda or /dev/hda which represents your first master drive, each partition will be represented by a number such as /dev/sda1 or /dev/hda1 for the first partition and so on.

List All Linux Device Names

Now let’s find out device names using some different command-line tools as shown:

Find Out Plugged USB Device Name Using df Command

To view each device attached to your system as well as its mount point, you can use the df command (checks Linux disk space utilization) as shown in the image below:

Find USB Device Name Using df Command

Use lsblk Command to Find USB Device Name

You can also use the lsblk command (list block devices) which lists all block devices attached to your system like so:

List Linux Block Devices

Identify USB Device Name with fdisk Utility

fdisk is a powerful utility which prints out the partition table on all your block devices, a USB drive inclusive, you can run it will root privileges as follows:

List Partition Table of Block Devices

Determine USB Device Name with dmesg Command

dmesg is an important command that prints or controls the kernel ring buffer, a data structure which stores information about the kernel’s operations.

Run the command below to view kernel operation messages which will as well print information about your USB device:

dmesg – Prints USB Device Name

That is all for now, in this article, we have covered different approaches of how to find out a USB device name from the command line. You can also share with us any other methods for the same purpose or perhaps offer us your thoughts about the article via the response section below.

Читайте также:  Эквалайзер с эффектами для windows 10

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

How to access a usb flash drive from the terminal?

I only have access to the command line.
I need to backup my data (on the user folder) to a pen (USB DOK).

  • How can I mount a flash drive manually?
  • What should be the copy command?

7 Answers 7

1. Find what the drive is called

You’ll need to know what the drive is called to mount it. To do that fire off one of the following (ranked in order of my preference):

You’re looking for a partition that should look something like: /dev/sdb1 . The more disks you have the higher the letter this is likely to be. Anyway, find it and remember what it’s called.

2. Create a mount point (optional)

This needs to be mounted into the filesystem somewhere. You can usually use /mnt/ if you’re being lazy and nothing else is mounted there but otherwise you’ll want to create a new directory:

3. Mount!

When you’re done, just fire off:

This answer is almost 6 years old and while the core of it still works, things like fdisk -l aren’t the most user-friendly options. There are also new mechanisms in higher stacks for mounting devices in a sane and standard way which might not always be available.

So I’ve added some polish from the other answers. While you’re reading this footnote and you’re doing this on a desktop system, there definitely are arguments for using udisksctl , per wecac’s answer. This mounts in the same way the desktop does —creating your own /media/$USER/device directory— but I think there are still arguments for a static mountpoint, especially when you don’t want the path to change.

Udisks also relies on D-Bus, so might not be available everywhere.

pmount / pumount

Install pmount . Mounts disks in /media/

Replace «sdb1» with your specific device path. For more information see the manpage:

Use udisksctl from package= udisks2 (in both Ubuntu and Debian). Procedure is:

Find the ID of the block device you want to mount, using lsblk :

From its size, /dev/sdc1 seems to be the USB drive I want to mount.

Use udisksctl to mount the device. Note that -b == —block-device (to reduce typing) but I prefer long options for documentation:

Addressing Hans Deragon’s comment below: you can also tell udisksctl to do —no-user-interaction . It does not attempt to authenticate the user, which usually «just works»:

In addition to using the standard mount command (which requires root) you can mount drives using udisks and dbus with your standard user.

To do this it is useful (but not required) to know a few things about the drive first:

  1. What device it is (i.e. /dev/sdb1 )
  2. what filesystem it uses.

Knowing these you can use a simple command to mount a drive from the command line.

this call should echo the path it is mounted at if the mount succeeds.

To unmount drives mounted in this way you can run:

N.B. the is simply the end of the path to it. So for example if what you want to mount is at /dev/sdb2 then you would put sdb2 in place of .

If you do not know which device it is or what filesystem it uses do not fear. You can easily print out all that information with this little command:

This will print out something like this:

Those that have IdUsage = ‘filesystem’ may be mounted using the above command.

This means that, for example, if i wanted to mount the device ‘USB DRIVE’ i would run the command

Источник

Оцените статью