Error formating a USB stick

The following are the details of the USB through ‘parted’:


# parted /dev/sdb
GNU Parted 2.4
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) print                                                            
Model: LEXAR JUMPDRIVE SECURE (scsi)
Disk /dev/sdb: 518MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End    Size    Type     File system  Flags
 1      32.3kB  411MB  411MB   primary  fat16        type=06
 2      411MB   510MB  98.7MB  primary  fat16        hidden, type=16

I want to remove the hidden flag, remove the two partitions and create a new, single partition. If I try any of these, or attempt to rewrite the partition table, etc, it just gives the error:

Error: Input/output error during write on /dev/sdb

Some history on this device:
The second partition used to be an encrypted partition that I had messed up as a little kid. I do not remember what I did to it though. I am attempting to recover it now.

Can someone help me out?

Thanks!

You do not tell what you exactly do when you get that error, but try first something simple like

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

If this gives no error, it may have removed the problem, thus then try to partition again.

Almost everything I try; attempting to delete or modify those partitions gives that error. For example:

(parted) set 2 hidden                                                     
New state?  on/[off]? off                                                 
Error: Input/output error during write on /dev/sdb

(parted) rm 2
Error: Input/output error during write on /dev/sdb  

(parted) rm 1                                                             
Error: Input/output error during write on /dev/sdb    

etc

this gives:

$ sudo dd if=/dev/zero of=/dev/sdb bs=1024 count=1
1+0 records in
1+0 records out
1024 bytes (1.0 kB) copied, 0.0126133 s, 81.2 kB/s

but nothing has changed. All the above commands still give the same error.

I tired this; don’t know if it will help:

$ sudo fsck /dev/sdb1
fsck from util-linux 2.20.1
fsck.fat 3.0.26 (2014-03-07)
FATs differ - using first FAT.
Leaving filesystem unchanged.
/dev/sdb1: 0 files, 0/50171 clusters

$ sudo fsck /dev/sdb2
fsck from util-linux 2.20.1
fsck.fat 3.0.26 (2014-03-07)
/dev/sdb2: 0 files, 0/48092 clusters

While I am not sure about what is wrong, I am also not sure about what you are doing.
After the dd command, the partition table on the device is destroyed. Thus I do not understand how you can try to do an fsck on any file system on any partition.

Please show

su -c 'fdisk -l'

BTW, be VERY, very sure that all the time you are executing these commands, the device is sdb. Else you might destroy some other disk.

On 2015-09-14 10:56, vishnugb wrote:

>
> Code:
> --------------------
> $ sudo dd if=/dev/zero of=/dev/sdb bs=1024 count=1
> 1+0 records in
> 1+0 records out
> 1024 bytes (1.0 kB) copied, 0.0126133 s, 81.2 kB/s
> --------------------

Repeat without “count”. And do make real sure it is sdb.

Being a 0.5 GB “disk”, it must be quite old, and it may be broken.


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

By the looks of it, the dd command did not destroy the partition table. I am trying to recover the second, currently un-usable partition on the USB.

$ su -c 'fdisk -l'
.
.
.
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.

Disk /dev/sdb: 517 MB, 517521408 bytes
255 heads, 63 sectors/track, 62 cylinders, total 1010784 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x095ee605

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63      803249      401593+   6  FAT16
/dev/sdb2          803250      996029       96390   16  Hidden FAT16

Looks like it worked this time. Why? What does the ‘count’ option do?

$ sudo dd if=/dev/zero of=/dev/sdb bs=1024
dd: error writing ‘/dev/sdb’: No space left on device
505393+0 records in
505392+0 records out
517521408 bytes (518 MB) copied, 149.614 s, 3.5 MB/s

Now, when I check:

(parted) print                                                            
Model: LEXAR JUMPDRIVE SECURE (scsi)
Disk /dev/sdb: 518MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End    Size    Type     File system  Flags
 1      32.3kB  411MB  411MB   primary  fat16
 2      411MB   510MB  98.7MB  primary               hidden

It is the same.

Yes, it is very old. But the first partition is still usable, and I don’t think the second has any hardware-level encryption, so it must be software-level, and so, maybe, removable?

What do I do now?

You might check
https://en.opensuse.org/SDB:Live_USB_stick#How_to_recover_the_USB_stick_for_.22normal.22_use_again

Well, you are supposed to check what any command, you are asked to run, will do to your system. I do not know of anybody here ever suggesting a destructive command on purpose, but typos are possible. And there should also be a learning moment, Thus when anybody suggests to do a dd command, the minimum you could do is

man dd

On 2015-09-15 06:36, vishnugb wrote:
> WARNING: GPT (GUID Partition Table) detected on ‘/dev/sdb’! The util fdisk doesn’t support GPT. Use GNU Parted.

This is very curious, on a small and perhaps old stick. Maybe it is not
that old.

If there is a GPT and you write to the MBR, it should not have the
effect you think. I suggest you read on GPT on the wikipedia.

On 2015-09-15 06:56, vishnugb wrote:

> Model: LEXAR JUMPDRIVE SECURE (scsi)

> Yes, it is very old. But the first partition is still usable, and I
> don’t think the second has any hardware-level encryption, so it must be
> software-level, and so, maybe, removable?

Not if it is in the firmware.

Guessing at the model name of your device, I think it is somekind of
firmware protection, designed for Windows. The software appears on the
second partition, the data on the first. And the second partition is
protected by the firmware, so nothing will touch it - unless the
manufacturer provides a software way to do it.

That’s my guess.

Another one is that it has a write protect switch, hardware or software.
Google that model.

> What do I do now?

Forget it. :slight_smile:

0.5 GB is not worth it, anyway…


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))