Sponsored Content
Top Forums Shell Programming and Scripting BASH Script to Detect and List USB Flash Drives Post 302297921 by godzillarama on Monday 16th of March 2009 06:58:34 AM
Old 03-16-2009
Thanks, Corona, for those replies; however, I believe that the LSHW utility will do nicely for gathering the information I'm wanting to list for the users. Here is a sample output from my machine. Two flash drives are connected (one of them older and painfully small -- 64MB -- the other 1GB).

This is the result of the "lshw -short" command.

Code:
H/W path                Device     Class       Description
==========================================================
                                   system      PROD00000000
/0                                 bus         Motherboard
/0/0                               processor   Intel(R) Pentium(R) 4 CPU 2.00GHz
/0/0/0                             memory      8KiB L1 cache
/0/0/1                             memory      512KiB L2 cache
/0/1                               memory      2021MiB System memory
/0/100                             bridge      651 Host
/0/100/1                           bridge      Virtual PCI-to-PCI bridge (AGP)
/0/100/1/0                         display     NV44A [GeForce 6200]
/0/100/2                           bridge      SiS962 [MuTIOL Media IO]
/0/100/2.1                         bus         SiS961/2 SMBus Controller
/0/100/2.5                         storage     5513 [IDE]
/0/100/2.5/0            ide0       bus         IDE Channel 0
/0/100/2.5/0/0          /dev/hda   disk        160GB SAMSUNG SP1604N
/0/100/2.5/0/0/1        /dev/hda1  volume      127GiB Windows NTFS volume
/0/100/2.5/0/0/2        /dev/hda2  volume      21GiB Windows NTFS volume
/0/100/2.5/0/1          /dev/hdb   disk        81GB Maxtor 6L080L0
/0/100/2.5/0/1/1        /dev/hdb1  volume      76GiB EXT3 volume
/0/100/2.5/1            ide1       bus         IDE Channel 1
/0/100/2.5/1/0          /dev/hdc   disk        SONY DVD RW DW-Q30A
/0/100/2.5/1/0/0        /dev/hdc   disk
/0/100/2.5/1/1          /dev/hdd   disk        LITE-ON LTR-52327S
/0/100/2.7                         multimedia  AC'97 Sound Controller
/0/100/3                           bus         USB 1.1 Controller
/0/100/3/1              usb4       bus         OHCI Host Controller
/0/100/3.1                         bus         USB 1.1 Controller
/0/100/3.1/1            usb5       bus         OHCI Host Controller
/0/100/3.3                         bus         USB 2.0 Controller
/0/100/3.3/1            usb1       bus         EHCI Host Controller
/0/100/a                           bus         USB
/0/100/a/1              usb6       bus         OHCI Host Controller
/0/100/a.1                         bus         USB
/0/100/a.1/1            usb7       bus         OHCI Host Controller
/0/100/a.1/1/1                     input       Microsoft IntelliMouse
/0/100/a.2                         bus         USB 2.0
/0/100/a.2/1            usb2       bus         EHCI Host Controller
/0/100/a.2/1/3          scsi2      storage     Flash Disk
/0/100/a.2/1/3/0.0.0    /dev/sda   disk        1029MB SCSI Disk
/0/100/a.2/1/3/0.0.0/1  /dev/sda1  volume      981MiB Windows FAT volume
/0/100/b                           bus         VT82xxxxx UHCI USB 1.1 Controller
/0/100/b/1              usb8       bus         UHCI Host Controller
/0/100/b/1/1            scsi3      storage     Mass Storage Device
/0/100/b/1/1/0.0.0      /dev/sdb   disk        65MB SCSI Disk
/0/100/b/1/1/0.0.0/1    /dev/sdb1  volume      62MiB Windows FAT volume
/0/100/b.1                         bus         VT82xxxxx UHCI USB 1.1 Controller
/0/100/b.1/1            usb9       bus         UHCI Host Controller
/0/100/b.2                         bus         USB 2.0
/0/100/b.2/1            usb3       bus         EHCI Host Controller
/0/100/d                eth0       network     RTL-8139/8139C/8139C+

Only takes a couple of seconds. True, lshw tends to view flash drives as SCSI devices, but I don't see that as a dealbreaker.
 

9 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

Mounting USB Drives in Solaris 9 x86

I'm trying to moun my external USB Mass Storage Drive (80GB) in my Solaris 9 box, I am new to Solaris, and kind of new to linux / unix variants. The external HD contains windows files, but I will be using it as a central storage area for my windows/ linux clients. Thanks -- N:confused:C (1 Reply)
Discussion started by: N0C717
1 Replies

2. What is on Your Mind?

USB Thumb Drives

I'm hunting around for thumb drives that aren't working. Something you may have kicking around in a drawer that you don't need any more. One you've upgraded and just don't need. I'm willing to pay a couple bucks for you to drop it into an envelope with a few stamps and send it along. I'm... (0 Replies)
Discussion started by: BOFH
0 Replies

3. Shell Programming and Scripting

how floppy disks, CDs and flash drives (pen drives) are accessed in UNIX

hi how floppy disks, CDs and flash drives (pen drives) are accessed in UNIX? thanks (0 Replies)
Discussion started by: nokia1100
0 Replies

4. Filesystems, Disks and Memory

USB Flash Drives

Can Solaris/any GNU/Linux distros/ any flavor of FreeBSD be booted, right from aUSB flash drive? Mine's the one pictured here. SanDisk | Products | USB Flash Drives | SanDisk CruzerŽ Titanium Plus USB Flash Drive Also, on a completely unrelated note (just so I don't have to fill up forum... (4 Replies)
Discussion started by: led3234
4 Replies

5. Solaris

Does Solaris Volume Manager support USB flash drives?

I would like to mirror or stripe across multiple USB flash drives on a Sun Blade 100 workstation running Solaris 10. Thanks! (6 Replies)
Discussion started by: yoda9999
6 Replies

6. Shell Programming and Scripting

script to detect a file from inserted usb and puts into a Variable

There is a same named log file that I have on my 2 different android phones. When I plug it into my computer, it appears in the media folder, For example the first android phone: /media/F6BA-0AF5/folder/A.log I want to put that into a variable to be manipulated.... (3 Replies)
Discussion started by: tobenguyen
3 Replies

7. What is on Your Mind?

Idea: selling Puppy Linux flash drives

What do you think of the idea of selling flash drives already prepared to boot Puppy Linux on PCs? (I still need to see if I can boot on Macs using online instructions I've found.) I know it's not too hard to prep your own flash drive, even if you have to buy one first, but just think about why... (8 Replies)
Discussion started by: MrMormon
8 Replies

8. Shell Programming and Scripting

Bash script to detect nonpingable hosts

I have a script to detect if a host is pingable or not. The problem is that I would like it to put the nonpingable hosts in one file and the pingable hosts in another. I have come up with this so far: for ip in `cat /tmp/testlist2`; do ping -c 3 $ip >/dev/null && echo "$ip is up" || echo "$ip... (5 Replies)
Discussion started by: newbie2010
5 Replies

9. Solaris

Anyway to do ufsdump os backup to usb drives

hi folks happy new year to all, I haven't been coming round for a long time. I've been googling about this can't seem to find any good examples, I need to know if it's possible to do a ufsdump os backup into a usb flash drive. Then what about in event of os recovery when we boot to single... (2 Replies)
Discussion started by: sparcguy
2 Replies
UMASS(4)						   BSD Kernel Interfaces Manual 						  UMASS(4)

NAME
umass -- USB Mass Storage Devices driver SYNOPSIS
To compile this driver into the kernel, place the following line in your kernel configuration file: device scbus device usb device umass Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): umass_load="YES" DESCRIPTION
The umass driver provides support for Mass Storage devices that attach to the USB port. To use the umass driver, usb(4) and one of uhci(4) or ohci(4) must be configured in the kernel. Additionally, since umass uses the SCSI sub- system and sometimes acts as a SCSI device, it requires da(4) and scbus(4) to be included in the kernel. HARDWARE
The umass driver supports USB Mass Storage devices, including: o ADTEC Stick Drive AD-UST32M, 64M, 128M, 256M o Denno FireWire/USB2 Removable 2.5-inch HDD Case MIFU-25CB20 o FujiFilm Zip USB Drive ZDR100 USB A o GREEN HOUSE USB Flash Memory "PicoDrive" GH-UFD32M, 64M, 128M o Huawei Mobile (SD slot) o IBM 32MB USB Memory Key (P/N 22P5296) o IBM 256MB USB Drive (MSYSTEM DiskOnKey2) o IBM ThinkPad USB Portable CD-ROM Drive (P/N 33L5151) o I-O DATA USB CD/CD-R/CD-RW/DVD-R/DVD-RW/DVD-RAM/DVD-ROM Drive DVR-iUH2 (CDROM, DVD-RAM only) o I-O DATA USB x6 CD-RW Drive CDRW-i64/USB (CDROM only) o I-O DATA USB/IEEE1394 Portable HD Drive HDP-i30P/CI, HDP-i40P/CI o Iomega USB Zip 100/250 drive o Iomega Zip750 USB2.0 drive o Keian USB1.1/2.0 3.5-inch HDD Case KU350A o Kurouto Shikou USB 2.5-inch HDD Case GAWAP2.5PS-USB2.0 o LaCie P3 HardDrive USB 200GB o Logitec LDR-H443U2 DVD-RAM/-R/+R/-RW/+RW drive o Logitec Mobile USB Memory LMC-256UD o Logitec USB1.1/2.0 HDD Unit SHD-E60U2 o Logitec USB Double-Speed Floppy Drive LFD-31U2 o Logitec USB/IEEE1394 DVD-RAM/R/RW Unit LDR-N21FU2 (CDROM only) o MELCO USB Flash Disk "ClipDrive", RUF-C32M, -C64M, -C128M, -C256M, -C512M o MELCO USB Flash Disk "PetitDrive", RUF-32M, -64M, -128M, -256Mm o MELCO USB2.0 Flash Disk "PetitDrive2", RUF-256M/U2, -512M/U2 o MELCO USB2.0 MO Drive MO-CH640U2 o Matshita CF-VFDU03 floppy drive o Merlin SM300 MP3/WMA Player (256Mb) o Microtech International, Inc. USB-SCSI-HD 50 USB to SCSI cable o Motorola E398 Mobile Phone (TransFlash memory card) o NOVAC USB2.0 2.5/3.5-inch HDD Case NV-HD351U o PNY Attache Flash Drive o Panasonic ("Matshita FDD CF-VFDU03") o Panasonic KXL-CB20AN Portable DVD-ROM/CD-R/RW o Panasonic KXL-CB35AN (DVD-ROM & CD-R/RW) o Panasonic USB2.0 Portable CD-RW Drive KXL-RW40AN (CDROM only) o Panasonic floppy drive o Qware BeatZkey! Pro o RATOC Systems USB2.0 Removable HDD Case U2-MDK1, U2-MDK1B o SanDisk SDDR-31 (Compact Flash) o SanDisk SDDR-75 (only Compact Flash port works) o Sitecom CN-300 MultiFlash (MMC/SD, SmartMedia, CF, MemoryStick) o Sony Portable CD-R/RW Drive CRX10U (CDROM only) o TEAC Portable USB CD-ROM Unit CD-110PU/210PU o Time DPA20B MP3 Player (1Gb) o Trek Thumbdrive 8MB o VAIO floppy drive (includes Y-E Data Flashbuster-U) o Y-E Data floppy drive (720/1.44/2.88Mb) Among the supported digital cameras are: o Asahi Optical (PENTAX) Optio 230 & 330 EXAMPLES
device umass device scbus device da device pass Add the umass driver to the kernel. camcontrol rescan 0 Rescan a Zip drive that was added after boot. The command above assumes that the Zip drive is on the first SCSI bus in the system. camcontrol rescan 0:0:0 camcontrol rescan 0:0:1 camcontrol rescan 0:0:2 camcontrol rescan 0:0:3 Rescan all slots on a multi-slot flash reader, where the slots map to separate LUNs on a single SCSI ID. Typically only the first slot will be enabled at boot time. Again, this assumes that the flash reader is the first SCSI bus in the system. bsdlabel -w da0 zip100 newfs da0c mount -t ufs /dev/da0c /mnt Write a disklabel to the Zip drive (see vpo(4) for the disktab(5) entry), creates the file system and mounts the new file system on /mnt. newfs_msdos /dev/da0 Create a new FAT type file system. Care should be taken not to run newfs(8) on devices that already contain data, as this will result in the information being lost. Many consumer devices such as digital cameras automatically create MS-DOS based file systems when storing information such as images and videos. These file systems can be accessed by specifying the file system type as msdos when using mount(8). SEE ALSO
ehci(4), ohci(4), uhci(4), usb(4), vpo(4), disktab(5), bsdlabel(8), camcontrol(8) AUTHORS
The umass driver was written by MAEKAWA Masahide <bishop@rr.iij4u.or.jp> and Nick Hibma <n_hibma@FreeBSD.org>. This manual page was written by Nick Hibma <n_hibma@FreeBSD.org>. BSD
October 22, 2009 BSD
All times are GMT -4. The time now is 10:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy