LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Commands to work with USB drives (https://www.linuxquestions.org/questions/linux-newbie-8/commands-to-work-with-usb-drives-823828/)

snydergc 08-03-2010 09:15 AM

Commands to work with USB drives
 
When working in command mode, what are some commands to use to query a USB drive? How do I look for it's "name" if I don't know it? I know once I find it and can use it normal cd and ls commands would work. It's just finding the drive, maybe mounting it, etc.

druuna 08-03-2010 09:27 AM

Hi,

The dmesg command shows this information.

After I plug in the usb device I see something like this:
Quote:

dmesg | tail -25
usb 1-1: new high speed USB device using ehci_hcd and address 7
usb 1-1: configuration #1 chosen from 1 choice
scsi4 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 7
usb-storage: waiting for device to settle before scanning
scsi 4:0:0:0: Direct-Access Kingston DT Secure 6.52 PQ: 0 ANSI: 0 CCS
sd 4:0:0:0: [sdd] 1975295 512-byte hardware sectors (1011 MB)
sd 4:0:0:0: [sdd] Write Protect is off
sd 4:0:0:0: [sdd] Mode Sense: 45 00 00 08
sd 4:0:0:0: [sdd] Assuming drive cache: write through
sd 4:0:0:0: [sdd] 1975295 512-byte hardware sectors (1011 MB)
sd 4:0:0:0: [sdd] Write Protect is off
sd 4:0:0:0: [sdd] Mode Sense: 45 00 00 08
sd 4:0:0:0: [sdd] Assuming drive cache: write through
sdd: sdd1
sd 4:0:0:0: [sdd] Attached SCSI removable disk
sd 4:0:0:0: Attached scsi generic sg5 type 0
usb-storage: device scan complete
The 2 bold parts are of interest.
- The first shows me that the (raw) usb device is attached to /dev/sdd.
- The second shows me that this particular usb device has 1 partition (/dev/sdd1).

You can mount it now as follows (assuming the filesystem on it is ext3):
mount -t ext3 /dev/sdd1 /mnt/mymountpoint

Unmounting is done as follows:
umount /dev/sdd1

the df -h command shows what is mounted.

Hope this helps.

francp 08-03-2010 09:59 AM

Use the command

"lsusb"

hope it helps

druuna 08-03-2010 10:18 AM

Hi,

@francp: Yep, nice command. But I've seen more then one distro that does not install the lsusb command by default and you also need to be root to use it. Another downside is that it does not show the device (as in /dev/xyz), which is needed if you want to mount it.

The command is generally used for displaying information about USB buses in the system and the devices connected to them.

Hope this clears things up a bit.

catkin 08-03-2010 12:22 PM

The blkid command is useful if the USB device is a block device which many are.


All times are GMT -5. The time now is 02:46 PM.