# HELP ME RECOVER MY PARTITION!!...corrupt partition table

## dE_logics

I used a new 8GB thumb drive to backup certain data (~3.4 GB); I had formatted it to a single JFS partition with msdos partition table using gparted.

Now, I was compiling openoffice, and realized it requires lots of space...that thumbdrive had enough space so I mounted it to /var/tmp/portage and started emerging openoffice.

All of sudden portage came up with an I/O error and stopped compiling.

I checked to see if the device was lacking free space...it was not so, it had..I think 3.1 GB free. Then I tried to unmount it but it could not, some process was still using it...so I - 

umount -l /dev/sdb1

Later I plugged in the disk again.................and to my dismay saw ALL PARTITIONS WHERE LOST!!!

I tried photorec to rover the data...it went till ~3GB; it doesn't preserve the hierarchy or file names, so I was wondering about fixing the partition table of the disk instead.

For that I used testdisk which on analysis of the partition said NO partitions where found...

gpart doesn't support jfs; and I see no other options.   :Crying or Very sad: 

CAN SOMEONE HELP!!!!???...I'll be glad!!!  :Smile: 

----------

## honp

Try Hirens CD, it is full of grea utils, maybe some can help.

----------

## whiteghost

i've used testdisk on sysrescue with good results. or you can emerge it.

----------

## dE_logics

 *honp wrote:*   

> Try Hirens CD, it is full of grea utils, maybe some can help.

 

I can emerge those...can you name a few?

----------

## dE_logics

 *whiteghost wrote:*   

> i've used testdisk on sysrescue with good results. or you can emerge it.

 

I did try testdisk.

No results

----------

## xaviermiller

Hello,

Do you need to restore data or just the partition table ?

If I read, the format was JFS, Photorec and Testdisk don't support JFS (only FAT, NTFS and EXT) : http://www.cgsecurity.org/wiki/TestDisk_6.11_Release

So you need to find a JFS filestystem recovery tool.

----------

## dE_logics

I was wondering it I can just recover the partition table the original partitions will come back...wont it??

----------

## xaviermiller

You can try it, with fdisk : delete the partition table, create it as identical (and obviously, don't format it  :Wink: ).

Then try fsck on the partition

----------

## dE_logics

Ok.

I will try this.

So I have to just make an msdos partition table...that's it?...and leave the partition unformatted?

I have Kernal JFS recovery

----------

## xaviermiller

You run fdisk, delete the partitions, and create a linux primary partition.

(don't use other tools, that format the partition).

----------

## honp

Do dd before any try and backup it.

----------

## dE_logics

Ok then, my attempts start.

----------

## dE_logics

jfs.fsck was completely useless...it just threw it's hands up.

----------

## eccerr0r

A lot of my flash based/eeprom USB/CF/PCMCIA/SD "disks" end up being dead and trashworthy when the partition table can no longer be read...  sorry...

I have a suspicion the controller could no longer deal with some corrupt metadata on the flash for these failures I had, and usually without special hardware, cannot recover from such failures.

----------

## NeddySeagoon

dE_logics,

Try to mount the first partition read only without using a partition table.

The command will be something like 

```
mount -o loop,ro,offset=32256 /dev/sda /some/mountpoint
```

This mounts the partition beginning 32256 bytes from the start of /dev/sda read only. You do not give a partition number, just the raw device.

32256 is right for a hard drive. FLASH devices vary, it depends on the sector size and sectors per track they report. The first MSDOS partition always starts at sector 0 head 1 cylinder 0, which for 63 sectors/track and 512 byte sectors is 32256.

Trying other numbers for offset is harmless but its only worth trying integer multiples of 512.

Journelled filesystems JFS, extX for X>2, reiserfs, NTFS are a really bad choice for FLASH memory as the journal writes reduce the life of the media. ext2 is good for media life.

If the first partition mounts, you can discover its size and calculate a new offset for the second partition.

----------

## dE_logics

Who cares about the life?...it's so damn cheep and this one has a 5 years warranty.

Forget about warranty, I'm planing to apply a case against Kingston...all their pendrives have such issues (above 4 gb).

Anyway, I recovered what I could using photorec...I hope that book Garnot's physics was recovered.

Currently the disk is under test...what I'm trying to do is fill it up with 1MB data (i.e 7000+ copies of the same file) named TEST.zip. Suppose the media is mounted in /media...then TEST.zip will be copied there then I'll  - 

mkdir new

cd new

cp TEST.zip

and on and on ~7000 times.

I made a shell script for this.

In the end the md5sum of all these files will be checked.

On trying this I did find problem...a few amount of times cp said that TEST.zip or new already existed...and there's no way the shell script has errors.

By the end it said something like file name too long...is it that there's a limit to the length of the tree?

Also I would like to know other secure ways to test a media.

I was wondering about something like filling up the disk with random data with a known md5sum then generating the md5sum of the data stored in the disk.

----------

## NeddySeagoon

dE_logics,

You cannot use cp to copy a single file to the same place multiple times unless you change the destination file name prior to each invocation of cp.

dd can do what you need since it does raw block writes.  You will need to use its seek/skip parameters depending on the direction of the copy.

Use a source file that is an integral multiple of the FLASH native block size.

Life is too short - accept that the drive is proably trashed by using a journeld fs. Get your warranty replacement.

----------

## dE_logics

humm...thanks.

I can generate an image file using urandom.

----------

## Gentree

I would not even want to inflict a OOO-err build on a hard disk , let alone a flash device. I think that is about the best means I can imagine to destruction test such a device.

With the price of 4GB flash , don't waste your time. Whatever is left of it will on death's door anyway and certainly no use as a back-up of anything.

Be nicer to the next on you get .   :Razz: 

----------

