LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (http://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Cannot write to USB flash drive (http://www.linuxquestions.org/questions/linux-hardware-18/cannot-write-to-usb-flash-drive-610442/)

leisa 01-01-2008 05:36 PM

Cannot write to USB flash drive
 
This isn't a Linux issue as much as one of a hardware nature but I am looking for a Linux-related solution (I don't run Windows at all).

I have a USB flash drive that can't be written to. I can mount the drive (apparently) and I can copy the one and only file on it but I can't write to it at all. This includes repartitioning or reformatting.

fdisk -l output is very strange:

Quote:

leisa@laptop:~$ fdisk -l /dev/sdb

Disk /dev/sdb: 4288 MB, 4288676352 bytes
132 heads, 62 sectors/track, 1023 cylinders
Units = cylinders of 8184 * 512 = 4190208 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/sdb1 ? 95081 234561 570754815+ 72 Unknown
Partition 1 has different physical/logical beginnings (non-Linux?):
phys=(357, 116, 40) logical=(95080, 19, 11)
Partition 1 has different physical/logical endings:
phys=(357, 32, 45) logical=(234560, 104, 51)
Partition 1 does not end on cylinder boundary.
/dev/sdb2 ? 20613 257175 968014120 65 Novell Netware 386
Partition 2 has different physical/logical beginnings (non-Linux?):
phys=(288, 115, 43) logical=(20612, 14, 47)
Partition 2 has different physical/logical endings:
phys=(367, 114, 50) logical=(257174, 92, 42)
Partition 2 does not end on cylinder boundary.
/dev/sdb3 ? 228481 465043 968014096 79 Unknown
Partition 3 has different physical/logical beginnings (non-Linux?):
phys=(366, 32, 33) logical=(228480, 18, 30)
Partition 3 has different physical/logical endings:
phys=(357, 32, 43) logical=(465042, 95, 39)
Partition 3 does not end on cylinder boundary.
/dev/sdb4 ? 352601 352608 27749+ d Unknown
Partition 4 has different physical/logical beginnings (non-Linux?):
phys=(372, 97, 50) logical=(352600, 44, 25)
Partition 4 has different physical/logical endings:
phys=(0, 10, 0) logical=(352607, 15, 33)
Partition 4 does not end on cylinder boundary.

Partition table entries are not in disk order
leisa@laptop:~$

I don't care about the data on this device. I only want to be able to use the damned thing.

Any suggestions?

David the H. 01-01-2008 06:42 PM

1. Try running dosfsck on it.

2. Reformat it with mkdosfs.

leisa 01-01-2008 06:55 PM

Quote:

Originally Posted by David the H. (Post 3008015)
1. Try running dosfsck on it.

Tried that yesterday. While it found all sorts of errors, it refused to correct them.

Quote:

2. Reformat it with mkdosfs.
Hadn't tried that as I didn't expect it to work. Tried it just now as you suggested...and it didn't do a thing.

Edit: Just to add, mkdosfs believed that the device was full. Actually, there is one 30MB zip file on this 4GB drive.

David the H. 01-01-2008 07:18 PM

Then it's probably a corrupted partition table or something. Try recreating the partition with fdisk (or cfdisk, etc), then reformatting. You might also try zeroing the thing out with dd first.

If that doesn't work, it could be a hardware problem.

leisa 01-01-2008 07:42 PM

Thanks David.

Unfortunately, fdisk (and cfdisk) won't write anything to this thing. In the case of cfdisk:

Quote:

FATAL ERROR: Bad primary partition 0: Partition begins after end-of-disk
Press any key to exit cfdisk

I'ts looking like it's probably a hardware issue. Too bad. This thing is only about 3 weeks old.

I occasionally use these flash drives for temporary backup purposes. Now I'm not so sure that they're reliable enough even for that.

Oh well. Thanks to all for the help. I suspect I'll just put it out of its misery. Any suggestions? Boot? Hammer? 12 gauge?

David the H. 01-01-2008 09:29 PM

I mentioned trying to zero the thing out using the dd command; that is, erase the device by filling it up with zero-bits. It's probably only necessary to wipe out the partition table that lies in the first sector or so.

dd if=/dev/zero of=/dev/sdb bs=512 count=1

Be very careful you get the right device name, dd isn't nicknamed "data destroyer" for nothing. I know from personal experience.

Once you have the device zeroed, you should be able to go back in and repartition it. Assuming it's not a hardware problem, of course.

As for your comment about using the drive for backup, I'm sure they're generally quite reliable. But the FAT filesystem isn't. If you plan only to use the drive as a linux backup device, you might consider formatting it in ext3 instead.

Also be aware that flash memory devices are capable of only a limited number of write-erase cycles before the memory blocks in them start to become unusable, so try not to stress them too much.

leisa 01-01-2008 10:30 PM

Quote:

Originally Posted by David the H. (Post 3008111)
I mentioned trying to zero the thing out using the dd command

Nope. DD didn't work...but you DID give me an idea using another method of zeroing out the drive.

I'll let you know (it's taking quite a while).

leisa 01-02-2008 09:30 AM

Update:

This device is dead. Nothing will write to it. 'dd' command did nothing, 'badblocks' actually appeared to be doing something as it went on and on for about 11 hours but did nothing except to give my cpu fan a workout.

I'm giving up!

The end. Thanks anyway, DtH.


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