Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[solved]Howto recover hw-locked pendrive's data?

Need help with peripherals or devices?
Message
Author
p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Howto repair a particular pendrive to again read its dat

#41 Post by p.H »

bkpsusmitaa wrote:p.H.I am not aware of any command line version similar to gparted.
Why do you need it ?
AFAIK there is nothing wrong with the partition table on the USB stick.
bkpsusmitaa wrote:Would you like me to coalesce all the posts and repost in one, so that both you and I are clear as to which next step do we need to take next?
No. I already know everything I need to know and posted the next steps a long time ago.
Create a copy of partition 2 :

Code: Select all

dd if=/dev/sdc2 of=partition2.img bs=4k
ddrescue is not needed if the pendrive can be read without error.

/dev/sdc2 contains an ext4 filesystem, so the image file contains an ext4 filesystem too. It can be mounted like a regular partition with the mount command (the "-o loop" option is not required any more) or checked with e2fsck.

Code: Select all

mount partition2.img /mnt
If you prefer, or if mount fails, run e2fsck first.

Code: Select all

e2fsck partition2.img

bkpsusmitaa
Posts: 485
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore
Has thanked: 5 times

Re: Howto repair a particular pendrive to again read its dat

#42 Post by bkpsusmitaa »

p.H., I do remember and acknowledge that you had posted the first solution earlier. Thank you for the complete code-lines for the recovery process.

Code: Select all

dd if=/dev/sdc2 of=partition2.img bs=4k
Outputs:

Code: Select all

1286656+0 records in
1286656+0 records out
5270142976 bytes (5.3 GB) copied, 255.102 s, 20.7 MB/s

Code: Select all

e2fsck partition2.img
Outputs:

Code: Select all

e2fsck 1.42.5 (29-Jul-2012)
partition2.img: clean, 29666/321920 files, 731236/1286656 blocks

Code: Select all

mount partition2.img /mnt
mounts normally in the /mnt directory. I've checked the files. They can be read.

Code: Select all

dd if=/dev/sdc1 of=partition1.img bs=4k
Outputs:

Code: Select all

2621692+0 records in
2621692+0 records out
10738450432 bytes (11 GB) copied, 538.849 s, 19.9 MB/s
The

Code: Select all

e2fsck partition1.img
won't work, as the partition is a fat32 partition, I remembered late :(

Code: Select all

fsck.vfat partition1.img
Outputs:

Code: Select all

dosfsck 3.0.13, 30 Jun 2012, FAT32, LFN
There are differences between boot sector and its backup.
Differences: (offset:original/backup)
  65:01/00
1) Copy original to backup
2) Copy backup to original
3) No action
? 3
Reclaimed 39 unused clusters (638976 bytes).
Free cluster summary wrong (133999 vs. really 134038)
1) Correct
2) Don't correct
? 3
Invalid input.
? ^C
I wasn't confident, so I did not damage the filesystem.

Strange, isn't it? The ext4 partition is alright, but unreadable. The fat32 partition has damaged data, but is unreadable!

Since the partition1 has a bad superblock how to recover the maximum possible data from the fat32 partition?

I attempted but changed nothing to the original partition1 in the pendrive:

Code: Select all

fsck.vfat /dev/sdc1

Code: Select all

dosfsck 3.0.13, 30 Jun 2012, FAT32, LFN
There are differences between boot sector and its backup.
Differences: (offset:original/backup)
  65:01/00
1) Copy original to backup
2) Copy backup to original
3) No action
? 3
Reclaimed 39 unused clusters (638976 bytes).
Free cluster summary wrong (133999 vs. really 134038)
1) Correct
2) Don't correct
? 2
Leaving file system unchanged.
/dev/sdc1: 1839 files, 521063/655101 clusters
Please advise on the above step. Will this serve any purpose to recover the data that was there in the pendrive?

I read this post: [SOLVED] No Boot, corrupt drive, any help welcome
I found specific clues:

Code: Select all

dumpe2fs /dev/sdb1| grep -i superblock
(I don't know about this, so I left this alone)
and

Code: Select all

blkid

Code: Select all

blkid /dev/sdc1

Code: Select all

/dev/sdc1: LABEL="STRONTIUM" UUID="201B-E085" TYPE="vfat" 

Code: Select all

 blkid /dev/sdc2

Code: Select all

/dev/sdc2: UUID="be2a228a-cb20-4e31-8792-316835decbe4" TYPE="ext4"
So there is nothing unknown here!

I searched Google with the string, "e2fsck -b 8193". Finding nothing very informative immediately.

I tried with

Code: Select all

man e2fsck | grep -e "8193"
and found this:

Found this:
-b superblock
Instead of using the normal superblock, use an alternative
superblock specified by superblock. This option is normally
used when the primary superblock has been corrupted. The loca‐
tion of the backup superblock is dependent on the filesystem's
blocksize. For filesystems with 1k blocksizes, a backup
superblock can be found at block 8193; for filesystems with 2k
blocksizes, at block 16384; and for 4k blocksizes, at block
32768.
Guess this code

Code: Select all

e2fsck -b 8193 /dev/sdc1
won't work, as the partition in question is a vFAT partition!

But I am beyond my circle of awareness here. I will have to read the related materials.

Thank you, once again! FOSS still breathes for self-assured and confident people like you!
Last edited by bkpsusmitaa on 2017-10-15 09:22, edited 1 time in total.
Freedom is impossible to conceive.
Books that help:
Dale Carnegie's How To Win Friends And Influence People and Emilie Post's Etiquette In Society, In Business, In Politics, And At Home

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Howto repair a particular pendrive to again read its dat

#43 Post by p.H »

Partition 1 (and its image) contains a FAT filesystem. e2fsck and dumpe2fs handle only ext2/3/4 filesystems, not FAT. Each filesystem type has its own set of tools. For FAT you need dosfsck (aka fsck.vfat, fsck.msdos) from package dosfstools.

But if you can mount (even read-only) partition 1 and read its contents without error, why did you create an image and why do you want to fsck it ? As detected by dosfsck, it has only minor inconsistencies which do not prevent reading it.

bkpsusmitaa
Posts: 485
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore
Has thanked: 5 times

Re: Howto repair a particular pendrive to again read its dat

#44 Post by bkpsusmitaa »

p.H wrote:[Each filesystem type has its own set of tools. For FAT you need dosfsck (aka fsck.vfat, fsck.msdos) from package dosfstools.
I apologise! I was editing the post when you posted.
p.H wrote:But if you can mount (even read-only) partition 1 and read its contents without error, why did you create an image and why do you want to fsck it ?
For safety! Please look at the fsck.vfat report posted earlier, especially, this part:

Code: Select all

Reclaimed 39 unused clusters (638976 bytes).
Free cluster summary wrong (133999 vs. really 134038)
1) Correct
2) Don't correct
? 2
Freedom is impossible to conceive.
Books that help:
Dale Carnegie's How To Win Friends And Influence People and Emilie Post's Etiquette In Society, In Business, In Politics, And At Home

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Howto repair a particular pendrive to again read its dat

#45 Post by p.H »

As I wrote in my previous post, these are just minor metadata inconsistencies. You can fix them if you like. It should not affect the files. Anyway you can back up the contents before.

bkpsusmitaa
Posts: 485
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore
Has thanked: 5 times

Re: Howto repair a particular pendrive to again read its dat

#46 Post by bkpsusmitaa »

Sorry, edited later, after p.H.'s post just below . Earlier, wrong post.
Tried:

Code: Select all

fsck.vfat partition1.img
Outputs:

Code: Select all

dosfsck 3.0.13, 30 Jun 2012, FAT32, LFN
There are differences between boot sector and its backup.
Differences: (offset:original/backup)
  65:01/00
1) Copy original to backup
2) Copy backup to original
3) No action
? 3
Reclaimed 39 unused clusters (638976 bytes).
Free cluster summary wrong (133999 vs. really 134038)
1) Correct
2) Don't correct
? 1
Leaving file system unchanged.
partition1.img: 1839 files, 521063/655101 clusters

Code: Select all

fsck.vfat -r /dev/sdc1

Code: Select all

dosfsck 3.0.13, 30 Jun 2012, FAT32, LFN
open: Read-only file system
No changes appear to have been made. Because of read-only?
Last edited by bkpsusmitaa on 2017-10-15 11:49, edited 2 times in total.
Freedom is impossible to conceive.
Books that help:
Dale Carnegie's How To Win Friends And Influence People and Emilie Post's Etiquette In Society, In Business, In Politics, And At Home

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Howto repair a particular pendrive to again read its dat

#47 Post by p.H »

Of course. You must do it on the image file.

bkpsusmitaa
Posts: 485
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore
Has thanked: 5 times

[Solved]Howto repair a particular pendrive, read its data

#48 Post by bkpsusmitaa »

Yes,

Code: Select all

sudo fsck.vfat -r partition1.img
outputs:

Code: Select all

dosfsck 3.0.13, 30 Jun 2012, FAT32, LFN
There are differences between boot sector and its backup.
Differences: (offset:original/backup)
  65:01/00
1) Copy original to backup
2) Copy backup to original
3) No action
? 1
Reclaimed 39 unused clusters (638976 bytes).
Free cluster summary wrong (133999 vs. really 134038)
1) Correct
2) Don't correct
? 1
Perform changes ? (y/n) y
partition1.img: 1839 files, 521063/655101 clusters
And again:

Code: Select all

 sudo fsck.vfat -r partition1.img
this time yields;

Code: Select all

dosfsck 3.0.13, 30 Jun 2012, FAT32, LFN
partition1.img: 1839 files, 521063/655101 clusters
I would really like to thank you, p.H. for the consistent support you have provided. You are a patient and transparent person, a real teacher-material.
My good wishes.
There are very many questions that I would like to ask you. But I can gradually do it in a different manner.
Freedom is impossible to conceive.
Books that help:
Dale Carnegie's How To Win Friends And Influence People and Emilie Post's Etiquette In Society, In Business, In Politics, And At Home

bkpsusmitaa
Posts: 485
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore
Has thanked: 5 times

Now, time for some humour!

#49 Post by bkpsusmitaa »

Head_on_a_Stick wrote:@OP, your posts are too prolix.
Yes, of course!
better,
why not this!
Freedom is impossible to conceive.
Books that help:
Dale Carnegie's How To Win Friends And Influence People and Emilie Post's Etiquette In Society, In Business, In Politics, And At Home

Post Reply