LinuxQuestions.org

LinuxQuestions.org (http://www.linuxquestions.org/questions/index.php)
-   Linux - Hardware (http://www.linuxquestions.org/questions/forumdisplay.php?f=18)
-   -   Addressing flash drive (http://www.linuxquestions.org/questions/showthread.php?t=4175451695)

waddles 02-25-2013 08:35 PM

Addressing flash drive
 
This is so aggravating to me because I think I should know this but ...
I acquired a 16GB SanDisk USB flash drive at the local Target.
I plugged it in and sure 'nuf' lsusb sees it:
Bus 001 Device 000: ID 0781:5530 SanDisk Corp. Cruzer
Its little light under the slider flashes. I tried fdisk /dev/sdc (have 2 hard drives) but that got me:
No such file or directory
How do I identify this so I can partition it to install some other Linuxes?
If left long enough, lsusb stops recognizing its existence. Is this a problem (light still flashes)? BTW using Slackware 13.37.

Shadow_7 02-25-2013 08:39 PM

$ cat /proc/partitions

Check dmesg to see if things went as expected when you inserted a new usb device. But it should list it in /proc/partitons. Although if you have multiple usb cards you can get a bit mixed up and might need to reference UUIDs and things like that. My USB flash mediums show up as /dev/hdc if I boot with them connected. Or as /dev/sdg if I plug them in after I boot.

EDDY1 02-25-2013 08:51 PM

My cruzer is listed under media
/media/usb0

Shadow_7 02-25-2013 09:02 PM

If it's mounted you can use mount without parms to list it's device name and it's mount point. And df can show device capacity and remaining space which can also help ID something that's already mounted.

$ mount
$ df

EDDY1 02-25-2013 09:53 PM

Quote:

Originally Posted by Shadow_7 (Post 4899749)
If it's mounted you can use mount without parms to list it's device name and it's mount point. And df can show device capacity and remaining space which can also help ID something that's already mounted.

$ mount
$ df

I was just letting OP know how my system mounts the cruzer usb drive

onebuck 02-25-2013 10:05 PM

Member Response
 
Hi,
Quote:

Originally Posted by waddles (Post 4899731)
This is so aggravating to me because I think I should know this but ...
I acquired a 16GB SanDisk USB flash drive at the local Target.
I plugged it in and sure 'nuf' lsusb sees it:
Bus 001 Device 000: ID 0781:5530 SanDisk Corp. Cruzer
Its little light under the slider flashes. I tried fdisk /dev/sdc (have 2 hard drives) but that got me:
No such file or directory
How do I identify this so I can partition it to install some other Linuxes?
If left long enough, lsusb stops recognizing its existence. Is this a problem (light still flashes)? BTW using Slackware 13.37.

From the console do 'fdisk -l';
Quote:

excerpt form 'man fdisk';
-l List the partition tables for the specified devices and then exit. If no devices are given, those mentioned in /proc/partitions (if that
exists) are used.
Quote:

excerpt from 'man lsusb';

lsusb - list USB devices

SYNOPSIS
lsusb [ options ]

DESCRIPTION
lsusb is a utility for displaying information about USB buses in the system and the devices connected to them.

OPTIONS
-v, --verbose
Tells lsusb to be verbose and display detailed information about the devices shown. This includes configuration descriptors for the device's
current speed. Class descriptors will be shown, when available, for USB device classes including hub, audio, HID, communications, and chipcard.

-s [[bus]:][devnum]
Show only devices in specified bus and/or devnum. Both ID's are given in decimal and may be omitted.

-d [vendor]:[product]
Show only devices with the specified vendor and product ID. Both ID's are given in hexadecimal.

-D device
Do not scan the /dev/bus/usb directory, instead display only information about the device whose device file is given. The device file should be
something like /dev/bus/usb/001/001. This option displays detailed information like the v option; you must be root to do this.

-t Tells lsusb to dump the physical USB device hierarchy as a tree. This overrides the v option.

-V, --version
Print version information on standard output, then exit successfully.
Sample;
Code:

# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 0408:2fb1 Quanta Computer, Inc.
Bus 002 Device 007: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 002 Device 004: ID 8086:0189 Intel Corp.
Bus 002 Device 008: ID 045e:0745 Microsoft Corp. Nano Transceiver v1.0 for Bluetooth
Bus 003 Device 002: ID 1058:0740 Western Digital Technologies, Inc. My Passport 1TB

Code:

# lsusb -t
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
        |__ Port 2: Dev 7, If 0, Class=Hub, Driver=hub/4p, 480M
            |__ Port 2: Dev 8, If 0, Class=Human Interface Device, Driver=usbhid, 12M
            |__ Port 2: Dev 8, If 1, Class=Human Interface Device, Driver=usbhid, 12M
            |__ Port 2: Dev 8, If 2, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 5: Dev 4, If 0, Class=Wireless, Driver=btusb, 12M
        |__ Port 5: Dev 4, If 1, Class=Wireless, Driver=btusb, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
        |__ Port 4: Dev 3, If 0, Class=Video, Driver=uvcvideo, 480M
        |__ Port 4: Dev 3, If 1, Class=Video, Driver=uvcvideo, 480M
        |__ Port 4: Dev 3, If 2, Class=Video, Driver=, 480M

If you use 'lsusb -v' then a very verbose output will be provided. Try it! :)

waddles 02-26-2013 03:35 AM

Addressing flash drive
 
Thanks for all the input!!
Does anyone suspect the device is failing after reading below?
When plugged in there is no initial light flashing indication on the flash drive and no indication from lsusb.
When light flashes, approx. 1/sec, lsusb shows that it is there:
Code:

Bus 001 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 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 0c45:60fc Microdia PC Camera with Mic (SN9C105)
Bus 001 Device 018: ID 0781:5530 SanDisk Corp. Cruzer

I am getting no indication of positive response from mount or df as regarding the USB device.
ls /media/* shows devices 0 and 1 for:cdrecorder, cdrom, dvd, floppy, memory, hd, and zip.
cat /proc/partitions does not show the device.
fdisk -l shows only my hard drives sda and sdb
and when I use that command the light in the flash drive begins to rapidly flash. I unplugged it.

This motherboard KT4V-L is several years old and I do not have a USB drive specifically setup for the BIOS. Could that be the reason it is not responding?
I have done everything the manual says to do but have not plugged in the flash drive when doing the setup which is possibly why it does not provide it as an option for booting from. I will try this.

waddles 02-26-2013 04:06 AM

I opened my MSI manual on the motherboard and rechecked my configuration. Even with the flash drive installed the BIOS did NOT show any indication of seeing the flash drive as a bootable item. The manual shows several expected options USB FDD, USB CDROM, USB hdd, or USB RMD-FDD. The only bootable devices are currently Floppy, Cdrom, and hard drive.
The "USB Legacy Support" is set to All Device as required and "Try Other Devices" to YES as described.
I can live with BIOS not having USB as a bootable device by using the PLOP script or something like that but have misgivings about this flash drive with this system when after about 3 min its light goes out and is not recognized by lsusb.

EDDY1 02-26-2013 04:23 AM

The floppy would be under hdd in bios?
In bios under boot there should be a +sign next to hdd, select it & it'll expand. Move cruzer to top of list under hdd's in boot section.

273 02-26-2013 08:37 AM

In my experience also USB drives tend to show up under hard Drives in BIOS. This causes me a lot of annoyance because it means changing the BIOS hard drive order in order to boot from USB every time I want to try a live USB out but seems to be the way it's done nowadays.

Shadow_7 02-26-2013 10:43 AM

F12 spamming is mostly the way to get to the boot order options on newer machines. But it can be ESC, F10 and lots of other things too. Depending on brand and age of the machine. Most of the time I just put an entry for the USB stick in the existing bootloader of the computers main HDD.

# nano /etc/grub.d/40_custom
# update-grub

Be sure to use the UUIDs for the partition, and the same in the /etc/fstab of the linux install it applies to.

It should contain something like this in 40_custom for the grub to boot the device.

Code:

menuentry 'Debian Sid i386 - PNY' --class debian --class gnu-linux --class gnu --class os {
        load_video
        insmod gzio
        insmod uhci
        insmod ohci
        insmod usb
        insmod part_msdos
        insmod ext2
###        set root='(hd0,msdos4)'
        search --no-floppy --fs-uuid --set=root ba55c1ef-0b0e-c0da-5010-5ca1ed121234
        echo        'Loading Linux PNY 32GB USB stick...'
        linux        /boot/vmlinuz-3.2.0-4-686-pae root=UUID=ba55c1ef-0b0e-c0da-5010-5ca1ed121234 ro
        echo        'Loading initial ramdisk ...'
        initrd        /boot/initrd.img-3.2.0-4-686-pae
}

Use blkid on the partition in question to get the UUID. When you plug the device in, it should be listed in /proc/partitions for your running linux. If you boot a grub boot cd, you have to type most of those lines from 40_custom in at grubs command line to get it to boot, so you technically don't have to reconfigure grub, just press "c" for command mode. And type the lines between { and } followed by boot.

You can't really boot a usb stick unless you've installed a bootloader onto that stick. At least not via the bios options.

$ cat /proc/partitions
# blkid /dev/sdg1

Or whatever applies as the /dev/ name for the place in question. Automounting only happens with a system configured to do that. Some distros have that installed and configured by default and others do not. So you can't just have an expectation that it's automatic.

Shadow_7 02-26-2013 10:58 AM

Some really old machines do not support booting usb. But you can boot grub from a cdrom and then jump to the grub on the stick.

$ grub-mkrescue -o grub-el-torito.iso
$ k3b grub-el-torito.iso

Since there's no menu setup with that type of image you'll default to the grub commandline

grub> insmod uhci
grub> insmod ohci
grub> insmod usb
grub> ls

Your grub name of the partition should be one of those listed. If all is going well anyway.

grub> insmod part_msdos
grub> insmod ext2
grub> configfile (usb0a,msdos2)/boot/grub/grub.cfg

Where (usb0a,msdos2) is the grub name of the stick I boot my antique laptop with. And that launches the grub on that stick and I can use it's menu at that point. Otherwise you have to type in the UUID stuff which is a lot more typing.

TobiSGD 02-26-2013 11:25 AM

BIOS settings should not prevent the Flash drive from being seen (unless you totally disabled USB in the BIOS, which can't be the case, since it shows up in lsusb).
Unplug the device, launch the command
Code:

tail -f /var/log/messages
and plug the device into the machine again. Post here which output is added to the tail command, so that we can see what actually is happening on your machine.

waddles 02-26-2013 11:26 PM

Addressing flash drive
 
tail -f /var/log/messages after disconnecting flash drive:
Code:

tail -f /var/log/messages
Feb 26 21:20:10 polaris kernel: [ 2536.256767] scsi 9:0:0:0: Direct-Access    SanDisk  Cruzer          1.26 PQ: 0 ANSI: 5
Feb 26 21:20:10 polaris kernel: [ 2536.257149] sd 9:0:0:0: Attached scsi generic sg4 type 0
Feb 26 21:20:10 polaris kernel: [ 2536.262103] sd 9:0:0:0: [sdc] 31266816 512-byte logical blocks: (16.0 GB/14.9 GiB)
Feb 26 21:20:10 polaris kernel: [ 2536.264709] sd 9:0:0:0: [sdc] Write Protect is off
Feb 26 21:20:10 polaris kernel: [ 2536.276221]  sdc: sdc1
Feb 26 21:20:10 polaris kernel: [ 2536.278134] sd 9:0:0:0: [sdc] Attached SCSI removable disk
Feb 26 21:20:13 polaris kernel: [ 2539.483303] usb 1-6: USB disconnect, address 25
Feb 26 21:20:13 polaris kernel: [ 2539.487356] scsi 9:0:0:0: [sdc] Unhandled error code
Feb 26 21:20:13 polaris kernel: [ 2539.487362] scsi 9:0:0:0: [sdc]  Result: hostbyte=0x07 driverbyte=0x00
Feb 26 21:20:13 polaris kernel: [ 2539.487367] scsi 9:0:0:0: [sdc] CDB: cdb[0]=0x28: 28 00 00 00 00 40 00 00 08 00

Now reconnecting:
Code:

Feb 26 21:22:18 polaris kernel: [ 2664.071319] usb 1-6: new high speed USB device using ehci_hcd and address 26
Feb 26 21:22:18 polaris kernel: [ 2664.187258] usb 1-6: New USB device found, idVendor=0781, idProduct=5530
Feb 26 21:22:18 polaris kernel: [ 2664.187265] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Feb 26 21:22:18 polaris kernel: [ 2664.187270] usb 1-6: Product: Cruzer
Feb 26 21:22:18 polaris kernel: [ 2664.187273] usb 1-6: Manufacturer: SanDisk
Feb 26 21:22:18 polaris kernel: [ 2664.187275] usb 1-6: SerialNumber: 20060775120CCBC0F3E6
Feb 26 21:22:18 polaris kernel: [ 2664.190939] scsi10 : usb-storage 1-6:1.0
Feb 26 21:22:29 polaris kernel: [ 2675.199195] scsi 10:0:0:0: Direct-Access    SanDisk  Cruzer          1.26 PQ: 0 ANSI: 5
Feb 26 21:22:29 polaris kernel: [ 2675.199560] sd 10:0:0:0: Attached scsi generic sg4 type 0
Feb 26 21:22:29 polaris kernel: [ 2675.207144] sd 10:0:0:0: [sdc] 31266816 512-byte logical blocks: (16.0 GB/14.9 GiB)
Feb 26 21:22:29 polaris kernel: [ 2675.209176] sd 10:0:0:0: [sdc] Write Protect is off
Feb 26 21:22:29 polaris kernel: [ 2675.218672]  sdc: sdc1
Feb 26 21:22:29 polaris kernel: [ 2675.220706] sd 10:0:0:0: [sdc] Attached SCSI removable disk

Looks like my device is sdc and only 1 partition.
Would someone explain why fdisk -l did not show that drive?
Also why is the flash drive's lamp blinking on/off rapidly?

TobiSGD 02-26-2013 11:34 PM

Have you run the fdisk command as root (or with sudo on distros that use sudo)?
The blinking occurs usually when data on the device is read or written, for example by an indexing program running in the background.


All times are GMT -5. The time now is 11:04 PM.