# USB stick wrong size after dd

## 1clue

Hi,

In an attempt to make a usb stick bootable, I used dd to write an iso image to the thumb drive.  Yes it's stupid.

The image didn't work and isn't mountable by any computer I have, but not only that the thumb drive says it's maximum size is the size of the iso, not 32g anymore.

Does anybody know how to repair this using Linux tools?  The stuff on the net i found refers to windows apps.

Thanks.

----------

## cach0rr0

tried just nuking the partition table with fdisk?

----------

## 1clue

Yes.

Fdisk won't write a partition table, nor will gparted or testdisk or disk utility on the Mac.

I also tried sudo dd of=/dev/sde if=/dev/zero bs=512 count=4 and that still doesn't do anything.

I tried changing disk geometry (cylinders, tracks sectors) and it won't write that either.

If there's a read-only switch on this thing i can't see it and haven't found it in almost a year of using this thing.

----------

## The Doctor

Have you tried just creating a file system on it?

----------

## creaker

It is normal for usb stick that was written by dd.

The size reduced to iso size because of usb stick seems for system like a cd or dvd.

When I need to get back my stick, I using GParted instead of fdisk. Fdisk can't recreate a partition table.

Also usb stick that was written with dd may be unbootable. It depends on iso type (hybrid or not)

You can write iso to stick with Unetbootin tool.

----------

## frostschutz

You could be a bit more generous with dd, i.e. zero the first 8MiB instead of just a couple bytes.

dd if=/dev/zero of=/dev/usbstick bs=1M count=8

Verify that this data is actually written to the stick

dd if=/dev/zero bs=1M count=8 | md5sum

dd if=/dev/usbstick bs=1M count=8 | md5sum

should be identical (in this example 96995b58d4cbf6aaa9041b4f00c7f6ae)

disconnect the stick, reconnect the stick

If it still shows old capacity, the stick is probably defective. Either that or it's not a plain simple stupid storage device. Which brand/model?

----------

## 1clue

The stick is an a-data n005 32g usb3 stick.

I copied the iso over with dd to the raw device:  /dev/sde rather than /dev/sde1 for example. I have been unable to make a partition after the 4g one because all the disk utilities think there's nothing out there.  And somehow it magically turned into 4.00g rather than the size of the iso.

I did all this stuff as root. There is no partition, just a blank 4g space. I can't create a partition at all because there is no partition table. The various utilities fail in different ways when I try to write a partition table. testdisk lets me 'create' one and even change the disk geometry so it looks like 32g again, but when I power the device down and remove/reinstall it, nothing was written at all.

The data on the drive was never an issue. It's long gone or useless by now. The drive on the other hand is usb3 64g and it cost a significant amount of money.

----------

## creaker

If all the linux tools (fdisk, parted and so on) failed, you can try two things. The first one is a HP Low Level Format Tool. If HP Tool doesn't helps, you can search over manufacturer's site for special recovery tool.

But these programs doesn't works under linux.

Also if you still trust dd you can just copy a hard drive to stick. At least it writes a partition table to the stick:

dd if=/dev/youharddrive of=/dev/yourusbstick

without device number and count limit.

But I'm not sure it is a good idea   :Confused: 

----------

## frostschutz

 *1clue wrote:*   

> The various utilities fail in different ways when I try to write a partition table.

 

There's really nothing special about writing a partition table; it's just a few bytes of data in the first sector. If that fails then not many things come to mind, apart from faulty drive.

Try badblocks -b 4096 -c 1024 /dev/thingy

----------

## chiefbag

```
emerge parted
```

Run parted where XYZ is your usb device

```
parted /dev/XYZ
```

Run the print command to list partitions

```
(parted) print
```

You will see something like the following

```
Number  Start   End    Size   Type     File system  Flags

 1      32.3kB  189GB  189GB  primary  ext3

 2      189GB   320GB  131GB  primary  ext3
```

To REMOVE from eg partation 1

```
(parted) rm 1
```

To exit parted

```
(parted)  exit 
```

Now just create a new partation with cfdisk

```
cfdisk /dev/XYZ
```

----------

## chadfurman

So, where gparted failed parted succeeded.  Opening up parted on /dev/sdd, running mklabel msdos, then "quit", caused gparted to now be able to create partitions.

----------

