Linux

Off-Topic, anything, preferably not related to s1mp3! :)

Moderator: wladston

Linux

Postby ialongiya » Mon Nov 30, 2009 6:45 am

How do you list mountable usb devices on linux from terminal? I am using Damn Small Linux and would like to display a list of all connected usb storage devices and their names from terminal for example i would like to be able to figure out what my ipod would be when connected for example /dev/sda1 or whatever. Thanks in advance!
ialongiya
 
Posts: 1
Joined: Sat Nov 28, 2009 7:21 am

Re: Linux

Postby louigi600 » Tue Dec 01, 2009 8:02 pm

Well a lot depends on your distro and I don't think there is one answer.
Here is one way that is possibly usable on all distributions (appart from the ones that do automount and there's nothing to be done):
just after having inserted the usb disk do
dmesg |tail -24
you should see something like this
Code: Select all
root@hp:~/mp4/debug_tools/linux/s1mp3/trunk# dmesg |tail -24
usb 4-2: new high speed USB device using ehci_hcd and address 2
usb 4-2: New USB device found, idVendor=10d6, idProduct=1101
usb 4-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 4-2: Product: HS USB FlashDisk
usb 4-2: Manufacturer: ACTIONS
usb 4-2: SerialNumber: 4512482adf0fe
usb 4-2: configuration #1 chosen from 1 choice
Initializing USB Mass Storage driver...
scsi0 : SCSI emulation for USB Mass Storage devices
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usb-storage: device found at 2
usb-storage: waiting for device to settle before scanning
scsi 0:0:0:0: Direct-Access     ACTIONS  HS USB FlashDisk 2.00 PQ: 0 ANSI: 0 CCS
usb-storage: device scan complete
Driver 'sd' needs updating - please use bus_type methods
sd 0:0:0:0: [sda] 8016817 512-byte hardware sectors: (4.10 GB/3.82 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 00 c0 00 00
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] Assuming drive cache: write through
 sda:
sd 0:0:0:0: [sda] Attached SCSI removable disk
sd 0:0:0:0: Attached scsi generic sg0 type 0
root@hp:~/mp4/debug_tools/linux/s1mp3/trunk#

In this case the usb disk is sda and has no partitions so you should mount the entire device like this:
mount /dev/sda /mnt

In some other cases you could see something like this:
Code: Select all
root@hp:~/mp4/debug_tools/linux/s1mp3/trunk# dmesg |tail -24
usb-storage: device found at 3
usb-storage: waiting for device to settle before scanning
scsi scan: INQUIRY result too short (5), using 36
scsi 1:0:0:0: Direct-Access     USB 2.0  (HS) Flash Disk  1.00 PQ: 0 ANSI: 0 CCS
sd 1:0:0:0: Attached scsi generic sg0 type 0
scsi scan: INQUIRY result too short (5), using 36
scsi 1:0:0:1: Direct-Access     USB 2.0  (HS) Flash Disk  1.00 PQ: 0 ANSI: 0 CCS
sd 1:0:0:1: Attached scsi generic sg1 type 0
usb-storage: device scan complete
sd 1:0:0:0: [sda] 1971121 512-byte hardware sectors: (1.00 GB/962 MiB)
sd 1:0:0:0: [sda] Write Protect is off
sd 1:0:0:0: [sda] Mode Sense: 00 c0 00 00
sd 1:0:0:0: [sda] Assuming drive cache: write through
sd 1:0:0:0: [sda] Assuming drive cache: write through
 sda: sda1
sd 1:0:0:0: [sda] Attached SCSI removable disk
sd 1:0:0:1: [sdb] 3987441 512-byte hardware sectors: (2.04 GB/1.90 GiB)
sd 1:0:0:1: [sdb] Write Protect is off
sd 1:0:0:1: [sdb] Mode Sense: 00 c0 00 00
sd 1:0:0:1: [sdb] Assuming drive cache: write through
sd 1:0:0:1: [sdb] Assuming drive cache: write through
 sdb: sdb1
sdb: p1 size 3987209 limited to end of disk
sd 1:0:0:1: [sdb] Attached SCSI removable disk
root@hp:~/mp4/debug_tools/linux/s1mp3/trunk#

in this case the mp3 player just plugged in has 2 internal devices (sda and asb) each with one partition.
You could mount them like this
mount /dev/sda1 /mnt/one
mount /dev/sdb1 /mnt/two

lsusb will give you some information on what usb devices plugged in:
Code: Select all
root@hp:/usr/src# lsusb
Bus 004 Device 003: ID 10d6:1101 Actions Semiconductor Co., Ltd D-Wave 2GB MP4 Player
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
root@hp:/usr/src#


fdisk -l will give you an idea on what devices and what partitions are present on the system (including ide and scsi disks).
Beware that unpartitioned devices like the firs example will give you crazy output
Code: Select all
root@hp:~/mp4/debug_tools/linux/s1mp3/trunk# fdisk  -l

Disk /dev/hda: 40.0 GB, 40007761920 bytes
16 heads, 63 sectors/track, 77520 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Disk identifier: 0x71e40b26

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1         125       62968+  83  Linux
/dev/hda2             126        1118      500472   82  Linux swap
/dev/hda3            1119       77520    38506608   83  Linux

Disk /dev/sda: 1009 MB, 1009213952 bytes
32 heads, 63 sectors/track, 977 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         977      984784+   6  FAT16

Disk /dev/sdb: 2041 MB, 2041569792 bytes
61 heads, 60 sectors/track, 1089 cylinders
Units = cylinders of 3660 * 512 = 1873920 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1090     1993604+   6  FAT16
root@hp:~/mp4/debug_tools/linux/s1mp3/trunk#


This is what you get on unpartitioned devices:
Code: Select all
root@hp:~/mp4/debug_tools/linux/s1mp3/trunk# fdisk  -l /dev/sda

Disk /dev/sda: 4104 MB, 4104610304 bytes
127 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 7874 * 512 = 4031488 bytes
Disk identifier: 0x6f20736b

This doesn't look like a partition table
Probably you selected the wrong device.

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   ?       98824      243796   570754815+  72  Unknown
Partition 1 has different physical/logical beginnings (non-Linux?):
     phys=(357, 116, 40) logical=(98823, 58, 11)
Partition 1 has different physical/logical endings:
     phys=(357, 32, 45) logical=(243795, 59, 51)
Partition 1 does not end on cylinder boundary.
/dev/sda2   ?       21424      267300   968014120   65  Novell Netware 386
Partition 2 has different physical/logical beginnings (non-Linux?):
     phys=(288, 115, 43) logical=(21423, 77, 47)
Partition 2 has different physical/logical endings:
     phys=(367, 114, 50) logical=(267299, 87, 42)
Partition 2 does not end on cylinder boundary.
/dev/sda3   ?      237476      483352   968014096   79  Unknown
Partition 3 has different physical/logical beginnings (non-Linux?):
     phys=(366, 32, 33) logical=(237475, 53, 30)
Partition 3 has different physical/logical endings:
     phys=(357, 32, 43) logical=(483351, 62, 39)
Partition 3 does not end on cylinder boundary.
/dev/sda4   ?           1      461929  1818613248    d  Unknown
Partition 4 has different physical/logical beginnings (non-Linux?):
     phys=(372, 97, 50) logical=(0, 0, 1)
Partition 4 has different physical/logical endings:
     phys=(0, 10, 0) logical=(461928, 87, 30)
Partition 4 does not end on cylinder boundary.

Partition table entries are not in disk order
root@hp:~/mp4/debug_tools/linux/s1mp3/trunk#


Don't forget to unmount the device before unplugging it ;-)
--
Regards
David Rao
ZX-6302L-TLSTK V2.0 2007-09-21 MAIN HY
louigi600
 
Posts: 5
Joined: Sat Nov 28, 2009 8:46 am


Return to Free chat

Who is online

Users browsing this forum: No registered users and 2 guests



cron