LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   What is going on with my USB stick? (https://www.linuxquestions.org/questions/linux-general-1/what-is-going-on-with-my-usb-stick-675680/)

tinker123 10-11-2008 10:03 AM

What is going on with my USB stick?
 
Hi;

I got a free 1 Gig USB stick as a promotional. I would like to install SystemRescueCD on it to make it into a "live usb stick". My computer is running Ubuntu 8.04.

I am having trouble detecting the device it is on and I think there may be partition or file system issues on the stick.

First issue: finding out what device the USB stick is:

running this command

Quote:

cat /proc/partitions
yields with the USB stick plugged in (& autodetected) and NOT plugged in to eliminate my computer's devices yields this:

Quote:

8 16 987135 sdb
8 17 979933 sdb1
I get 2 device names, but I only have one USB ( or any ) device plugged into my computer.

Why do I get two device names?

funning modprobe with the USB plugged in and automounted by Ubuntu yields nothing

Quote:

root@Wisdom:~# modprobe usb-storage
root@Wisdom:~#
runnng dmesg seems to indicate a problem, but I don't understand the output

Quote:

root@Wisdom:~# dmesg | tail -n 50
[ 8014.002943] sd 7:0:0:0: [sdb] Write Protect is off
[ 8014.002950] sd 7:0:0:0: [sdb] Mode Sense: 00 00 00 00
[ 8014.002953] sd 7:0:0:0: [sdb] Assuming drive cache: write through
[ 8014.006049] sd 7:0:0:0: [sdb] 1974271 512-byte hardware sectors (1011 MB)
[ 8014.006924] sd 7:0:0:0: [sdb] Write Protect is off
[ 8014.006929] sd 7:0:0:0: [sdb] Mode Sense: 00 00 00 00
[ 8014.006932] sd 7:0:0:0: [sdb] Assuming drive cache: write through
[ 8014.006939] sdb: sdb1
[ 8014.116805] sd 7:0:0:0: [sdb] Attached SCSI removable disk
[ 8014.116859] sd 7:0:0:0: Attached scsi generic sg3 type 0
[ 9316.958841] cdrom: This disc doesn't have any tracks I recognize!
[10381.662373] FAT: invalid media value (0xa5)
[10381.662381] VFS: Can't find a valid FAT filesystem on dev sdb.
[11014.741098] FAT: invalid media value (0xa5)
[11014.741106] VFS: Can't find a valid FAT filesystem on dev sdb.
[11288.298450] usb 4-2: USB disconnect, address 7
[11293.905004] usb 4-2: new high speed USB device using ehci_hcd and address 8
[11294.040007] usb 4-2: configuration #1 chosen from 1 choice
[11294.071004] scsi8 : SCSI emulation for USB Mass Storage devices
[11294.077307] usb-storage: device found at 8
[11294.077313] usb-storage: waiting for device to settle before scanning
[11299.074071] usb-storage: device scan complete
[11299.075331] scsi 8:0:0:0: Direct-Access USB 2.0 Flash Disk 0.00 PQ: 0 ANSI: 2
[11299.082540] sd 8:0:0:0: [sdc] 1974271 512-byte hardware sectors (1011 MB)
[11299.083541] sd 8:0:0:0: [sdc] Write Protect is off
[11299.083548] sd 8:0:0:0: [sdc] Mode Sense: 00 00 00 00
[11299.083551] sd 8:0:0:0: [sdc] Assuming drive cache: write through
[11299.086894] sd 8:0:0:0: [sdc] 1974271 512-byte hardware sectors (1011 MB)
[11299.087889] sd 8:0:0:0: [sdc] Write Protect is off
[11299.087894] sd 8:0:0:0: [sdc] Mode Sense: 00 00 00 00
[11299.087897] sd 8:0:0:0: [sdc] Assuming drive cache: write through
[11299.087904] sdc: sdc1
[11299.197969] sd 8:0:0:0: [sdc] Attached SCSI removable disk
[11299.198024] sd 8:0:0:0: Attached scsi generic sg3 type 0
[11300.740252] FAT: Directory bread(block 3858) failed
[11300.740267] FAT: Directory bread(block 3859) failed
[11300.740275] FAT: Directory bread(block 3860) failed
[11300.740282] FAT: Directory bread(block 3861) failed
[11300.740289] FAT: Directory bread(block 3862) failed
[11300.740296] FAT: Directory bread(block 3863) failed
[11300.740303] FAT: Directory bread(block 3864) failed
[11300.740310] FAT: Directory bread(block 3865) failed
[11300.740361] FAT: Directory bread(block 3858) failed
[11300.740368] FAT: Directory bread(block 3859) failed
[11300.740375] FAT: Directory bread(block 3860) failed
[11300.740382] FAT: Directory bread(block 3861) failed
[11300.740388] FAT: Directory bread(block 3862) failed
[11300.740395] FAT: Directory bread(block 3863) failed
[11300.740401] FAT: Directory bread(block 3864) failed
[11300.740408] FAT: Directory bread(block 3865) failed
root@Wisdom:~#


running fdisk -l on the first device sdb yields

Quote:

Disk /dev/sdb: 1010 MB, 1010826752 bytes
255 heads, 63 sectors/track, 122 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0007627f

Device Boot Start End Blocks Id System
/dev/sdb1 1 122 979933+ c W95 FAT32 (LBA)
root@Wisdom:~#
running fdisk -l on the second device yields listings that are almost identical ( the same device, two partitions? ) except no file system

Quote:

Disk /dev/sdb1: 1003 MB, 1003451904 bytes
255 heads, 63 sectors/track, 121 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
root@Wisdom:~#
To figure out which is my USB I replugged the stick in and let Ubuntu auto detect and mount it. I then put a file called Hello.txt on it and then I unmounted the USB stick.

Attempting to mount the first device, sdb yields an error message

Quote:

root@Wisdom:~# mount -t vfat /dev/sdb /mnt/usb
mount: wrong fs type, bad option, bad superblock on /dev/sdb,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

root@Wisdom:~#
Attempting to mount the second device, sdb1 is successful and it has my text file

Quote:

root@Wisdom:~# mount -t vfat /dev/sdb1 /mnt/usb
root@Wisdom:~# ls /mnt/usb
Hello.txt
root@Wisdom:~#
So, I come back to the question, why 2 device names when there is only one USB device plugged in?

Thanks much in advance for any info

Nightfish 10-11-2008 05:08 PM

kind of a long description of a problem for such a short answer.
Some usb sticks have a virtual partition where they try to emulate a floppy drive(a: or b:) where the security lock for the main partition is located and other things.
Try plugging it in to a windows computer (yea I know how that sounds) and see what happenes. If you get 2 drives, one beeing a floppy, you get your answer, if not... just format the whole thing.

Fedora Development

michaelk 10-11-2008 05:50 PM

There is nothing wrong.
sdb is your entire drive
sdb1 is the 1st partition. This contains the filesystem i.e data which is typically FAT32.

In a nutshell partitions divide a drive into pieces. Lots of information on partitions can be found by googling. A flash drive can be divided into 15 partitions (since it is uses the SCSI subsystem) with 4 being called primary. A primary partition can be designated as an extended partition which can be subdivided into 11 logical partitions. A data (primary,logical) partition can not be subdivided which is why nothing is displayed on the output of fdisk for /dev/sdb1. You can only mount a data filesystem which in your case is just sdb1.

If you look at the entire output of cat /proc/partitions you should see multiple partitions for the internal drive.

tinker123 10-12-2008 09:34 AM

Thanks for the answers guys.

Is there any way ( and do I want to ) to blow away the sdb1 partition?
I would like to use the whole USB stick for a liveUSB stick

tredegar 10-12-2008 01:25 PM

Quote:

Is there any way ( and do I want to ) to blow away the sdb1 partition?
As michaelk says, you have only the one partition /dev/sdb1
Use it as you wish.
If you "blow it away", you'll only have to re-create it again, one way or another.

trickykid 10-13-2008 10:01 AM

You can use dd to completely wipe the usb stick.

dd if=/dev/random of=/dev/sdb

Then use fdisk to re-create a primary partition on it.

Then you can use mkfs or the like to create the type of filesystem you want on it.

jschiwal 10-13-2008 10:16 AM

/dev/sdc is the device for the drive. /dev/sdc1 is the device for the partition on the device. Before the partition is the MBR. The partition probably starts at block 63. You can check this with "sudo /sbin/fdisk -lu /dev/sdc".

You can also get information on your pendrive with "udevinfo -q info -n /dev/sdc1". It will show what filesystem is on it, the label and UUID of the filesystem.

oskar 10-13-2008 02:08 PM

Quote:

Originally Posted by trickykid (Post 3308751)
You can use dd to completely wipe the usb stick.

dd if=/dev/random of=/dev/sdb

Then use fdisk to re-create a primary partition on it.

Then you can use mkfs or the like to create the type of filesystem you want on it.

Just want to caution anyone to double check if that is really the drive they want to wipe clean. Your usb drive will not always get mounted at /dev/sdb. If you, like me, sometimes have a problem with hal or your usb card where it disconnects and reconnects drives for no apparent reason, the device name might change without you doing anything.

I guess the most secure way would be to do this by UUID (potentially more confusing) or if possible by the devices individual name, if set. I did a quick search to see if I can find anything on this, but I can't. I'm kind of curious myself if and how that might be possible.

jschiwal 10-13-2008 06:46 PM

If there is a problem with the filesystem on the drive, you could simply format the filesystem on /dev/sdb1 (assuming that is what is used).
But having /dev/sdb and /dev/sdb1 for example is normal. There is nothing wrong with that.

I tried to use a promotional usb drive at work and windows didn't even recognize it. The same thing happened when a Windows server was being installed. One of the installers had files he needed to install copied to a pen drive he got from Disney at NAB. Windows didn't see it. I had a laptop that I had dual booting with Mandrake Linux. I rebooted into Mandrake, inserted the pendrive and sent the files over the network.

If this is a pendrive that has some promotional material on it, it may have some defects intentionally in the filesystem to make it harder to delete the promotional material. Some pendrives will simulate a hard disk for part of it. (U3 and others).

You can use "udevinfo -q env -n /dev/sdb1" to determine the filesystem, label and UUID. If you wanted to add an entry in /etc/fstab for the pendrive, you would want to use "LABEL=" or "UUID=" instead of the device name in the first field of the /etc/fstab entry. Also use the "noauto" option. This will enable you to mount it (manually) even if it gets a different device assigned to it the next time you plug it in.

Trickykid: You don't want to wipe a hard drive using /dev/random. You will run out of entropy very quickly. You can use /dev/urandom oro /dev/zero instead. A pen drive is flash based so you don't need to worry about previous material being extracted as can happen to one or two layers of magnetic material.


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