Read only usb drive in Fedora – Resolve issue without formatting

By | January 11, 2015
Read only usb drive

Read Only USB Drive

I have a 8 GB usb drive. Yesterday suddenly its started mounting read only in Fedora 20. This issue has occurred earlier also but I formatted drive and it worked fine. This time I had important data and wanted to resolve this issue read only usb drive without formatting disk. So I did some research to resolve the issue.

In this post I’ll try to explain – How to make read only usb drive writable without formatting drive and the reason behind of this silly occurrence ?

Notes

  • The commands/steps written here were tested on Fedora 20. It should work on Fedora (17-20)/Redhat 7/Centos 7. I’ll explain where needed, so that commands work on other distros/versions also.
  • Please always take backup of your important data before doing any R&D with your storage devices.
  • If you are in hurry and don’t want to read whole post, as you may found it little geeky :p. Click here for a Quick Fix.

 

Troubleshooting

1- Open terminal and login with root credentials


2- Run mount command to find out where it is mounted and what are the permissions

3- Run umount command to unmount drive

4- Disconnect the drive from system

5- Run journalctl command to find out exact problem

6- Connect USB drive now and monitor the messages appearing in the terminal

Read only usb drive - logs

Journalctl – viewing logs

Note – Journalctl is a component of systemd for viewing and managing logs in Fedora. In older Fedora version rsyslogd is used to manage logs.

On older fedora/Redhat versions use tail command instead of journalctl

 

Error 
In logviewer you can find out exactly what is happening. In my case I was getting  fat_get_cluster – invalid cluster chain error. To understand error, lets find out some basic information

Cluster
In FAT (File Allocation Table) file system, partition is logically divided in equal sizes small blocks called clusters. Cluster sizes depends on the size of partition. While saving file in cluster if file size is greater than cluster size it is saved in more than one cluster.

FAT
At the time of formatting, a disk map table also known as FAT (File Allocation Table) is created at the known position on the disk. This table (FAT) contains entries of each cluster. Thus number of entries is equal to number of clusters on disk.

Possible values in FAT

Value Meaning
0x0000 Free/unused cluster
0x0001 Reserved Cluster
0x0002 – 0xFFEF Used cluster, value points to next cluster
0xFFF0 – 0xFFF6 Reserved Values
In order to read any file from FAT file system, OS need to know first cluster entry and then next cluster……… and at the end EOC (End of cluster chain) and to write file OS need to find free clusters.

If there is any error in FAT entry, OS may not be able to read data or it may overwrite data.

Therefore while mounting disk, Operating system check consistency of FAT and if it finds any error it mounts drive as read only to save drive from any further damage.

Possible causes of errors

There may be many reasons for the read only usb disk problem. I am listing some of the possible reasons so that you can avoid them in future.

  • You disconnected drive while reading/writing data.
  • Hard power off of system while reading/writing data.
  • Physically damaged drive.
  • Virus infected drive.

I hope you got clear idea what is happening to your drive.

Solution

Follow the following steps to resolve the issue.

1- Press ctrl+c, to close journalctl command if not closed already.

2- unmount the drive

3- run fsck command to repair the disk

<span style="font-family: Terminal, Monaco;">a = automatically repair the file system</span>
<span style="font-family: Terminal, Monaco;">f = salvage unused chains to files</span>
<span style="font-family: Terminal, Monaco;">v = verbose mode</span>

4- Disconnect your drive and re-plug your USB. DONE! It is ready.

 

Do you have something to add in story ? Please share in the comment.

Leave a Reply

4 Comments on "Read only usb drive in Fedora – Resolve issue without formatting"

Notify of
avatar
Sort by:   newest | oldest | most voted
rokey
Guest

Not working for me

Amit Singh
Admin

Hi Rokey,

Can you please give more info on your situation?

Daniel
Guest

Thanks so much! That worked perfectly!

pieter
Guest

I had to go through these steps two times, and after that everything was fine. It appears my computer needed two runs to fix errors, but I’m happy everything works fine again (all files are ok, but directory structure is gone)

wpDiscuz