LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   can't recover USB pendrive after 'dd' (https://www.linuxquestions.org/questions/linux-hardware-18/cant-recover-usb-pendrive-after-dd-4175439370/)

r@fitiiixxx 11-29-2012 05:26 PM

can't recover USB pendrive after 'dd'
 
Hello,

I recently used my 16Gb Verbatim STORE N GO pendrive to create an usb-install image of Arch. After looking at the wiki i tried for the first time to create an image with dd as described in there
Quote:

On GNU/Linux

Overwrite the USB drive
Warning: This will irrevocably destroy all data on /dev/sdx.
Note: Check with lsblk that the USB device is not mounted, and use /dev/sdx instead of /dev/sdx1. These are very common mistakes!
# dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx
After that i wanted to recover my pendrive but instead of following the wiki i did something stupid and formated the whole pendrive.
I restored a fully functional pendrive, but with only 400MB of capacity. So i reformated with Gparted and it gave me an error that i couldn't save in a .txt file as i was on a liveCD Ubuntu 10.04.
Next thing i tried is the wiki solution to recover the pendrive
Quote:

How to restore the USB drive
Because the ISO image is a hybrid which can either be burned to a disc or directly written to a USB drive, it doesn't include a standard partition table.
After you install Arch Linux and you're done with the USB drive, you should zero out its first 512 bytes (meaning the boot code from the MBR and the non-standard partition table) if you want to restore it to full capacity:
# dd count=1 bs=512 if=/dev/zero of=/dev/sdx
Then create a new partition table (e.g. "msdos") and filesystem (e.g. EXT4, FAT32) using gparted
The thing is that now whenever i try to format it with Gparted or with terminal comands i can't fix it, it drops me an error about
Quote:

Error in / out during read /dev/sdb
and i can't fix my pendrive.
I need help to retrieve my pendrive back.

PS: ask me any questions you might have.

jefro 11-29-2012 08:38 PM

If you can't create a partition with fdisk then can you see any info on the drive or select it at all in fdisk?

The OEM may offer a program so see their site.


I am not sure this is for flash drives. "# dd count=1 bs=512 if=/dev/zero of=/dev/sdx" Looks more like a usb hard drive.

r@fitiiixxx 11-29-2012 08:51 PM

usb pendrive = usb drive, it is a memory stick, not a flash card.
Verbatim STORE N GO
Also this is what fdisk -l gives me:
Code:

$ sudo fdisk -l
[sudo] password for nicolas:

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Identificador del disco: 0x00076938

Disposit. Inicio    Comienzo      Fin      Bloques  Id  Sistema
/dev/sda1  *          63      385559      192748+  83  Linux
Partition 1 does not start on physical sector boundary.
/dev/sda2          385560    10153079    4883760  82  Linux swap / Solaris
/dev/sda3        10153080  650150549  319998735  83  Linux
/dev/sda4      650150550  1953525167  651687309  83  Linux
Partition 4 does not start on physical sector boundary.

it's on spanish but the info is well known. Haven't used fdisk ever. I allways use graphical solutions for these problems as i'm not that experienced with sh.

TobiSGD 11-29-2012 09:05 PM

It is missing the flash drive in that output, did you plug it in before running the fdisk command?

r@fitiiixxx 11-30-2012 11:01 AM

Yes i did, before running fdisk. That's the problem, i don't even know what's happening to it, first i need to figure out what is going on with it, i know is not wroken because it's almost new and until this, it was working like a charm.
I will never ever use again dd command to create an OS image :(
hope i can bring it back...

jefro 11-30-2012 04:42 PM

Plug in flash drive and use lsusb command maybe?

rknichols 11-30-2012 06:25 PM

What messages appear in /var/log/messages when you plug in the drive? Frankly, it sounds like the drive just decided to die. That wouldn't be due to any fault of dd -- that just happened to be what you were doing when the drive died.

TobiSGD 11-30-2012 07:52 PM

Quote:

Originally Posted by r@fitiiixxx (Post 4840288)
i know is not wroken because it's almost new and until this, it was working like a charm.

New hardware is not a guarantee that it can't break and many electronic devices tend to break suddenly without any warnings.

Quote:

I will never ever use again dd command to create an OS image
I would consider that to be pure coincidence. I do things like that very often and never had a breakage that was caused by using dd. dd is doing nothing more than writing data to the device, there is no magical "break the device"-function.

Quote:

hope i can bring it back...
If not you can actually be happy that it was a new device and you still have warranty on it. Back to the vendor and get a new one.

r@fitiiixxx 11-30-2012 11:11 PM

Quote:

Originally Posted by TobiSGD (Post 4840525)
New hardware is not a guarantee that it can't break and many electronic devices tend to break suddenly without any warnings.
...
I would consider that to be pure coincidence. I do things like that very often and never had a breakage that was caused by using dd. dd is doing nothing more than writing data to the device, there is no magical "break the device"-function.
...
If not you can actually be happy that it was a new device and you still have warranty on it. Back to the vendor and get a new one.

True, new hardware could have factory faults, not this one! i just fixed!
it wasn't a coincidence, i wroke the whole mbr table, using dd did not the trick, problem was that Arch is a dual iso with 32 and 64 bit iso inside the same boot image, so in order to recover the partition tables (because of some weird stuff arch does to pendrives) i had to follow exact same steps in that wiki, which i did not, because i thought that gparted was more suitable for me. WRONG!
I couldn't be happy if the device was new, as in my country is really hard to make validation of my warranty, since all the products are imported and most vendors will try every excuse they get in order to invalidate warranties.

@jefro:
lsusb showed me a Verbatim hard disk connected to BUS 001 (usb 2.0) so it's ok.


@rknichols:
I can't check /var/log/messages because...
Code:

$ ls /var/log/
Xorg.0.log      Xorg.2.log      btmp    lastlog  pacman.log
Xorg.0.log.old  Xorg.2.log.old  faillog  libvirt  pm-powersave.log
Xorg.1.log      Xorg.3.log      gdm      ntp.log  wtmp
Xorg.1.log.old  Xorg.4.log      journal  old

._.

now i'm going to explain, how i fixed it.

[SOLUTION]
Quote:

Originally Posted by Hinnerk van Bruinehsen
use on terminal:
Code:

fdisk /dev/sdx
(x is the letter for the device).

Now at the interactive promt, you can check multiple options pressing 'm'.
Delete partition (press d), create a new partition (press n) - use the whole drive.
Write the changes (press w) and quit (press d).
Afterwards you should be able to use the whole drive again.


jefro 12-01-2012 02:29 PM

Glad you fixed it and posted the results.


I sometimes post more like a man page. They are only good if you know the answer.
"can you see any info on the drive or select it at all in fdisk?"


All times are GMT -5. The time now is 09:05 AM.