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

Getting your soundcard to work, using Debian on non-i386 hardware, etc

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

Postby bkpsusmitaa » 2017-10-09 05:51

[Post-solution Clarification] Originally, the subject heading was: Howto repair a particular pendrive to again read its data? Gradually, following interactions with p.M., it was learnt and understood that the drive with two partitions (EXT4 and FAT32] is Write-protected, locked by the firmware, which made the ext4 partition unmountable and unreadable, while the fat32 partition read-only.


Hi!
My pendrive partitions are shown in the FileManager (nautilus or pcmanfm) drive explorer window. Upon clicking to look into it or
Code: Select all
sudo mount  /dev/sdc2 /media/sdc2
, the error displays:
Code: Select all
Error mounting: mount exited with exit code 1: helper failed with:
mount: block device /dev/sdc2 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/sdc2,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so


Code: Select all
sudo mount  /dev/sdc1 /media/sdc1

Code: Select all
mount: block device /dev/sdc1 is write-protected, mounting read-only


GParted report while trying to check the pendrive:

Report:
Code: Select all
GParted 0.12.1 --enable-libparted-dmraid

Libparted 2.3
Check and repair file system (ext4) on /dev/sdc2  00:00:00    ( ERROR )
        
calibrate /dev/sdc2  00:00:00    ( SUCCESS )
        
path: /dev/sdc2
start: 20,973,568
end: 31,266,815
size: 10,293,248 (4.91 GiB)
check file system on /dev/sdc2 for errors and (if possible) fix them  00:00:00    ( ERROR )
        
e2fsck -f -y -v /dev/sdc2
        
Disk write-protected; use the -n option to do a read-only
check of the device.
e2fsck 1.42.5 (29-Jul-2012)
e2fsck: Read-only file system while trying to open /dev/sdc2
libparted messages    ( INFO )
        
Unable to open /dev/sdc read-write (Read-only file system). /dev/sdc has been opened read-only.
Unable to open /dev/sdc read-write (Read-only file system). /dev/sdc has been opened read-only.


Code: Select all
e2fsck -f -y -v /dev/sdc1

Report:
Code: Select all
e2fsck 1.42.5 (29-Jul-2012)
Warning!  /dev/sdc1 is mounted.
e2fsck: Operation not permitted while trying to open /dev/sdc1
You must have r/w access to the filesystem or be root


Code: Select all
e2fsck -f -y -v /dev/sdc

Code: Select all
e2fsck 1.42.5 (29-Jul-2012)
/dev/sdc is in use.
e2fsck: Cannot continue, aborting.


Code: Select all
umount /media/sdc

Code: Select all
umount: /media/sdc is not mounted (according to mtab)


Code: Select all
sudo e2fsck -f -n -v /dev/sdc

Code: Select all
e2fsck 1.42.5 (29-Jul-2012)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/sdc

The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>


Code: Select all
dmesg
reports
Code: Select all
[ 2547.030210] usb 1-5: USB disconnect, device number 4
[ 2548.536452] usb 1-5: new high-speed USB device number 5 using ehci-pci
[ 2548.660700] usb 1-5: New USB device found, idVendor=0781, idProduct=5567
[ 2548.660709] usb 1-5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2548.660716] usb 1-5: Product: Cruzer Blade
[ 2548.660722] usb 1-5: Manufacturer: SanDisk
[ 2548.660728] usb 1-5: SerialNumber: 20060876920A0992874A
[ 2548.662280] scsi6 : usb-storage 1-5:1.0
[ 2549.664258] scsi 6:0:0:0: Direct-Access     SanDisk  Cruzer Blade     1.26 PQ: 0 ANSI: 5
[ 2549.664622] sd 6:0:0:0: Attached scsi generic sg3 type 0
[ 2549.666098] sd 6:0:0:0: [sdc] 31266816 512-byte logical blocks: (16.0 GB/14.9 GiB)
[ 2549.667988] sd 6:0:0:0: [sdc] Write Protect is on
[ 2549.667999] sd 6:0:0:0: [sdc] Mode Sense: 43 00 80 00
[ 2549.668979] sd 6:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 2549.685704]  sdc: sdc1 sdc2
[ 2549.690857] sd 6:0:0:0: [sdc] Attached SCSI removable disk
[ 2552.906044] FAT-fs (sdc1): utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive!
[ 2650.406111] EXT4-fs (sdc2): INFO: recovery required on readonly filesystem
[ 2650.406123] EXT4-fs (sdc2): write access unavailable, cannot proceed
[ 2654.211098] EXT4-fs (sdc2): INFO: recovery required on readonly filesystem
[ 2654.211110] EXT4-fs (sdc2): write access unavailable, cannot proceed
[ 2665.802358] EXT4-fs (sdc2): INFO: recovery required on readonly filesystem
[ 2665.802369] EXT4-fs (sdc2): write access unavailable, cannot proceed
[ 2741.044567] SGI XFS with ACLs, security attributes, realtime, large block/inode numbers, no debug enabled
[ 2789.333051] FAT-fs (sdc1): utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive!
[ 3416.644841] EXT4-fs (sdc2): INFO: recovery required on readonly filesystem
[ 3416.644847] EXT4-fs (sdc2): write access unavailable, cannot proceed
[ 3423.070968] EXT4-fs (sdc2): INFO: recovery required on readonly filesystem
[ 3423.070980] EXT4-fs (sdc2): write access unavailable, cannot proceed



How to protect my data, but mount, take a backup and then recover the pendrive? Should I run:
Code: Select all
e2fsck -b 8193 /dev/sdc
?
I am beyond my limits of knowhow!
Last edited by bkpsusmitaa on 2017-10-17 04:13, edited 4 times in total.
Freedom is impossible to conceive.
bkpsusmitaa
 
Posts: 333
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore

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

Postby debiman » 2017-10-09 17:47

  1. it seems indeed your drive is read-only
  2. try to mount in a different location - e.g
    Code: Select all
    cd
    mkdir mnt
    sudo mount /dev/sdxx mnt
  3. output of
    Code: Select all
    mount

edit: of course i meant read-only, not write-only.
Last edited by debiman on 2017-10-10 14:38, edited 1 time in total.
User avatar
debiman
 
Posts: 1626
Joined: 2013-03-12 07:18

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

Postby pylkko » 2017-10-09 18:48

It is possibly hardware failure because flash drives often (if not always) go into read-only mode when they die. I would suspect this especially if the system was indeed ext4 formatted and you did nothing and it just suddenly went bad. Especially since you are getting kernel messages about not being able to read it, and thus it is unlikely that you have mounted it wrong or do not have permissions or proper mount rule.

Copy the data somewhere else and try to format the drive.

dd writes to the block device when it is not mounted. So, if this does not work, then I'm afraid the device is gone.
User avatar
pylkko
 
Posts: 1213
Joined: 2014-11-06 19:02

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

Postby bkpsusmitaa » 2017-10-10 01:21

pylkko wrote:Copy the data somewhere else and try to format the drive.

That is the point, Pyikko! How do I copy a drive's files which I can't read? You talked about dd, but didn't say much.
Code: Select all
info coreutils 'dd invocation'
is a huge file.

This problem had occurred once, Pyikko! For that drive the files weren't that important. So I formatted the drive and the problem was gone!

Debiman, the problem is the same with even the new mount point.
Code: Select all
sudo mount /dev/sdc2 /media/ant

Code: Select all
mount: block device /dev/sdc2 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/sdc2,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so
Freedom is impossible to conceive.
bkpsusmitaa
 
Posts: 333
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore

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

Postby Head_on_a_Stick » 2017-10-10 05:33

Apologies if this has already been mentioned but have you tried:
Code: Select all
# hdparm -r0 /dev/sdX
"Only the mediocre are always at their best." — Jean Giraudoux
User avatar
Head_on_a_Stick
 
Posts: 6810
Joined: 2014-06-01 17:46
Location: /dev/chair

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

Postby bkpsusmitaa » 2017-10-10 14:44

How can I call you HOAS? Why did you choose such a name which if called might be consider as a satire!? Mine to will sound funny for the uninitiated. 'bkp' is my native town, Barrackpore ;-)
Thank you for hdparm and your modesty. No one before you mentioned hdparm, and I also read about it after you posted, in the man page. It is a huge file! I wonder how the console users used to read man pages in consoles. It requires an extreme clerical ability to undertake such endeavours.

But unfortunately,
Code: Select all
sudo hdparm -r0 /dev/sdc2
(the pendrive is mounted on the USB port 1-6 with sdc2), even after hdparm code is executed, the same error message, as mentioned earlier, greets when the partition is clicked.
Last edited by bkpsusmitaa on 2017-10-10 17:06, edited 1 time in total.
Freedom is impossible to conceive.
bkpsusmitaa
 
Posts: 333
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore

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

Postby debiman » 2017-10-10 14:58

you need to show us.
also what i requested earlier (you posted only half of it).

PS: flattery will get you nowhere.
User avatar
debiman
 
Posts: 1626
Joined: 2013-03-12 07:18

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

Postby bkpsusmitaa » 2017-10-10 17:13

Debiman, why the sudden irritation?
Of course, I had made a mount folder first, sudo mkdir /media/ant
then used the mount command like I have posted.

And regarding HOAS, it was not flattery, it was a decent acknowledgement. One must understand the difference between flattery and decency to oneself be a decent person !
Freedom is impossible to conceive.
bkpsusmitaa
 
Posts: 333
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore

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

Postby Head_on_a_Stick » 2017-10-10 17:28

bkpsusmitaa wrote:
Code: Select all
sudo hdparm -r0 /dev/sdc2

Try:
Code: Select all
sudo hdparm -r0 /dev/sdc

If I had wanted you to add a partition number then I would have specified /dev/sdXY ;)

Also, debiman is right — you should always post any command output in full when things go wrong.
"Only the mediocre are always at their best." — Jean Giraudoux
User avatar
Head_on_a_Stick
 
Posts: 6810
Joined: 2014-06-01 17:46
Location: /dev/chair

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

Postby bkpsusmitaa » 2017-10-10 23:42

If I had wanted you to add a partition number then I would have specified /dev/sdXY ;)
That was the first one I tried.
Code: Select all
sudo hdparm -r0 /dev/sdc

Output:
Code: Select all

/dev/sdc:
 setting readonly to 0 (off)
 readonly      =  0 (off)

Then I clicked the partition, and I had the same report.
Code: Select all
Error mounting: mount exited with exit code 1: helper failed with:
mount: block device /dev/sdc2 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/sdc2,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so


but as superuser if I type:
Code: Select all
sudo nautilus --browser
and then click on the partition, no message is displayed, but the partition isn't opened.

I further tried:
Code: Select all
e2fsck -f -y -v /dev/sdc2

Output:
Code: Select all
e2fsck 1.42.5 (29-Jul-2012)
e2fsck: Read-only file system while trying to open /dev/sdc2
Disk write-protected; use the -n option to do a read-only
check of the device.

So I tried:
Code: Select all
e2fsck -f -n -v /dev/sdc2

The output was:
Code: Select all
e2fsck 1.42.5 (29-Jul-2012)
Warning: skipping journal recovery because doing a read-only filesystem check.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

       29666 inodes used (9.22%, out of 321920)
          88 non-contiguous files (0.3%)
          12 non-contiguous directories (0.0%)
             # of inodes with ind/dind/tind blocks: 0/0/0
             Extent depth histogram: 29601/51
      731236 blocks used (56.83%, out of 1286656)
           0 bad blocks
           1 large file

       27577 regular files
        2074 directories
           0 character device files
           0 block device files
           0 fifos
           0 links
           6 symbolic links (6 fast symbolic links)
           0 sockets
------------
       29657 files

The same reports on e2fsck with sudo.
Freedom is impossible to conceive.
bkpsusmitaa
 
Posts: 333
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore

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

Postby peer » 2017-10-11 05:14

Perhaps you should try an iso with data recovery software.
peer
 
Posts: 34
Joined: 2017-03-26 10:14

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

Postby pylkko » 2017-10-11 15:42

Some flash memories have firmware level code that forces the drive to read only in order to protect your data in the event that they notice a problems with the hardware. There are many reports on the net that SanDisk pendrives behave like this and at times when they are not broken. See
http://forums.sandisk.com/t5/All-SanDisk-USB-Flash-Drives/Sandisk-cruzer-16GB-became-read-only/td-p/255218/page/2

I suggest you dd/ddrescue the data away from the drive and see if you can find a way to use it. So as root:
Code: Select all
ddrescue -d -r1 /dev/sda testRecover.img testRecover.logfile

replace the drive name with what you have in your situation.
User avatar
pylkko
 
Posts: 1213
Joined: 2014-11-06 19:02

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

Postby bkpsusmitaa » 2017-10-12 07:25

pylkko wrote: ... see if you can find a way to use it ...

Won't the resulting .img file be readable by any ISO reading package?
Freedom is impossible to conceive.
bkpsusmitaa
 
Posts: 333
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore

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

Postby pylkko » 2017-10-12 08:17

Yes, in principle. But if the drive is failing and some parts of it cannot be read, then the iso might be hard to read...
User avatar
pylkko
 
Posts: 1213
Joined: 2014-11-06 19:02

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

Postby bkpsusmitaa » 2017-10-12 11:18

pylkko wrote:... But if the drive is failing and some parts of it cannot be read ...
Let's set the negative scenarios aside. Which applications could be used to read those backups? Brasero, K3B?
Last edited by bkpsusmitaa on 2017-10-12 12:15, edited 1 time in total.
Freedom is impossible to conceive.
bkpsusmitaa
 
Posts: 333
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore

Next

Return to Hardware

Who is online

Users browsing this forum: wizard10000 and 5 guests

fashionable