LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-03-2016, 02:15 AM   #1
granfran
Member
 
Registered: Jun 2015
Posts: 33

Rep: Reputation: Disabled
Write-Protected File System


Greetings. My flash that contains my debian OS suddenly became "read-only" after a power failure. I booted with another OS disk and tried to fsck the flash drive; however this message appears: "disk write-protected; use the -n option to do a read only check".

I can run fsck with the -n option, but I need to repair the device and make it unprotected again. I have even tried to mkfs the device, but cannot because of the write-protected status.

Thanks in advance.
 
Old 10-03-2016, 02:21 AM   #2
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,861
Blog Entries: 36

Rep: Reputation: 459Reputation: 459Reputation: 459Reputation: 459Reputation: 459
Does the drive contain a physical read-only switch? I know some flash cards have that.
 
Old 10-03-2016, 02:27 AM   #3
granfran
Member
 
Registered: Jun 2015
Posts: 33

Original Poster
Rep: Reputation: Disabled
No, this one does not have a switch. From what I can tell, Linux will put a partition into "write protected" mode when it detects file inconsistencies.
 
Old 10-03-2016, 04:09 AM   #4
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920
Can you please post the entire output from the fsck command?

I would suggest that if the data on the flash disk is important to you, before anything else you make a byte-for-byte backup of the filesystem onto another device in case any of your subsequent recovery efforts go awry.
 
Old 10-03-2016, 06:36 AM   #5
granfran
Member
 
Registered: Jun 2015
Posts: 33

Original Poster
Rep: Reputation: Disabled
Below is the output:

Quote:
fsck.ext3: Read-only file system while trying to open /dev/sdc5
Disk write-protected; use the -n option to do a read-only
check of the device

Last edited by granfran; 10-03-2016 at 06:37 AM.
 
Old 10-03-2016, 07:37 AM   #6
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920
Are you sure that /dev/sdc5 is the Debian o/s filesystem in question? A blkid should confirm it (consider label, size etc.).

Also check that the filesystem is actually unmounted and not being auto mounted by your other o/s disk by issuing a mount | grep sdc5 command.

To see what fdisk thinks of the flash, could you also throw a fdisk -l /dev/sdc at it?
 
Old 10-03-2016, 09:32 AM   #7
granfran
Member
 
Registered: Jun 2015
Posts: 33

Original Poster
Rep: Reputation: Disabled
I confirmed that the disk is not mounted. The results of the other commands are below:

blkid

Quote:
/dev/sdb5: UUID="a5449d20-732a-4310-89b7-a50893b61a1d" TYPE="ext4" PARTUUID="55ae2695-05"
fdisk -l /dev/sdc

Code:
Disk /dev/sdc: 7.5 GiB, 8004304896 bytes, 15633408 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x55ae2695

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sdc1  *          64   851967   851904  416M 17 Hidden HPFS/NTFS
/dev/sdc2         854014 15632383 14778370    7G  5 Extended
/dev/sdc5         854016 14925823 14071808  6.7G 83 Linux
/dev/sdc6       14927872 15632383   704512  344M 82 Linux swap / Solaris
 
Old 10-03-2016, 10:14 AM   #8
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920
That looks fine to me. So what happens when you try to mount the filesystem? (mount -t ext4 -v -o rw /dev/sdc5 mountpoint [change mountpoint to your desired mount point]).

It's a bit unusual that your original fsck command tried to use fsck.ext3 rather than fsck.ext4. What command did you issue?
 
Old 10-03-2016, 10:32 AM   #9
granfran
Member
 
Registered: Jun 2015
Posts: 33

Original Poster
Rep: Reputation: Disabled
mount -t ext4 -v -o rw /dev/sdc5 /mnt

Quote:
mount: /dev/sdc5 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/sdc5,
missing codepage or helper program, or other error

In some cases useful info is found in syslog - try
dmesg | tail or so.

I used fsck. Now when I use fsck it uses fsck.ext4 with the same results. I don't have an explanation of why it used ext3 before.

Last edited by granfran; 10-03-2016 at 10:35 AM.
 
Old 10-03-2016, 12:04 PM   #10
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920
Ok. Filesystem corruption looks the most likely reason, I'm afraid to say.

What does fsck.ext4 with the -n option give you? If it looks too bad, you'll probably need to start looking at recovery software such as testdisk (if the data is important to you).

If the data isn't important to you, you can always reformat the relevant partition(s) and reload your operating system. That's assuming you don't have a backup image somewhere.
 
Old 10-03-2016, 12:15 PM   #11
granfran
Member
 
Registered: Jun 2015
Posts: 33

Original Poster
Rep: Reputation: Disabled
fsck with -n is below:

/dev/sdc5: clean, 109061/439776 files, 1753081/1758976 blocks


mkfs won't let me proceed because it is write-protected.

Doesn't this imply that the problem is not corrupted file system?
 
Old 10-03-2016, 12:36 PM   #12
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920
Quote:
Originally Posted by granfran View Post
fsck with -n is below:

/dev/sdc5: clean, 109061/439776 files, 1753081/1758976 blocks

mkfs won't let me proceed because it is write-protected.

Doesn't this imply that the problem is not corrupted file system?
Indeed it does. Strange that mounting the flash generates the error but fsck checks out ok. Something else must be in play.

Have you tried hdparm -r0 /dev/sdc ?
 
Old 10-03-2016, 12:38 PM   #13
michaelk
Moderator
 
Registered: Aug 2002
Posts: 21,920

Rep: Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305Reputation: 4305
I would not expect a power failure to damage the drive and it could be a coincidence but it could of failed. As stated I would copy anything important off the drive as soon as possible. Can you mount the drive read only?

Flash drives do fail and in several ways. Be lucky that it failed read only and not completely dead.
 
Old 10-03-2016, 12:45 PM   #14
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,351
Blog Entries: 4

Rep: Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334Reputation: 3334
Obviously, "computers don't 'just decide' to do these things." Look at the output of the dmesg command, which displays the swirl of messages that occur at boot, and I predict that you will discover that a file-system integrity check failed. Therefore, the disk was mounted read-only.
 
Old 10-03-2016, 12:53 PM   #15
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,861
Blog Entries: 36

Rep: Reputation: 459Reputation: 459Reputation: 459Reputation: 459Reputation: 459
Also, what is the make/model of the drive? How is it connected to your computer (e.g. SATA, USB, etc)?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove Write-Protected File jaypas Linux - Newbie 1 07-30-2010 04:34 PM
Need to write a file in delete protected mode shiv.singh Linux - Newbie 7 05-17-2009 12:59 AM
File write protected without chattr??? abefroman Linux - Server 1 12-06-2008 06:12 AM
Cant remove write protected weird file tuxombie Slackware 13 12-07-2004 09:44 AM
remove write-protected file randomtask Linux - Newbie 5 04-22-2004 03:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration