Linux путь до флешки

How do I know the device path to an USB-stick?

I have a USB-stick (used as an installation medium). Now I need to install a driver from a restricted folder on that device). But how do I get the device path to my USB-stick (e.g. /dev/sda3 so I can mount it using the mount command? I have read the answer to https://unix.stackexchange.com/questions/18925/how-to-mount-a-device-in-linux-beginners-confusion but fdisk -l shows nothing to me.

This really doesn’t answer the question. If I needed a path for » /path/tousbstick» what path would I type in the command line?

6 Answers 6

First plug in your USB-Stick.
Then type:

Your output should look something like this

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465,8G 0 disk ├─sda1 8:1 0 74,5G 0 part / ├─sda2 8:2 0 390,2G 0 part /home ├─sda3 8:3 0 1K 0 part └─sda5 8:5 0 1G 0 part [SWAP] 

Now you can use the size to determine which one is your usb stick . To mount it somewhere in your home folder for example just type:

mkdir ~/UsbStick sudo mount /dev/PATH_TO_YOUR_STICK ~/UsbStick 

obviously replacing PATH_TO_YOUR_STICK with the right /dev/sdX path and ~/UsbStick with the directory you created using the mkdir command

find device path, LABEL, UUID and TYPE of block devices with help of command

/dev/sda1: UUID="XXXX" TYPE="ntfs" /dev/sda5: UUID="XXXX-XXXX" TYPE="ext4" /dev/sda6: UUID="XXXX-XXXX" TYPE="swap" /dev/sda7: UUID="XXXX-XXXX" TYPE="ext4" /dev/sda8: UUID="XXXX-XXXX" TYPE="ext4" /dev/sdb1: LABEL="p" UUID="XXXX-XXXX" TYPE="vfat" 

get your device path and fire mount command for usb-stick.

Device names of flash drives

A flash drive can be connected

  • via USB (typically a USB stick or a memory card via a USB adapter)
  • the device name is the same as for SATA drives, /dev/sdx
  • and partitions are named /dev/sdxn

where x is the device letter and n the partition number, for example /dev/sda1

  • via PCI (typically a memory card in a built-in slot in a laptop)
  • the device name is /dev/mmcblkm
  • and partitions are named /dev/mmcblkmpn

where m is the device number and n the partition number, for example /dev/mmcblk0p1

Example with an SSD, HDD, USB pendrive and an SD card

$ sudo lsblk -o model,name,fstype,size,label,mountpoint MODEL NAME FSTYPE SIZE LABEL MOUNTPOINT Samsung SSD 850 sda 232,9G ├─sda1 vfat 300M EFI /boot/efi ├─sda2 1M ├─sda3 ext4 100G root └─sda4 swap 5G [SWAP] 00BEKT-00PVMT0 sdb 298,1G ├─sdb1 vfat 480M ├─sdb2 ext4 80G lubuntu-xenial64 /media/tester/lubuntu-xenial64 ├─sdb3 swap 3,9G [SWAP] ├─sdb4 ext4 100G ubuntu-artful64x / └─sdb5 ext4 113,7G ubuntu-artful64w /media/tester/ubuntu-artful64w Extreme sdc 14,6G ├─sdc1 ntfs 6,7G usbdata /media/tester/usbdata1 ├─sdc2 1M ├─sdc3 vfat 244M usbboot ├─sdc4 iso9660 948M Lubuntu 17.10 i386 /media/tester/Lubuntu 17.10 i386 └─sdc5 ext4 6,7G casper-rw /media/tester/casper-rw mmcblk0 3,7G ├─mmcblk0p1 ntfs 661M usbdata /media/tester/usbdata ├─mmcblk0p2 1K ├─mmcblk0p3 vfat 122M usbboot /media/tester/usbboot ├─mmcblk0p4 iso9660 355M 9w-dus /media/tester/9w-dus └─mmcblk0p5 ext4 2,6G persistence /media/tester/persistence 

Edit for lsblk list: With modern versions of Ubuntu you need not use sudo , and when there are (many) snaps, and we don’t want them to clutter the list, you the following command line,

lsblk -o model,name,fstype,size,label,mountpoint | grep -v " loop.*snap" 
$ sudo parted -ls [sudo] password for tester: Model: ATA Samsung SSD 850 (scsi) Disk /dev/sda: 250GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 316MB 315MB fat32 boot, esp 2 316MB 317MB 1049kB 3 317MB 108GB 107GB ext4 root 4 244GB 249GB 5369MB linux-swap(v1) Model: WDC WD32 00BEKT-00PVMT0 (scsi) Disk /dev/sdb: 320GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 33,6MB 537MB 503MB fat32 EFI System Partition boot, esp 2 537MB 86,4GB 85,9GB ext4 4 86,4GB 194GB 107GB ext4 5 194GB 316GB 122GB ext4 3 316GB 320GB 4161MB linux-swap(v1) Model: SanDisk Extreme (scsi) Disk /dev/sdc: 15,7GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 2 1049kB 2097kB 1049kB primary bios_grub 3 2097kB 258MB 256MB fat32 primary boot, esp 4 258MB 1252MB 994MB primary 5 1252MB 8473MB 7221MB ext2 primary 1 8473MB 15,7GB 7221MB ntfs primary msftdata Model: SD SD04G (sd/mmc) Disk /dev/mmcblk0: 3965MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 3 2097kB 130MB 128MB primary fat32 boot 4 130MB 502MB 372MB primary 2 502MB 3272MB 2769MB extended lba 5 503MB 3272MB 2768MB logical ext2 1 3272MB 3965MB 693MB primary ntfs 

Источник

Читайте также:  Vmware linux vmmon error

Как узнать путь устройства к USB-флешке?

У меня есть USB-флешка (используется как установочный носитель). Теперь мне нужно установить драйвер из ограниченной папки на этом устройстве). Но как мне получить путь к устройству USB-накопителя (например, /dev/sda3 чтобы я мог подключить его с помощью mount команды?

Это действительно не отвечает на вопрос. Если бы мне нужен был путь для «/ path / tousbstick», какой путь я бы набрал в командной строке?

Сначала подключите USB-флешку.
Затем введите:

Ваш вывод должен выглядеть примерно так

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465,8G 0 disk ├─sda1 8:1 0 74,5G 0 part / ├─sda2 8:2 0 390,2G 0 part /home ├─sda3 8:3 0 1K 0 part └─sda5 8:5 0 1G 0 part [SWAP] 

Теперь вы можете использовать размер, чтобы определить, какой из них ваш флешка. Чтобы смонтировать его где-нибудь в вашей домашней папке, например, просто наберите:

mkdir ~/UsbStick sudo mount /dev/PATH_TO_YOUR_STICK ~/UsbStick 

очевидно, заменив PATH_TO_YOUR_STICK на правильный /dev/sdX путь и ~/UsbStick на каталог, который вы создали с помощью mkdir команды

найти путь устройства, LABEL, UUID и TYPE блочных устройств с помощью команды

/dev/sda1: UUID="XXXX" TYPE="ntfs" /dev/sda5: UUID="XXXX-XXXX" TYPE="ext4" /dev/sda6: UUID="XXXX-XXXX" TYPE="swap" /dev/sda7: UUID="XXXX-XXXX" TYPE="ext4" /dev/sda8: UUID="XXXX-XXXX" TYPE="ext4" /dev/sdb1: LABEL="p" UUID="XXXX-XXXX" TYPE="vfat" 

получите путь к устройству и команду монтирования огня для usb-флешки.

Проверьте, сколько USB-портов доступно на вашем компьютере, чтобы мы могли подключать USB-устройства к этим портам.

Хотя это может теоретически ответить на вопрос, было бы предпочтительным включить сюда основные части ответа.

Имена устройств флешек

Флешка может быть подключена

  • через USB (обычно флешка или карта памяти через USB-адаптер)
    • имя устройства такое же, как для дисков SATA, /dev/sdx
    • и разделы названы /dev/sdxn

    где x буква устройства и n номер раздела, например /dev/sda1

    где m номер устройства и номер n раздела, например /dev/mmcblk0p1

    Пример с SSD, HDD, USB Pendrive и SD-картой

    $ sudo lsblk -o model,name,fstype,size,label,mountpoint MODEL NAME FSTYPE SIZE LABEL MOUNTPOINT Samsung SSD 850 sda 232,9G ├─sda1 vfat 300M EFI /boot/efi ├─sda2 1M ├─sda3 ext4 100G root └─sda4 swap 5G [SWAP] 00BEKT-00PVMT0 sdb 298,1G ├─sdb1 vfat 480M ├─sdb2 ext4 80G lubuntu-xenial64 /media/tester/lubuntu-xenial64 ├─sdb3 swap 3,9G [SWAP] ├─sdb4 ext4 100G ubuntu-artful64x / └─sdb5 ext4 113,7G ubuntu-artful64w /media/tester/ubuntu-artful64w Extreme sdc 14,6G ├─sdc1 ntfs 6,7G usbdata /media/tester/usbdata1 ├─sdc2 1M ├─sdc3 vfat 244M usbboot ├─sdc4 iso9660 948M Lubuntu 17.10 i386 /media/tester/Lubuntu 17.10 i386 └─sdc5 ext4 6,7G casper-rw /media/tester/casper-rw mmcblk0 3,7G ├─mmcblk0p1 ntfs 661M usbdata /media/tester/usbdata ├─mmcblk0p2 1K ├─mmcblk0p3 vfat 122M usbboot /media/tester/usbboot ├─mmcblk0p4 iso9660 355M 9w-dus /media/tester/9w-dus └─mmcblk0p5 ext4 2,6G persistence /media/tester/persistence 
    $ sudo parted -ls [sudo] password for tester: Model: ATA Samsung SSD 850 (scsi) Disk /dev/sda: 250GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 316MB 315MB fat32 boot, esp 2 316MB 317MB 1049kB 3 317MB 108GB 107GB ext4 root 4 244GB 249GB 5369MB linux-swap(v1) Model: WDC WD32 00BEKT-00PVMT0 (scsi) Disk /dev/sdb: 320GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 33,6MB 537MB 503MB fat32 EFI System Partition boot, esp 2 537MB 86,4GB 85,9GB ext4 4 86,4GB 194GB 107GB ext4 5 194GB 316GB 122GB ext4 3 316GB 320GB 4161MB linux-swap(v1) Model: SanDisk Extreme (scsi) Disk /dev/sdc: 15,7GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 2 1049kB 2097kB 1049kB primary bios_grub 3 2097kB 258MB 256MB fat32 primary boot, esp 4 258MB 1252MB 994MB primary 5 1252MB 8473MB 7221MB ext2 primary 1 8473MB 15,7GB 7221MB ntfs primary msftdata Model: SD SD04G (sd/mmc) Disk /dev/mmcblk0: 3965MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 3 2097kB 130MB 128MB primary fat32 boot 4 130MB 502MB 372MB primary 2 502MB 3272MB 2769MB extended lba 5 503MB 3272MB 2768MB logical ext2 1 3272MB 3965MB 693MB primary ntfs 

    Источник

    Determine USB device file Path

    How can i get USB device file path correctly in Linux. I used command: find / -iname «usb» and got the result as below:

    /dev/bus/usb /sys/bus/usb /sys/bus/usb/drivers/usb /sys/kernel/debug/usb 
    sh-3.2# ls /sys/bus/usb/devices/ 1-0:1.0 1-1:1.0 3-0:1.0 5-0:1.0 usb1 usb3 usb5 1-1 2-0:1.0 4-0:1.0 6-0:1.0 usb2 usb4 usb6 
    2:0:0:0 host0 host2 target2:0:0 

    So which device file is used for USB? How can i indentify it? I need to make a C program with USB device file. Further more, could you explain to me the number 1-1:1.0? What does it mean? Thank you.

    I need to check informations which related to USB device. So i think i will send ioctl to USB device file and read the feedback data? Is this possible?

    What do you mean with «read/write verification»? Is this for some specific device? Or are you trying to duplicate lsusb ?

    2 Answers 2

    So which device file is used for USB? How can i indentify it?

    What you see behind /sys/ is mainly configuration/information about devices. /dev/bus/usb is what you are looking for. I think that the following article can help you

    Is quite old, but still it can help you. (In the article they speak about /proc/bus/usb , today we have /dev/bus/usb )

    Further more, could you explain to me the number 1-1:1.0? What does it mean?

    Each field identify the connection point of your device. The first two field are mandatory:

    • X is the USB bus of your motherboard where is connected the USB system.
    • Y is the port in use on the bus system

    So the USB device identified with the string 3-3 is the device connected on the port 3 of the bus 3.

    If you connect an USB hub, you are extending the connection capability of a single USB port. The Linux kernel identify this situation by appending the Z field.

    So, the USB device identified with the string 1-2.5 is the device connected on the port 5 of the hub connected on the port 2 of the bus 1.

    USB specification allow you to connect in cascade more then one USB hub, so the Linux kernel continue to append the port in use on the different hubs. So, the USB device identified with the string 1-2.1.1 is the device connected on the port 1 of the hub connected on the port 1 of the hub connected to the port 2 of the bus 1.

    A fast way to retrieve these information is to read the kernel messages (if you can).

    $ dmesg | grep usb [. snip . ] [ 2.047950] usb 4-1: new full-speed USB device number 2 using ohci_hcd [ 2.202628] usb 4-1: New USB device found, idVendor=046d, idProduct=c318 [ 2.202638] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 2.202643] usb 4-1: Product: Logitech Illuminated Keyboard [ 2.202648] usb 4-1: Manufacturer: Logitech [. snip . ] 

    Then, the last two fields of the pattern (after colon) identify an internal section of an USB device :

    • A is the configuration number of the device
    • B is the interface number of a configuration

    So, the string 4-1:1.1 means: the interface 1, on configuration 1 that is connected on the port 1 of the bus 4.

    You can retrieve these information with the command lsusb .

    Источник

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