Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
USB stick wrong size after dd
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
1clue
Veteran
Veteran


Joined: 05 Feb 2006
Posts: 1198

PostPosted: Thu Jul 26, 2012 3:46 am    Post subject: USB stick wrong size after dd Reply with quote

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.
Back to top
View user's profile Send private message
cach0rr0
Moderator
Moderator


Joined: 13 Nov 2008
Posts: 4121
Location: Houston, Republic of Texas

PostPosted: Thu Jul 26, 2012 5:54 am    Post subject: Reply with quote

tried just nuking the partition table with fdisk?
_________________
Lost configuring your system?
dump lspci -n here | see Pappy's guide | Link Stash
Back to top
View user's profile Send private message
1clue
Veteran
Veteran


Joined: 05 Feb 2006
Posts: 1198

PostPosted: Thu Jul 26, 2012 6:01 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
The Doctor
Veteran
Veteran


Joined: 27 Jul 2010
Posts: 1266

PostPosted: Thu Jul 26, 2012 6:08 am    Post subject: Reply with quote

Have you tried just creating a file system on it?
_________________
First things first, but not necessarily in that order.
Back to top
View user's profile Send private message
creaker
Guru
Guru


Joined: 14 Jul 2012
Posts: 480

PostPosted: Thu Jul 26, 2012 9:04 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2424
Location: Germany

PostPosted: Thu Jul 26, 2012 11:15 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
1clue
Veteran
Veteran


Joined: 05 Feb 2006
Posts: 1198

PostPosted: Thu Jul 26, 2012 12:21 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
creaker
Guru
Guru


Joined: 14 Jul 2012
Posts: 480

PostPosted: Thu Jul 26, 2012 1:06 pm    Post subject: Reply with quote

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 :?
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2424
Location: Germany

PostPosted: Thu Jul 26, 2012 8:26 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
chiefbag
Guru
Guru


Joined: 01 Oct 2010
Posts: 440
Location: The Kingdom of Kerry

PostPosted: Fri Jul 27, 2012 3:55 pm    Post subject: Reply with quote

Code:
emerge parted


Run parted where XYZ is your usb device

Code:
parted /dev/XYZ


Run the print command to list partitions

Code:
(parted) print


You will see something like the following

Code:
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

Code:
(parted) rm 1


To exit parted
Code:
(parted)  exit


Now just create a new partation with cfdisk

Code:
cfdisk /dev/XYZ

_________________
A place for useful technical information
Back to top
View user's profile Send private message
chadfurman
n00b
n00b


Joined: 21 Feb 2013
Posts: 1

PostPosted: Thu Feb 21, 2013 7:55 am    Post subject: mklabel Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum