How to tell which device the USB drive is assigned as?
How can I tell which device the USB drive is assigned as?
Before inserting the USB drive:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 238.5G 0 disk
├─nvme0n1p5 259:3 0 15.9G 0 part [SWAP]
├─nvme0n1p1 259:1 0 222.6G 0 part /
└─nvme0n1p2 259:2 0 1K 0 part
After:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 1 1.9G 0 disk
├─sda2 8:2 1 2.4M 0 part
└─sda1 8:1 1 1.2G 0 part
nvme0n1 259:0 0 238.5G 0 disk
├─nvme0n1p5 259:3 0 15.9G 0 part [SWAP]
├─nvme0n1p1 259:1 0 222.6G 0 part /
└─nvme0n1p2 259:2 0 1K 0 part
Is it /dev/sda
??
Solution 1:
Simply use lsblk
output options to find it out:
lsblk -o NAME,TRAN
which produces:
sda sata
├─sda1
└─sda2
sdb usb
└─sdb1
sr0 sata
You can also use other options to get extra information (e.g: SIZE).
If you want a nice clean output use -S
:
$ lsblk -So NAME,SIZE,TRAN
NAME SIZE TRAN
sda 400G sata
sdb 16G usb
sr0 1024M sata
Solution 2:
How to find out which of your devices is a usb device
In short:
find /dev/disk -ls | grep usb
Or, on a specific device:
find /dev/disk -ls | grep usb | grep sda
If it has any output, sda
is a usb device.
Long version
Information on your devices is to be found in the directory /dev/disk
. Specifically the sub directories /dev/disk/by-id
and /dev/disk/by-path
give us information on wheter a device is a usb device or not. For example a name like:
usb-0930_USB_Flash_Memory_04506470B2D398CF-0:0
makes clear this is a usb drive.
If I run ls -l
on the file, the output is:
lrwxrwxrwx 1 root root 9 apr 27 09:21 /dev/disk/by-id/usb-0930_USB_Flash_Memory_04506470B2D398CF-0:0 -> ../../sdb
which clearly shows this is sdb
Using find to filter out usb devices
The find ... -ls
command, will subsequently give us the information we need.
You can easily find out which of the devices is a usb device by running the command:
find /dev/disk -ls | grep usb
To check if specifically sda
is a usb device, run:
find /dev/disk -ls | grep usb | grep sda
If it has any output, it is a usb device.
It obviously looks like your usb device has two partitions:
sda 8:0 1 1.9G 0 disk
├─sda2 8:2 1 2.4M 0 part
└─sda1 8:1 1 1.2G 0 part