While copying some large file I mistakenly taken out USB pen drive before the copy get completed. Later I again attached the USB pen drive in Ubuntu system but found that the USB pen drive showing read only filesystem message. I was not able to copy, create and delete any file. To solve this issue I followed some steps which I am sharing in this article.
Method Of Fixing Read Only USB Pen Drive In Ubuntu
In this section, we will follow the steps to fix the read only USB Pen Drive.
Disclaimer
- Some of you might be carrying the important data in USB / Pen Drive. In this method, we will format the USB drive. So due to this , the data will be erased and non recoverable.
- This solution works most of the time but in case there is Hardware issue in your USB/Pen drive then this solution won’t work. You should buy new USB/ Pen drive instead.
Find Out The Mounted Path Of USB Pen Drive
Step 1: Attach USB pen drive in system’s USB port. Automatically the Ubuntu will mount the USB pen drive and show icon on Desktop or Menu bar.
Open the terminal and become super user by running below given command
sudo su -
Step 2: First we have to find out in which directory the USB pen drive has been automatically mounted.For this run the df -Th
command.
In given below output you can see,in my system the USB pen drive is mounted in /media/linux/C38C-099C ,partition is /dev/sdd1 and filesystem is vfat.
Note: When you run df -Th
command in your system,the USB pen drive may mount in different directory and the partition might also be different.Hence the output value which you will get, use the same values in further steps.
root@tuxworld:~# df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/sda5 ext4 28G 25G 1.3G 96% / udev devtmpfs 2.0G 4.0K 2.0G 1% /dev tmpfs tmpfs 796M 1.1M 795M 1% /run none tmpfs 5.0M 8.0K 5.0M 1% /run/lock none tmpfs 2.0G 528K 2.0G 1% /run/shm none tmpfs 100M 104K 100M 1% /run/user cgroup tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/sda7 ext4 9.2G 8.2G 539M 94% /partition7 /dev/sda8 ext3 46G 38G 6.2G 86% /partition8 /dev/sda9 ext3 74G 67G 3.1G 96% /partition9 /dev/sda21 ext4 14G 4.9G 8.3G 37% /partition10 /dev/sdd1 vfat 15G 12G 3.6G 77% /media/linux/C38C-099C
Unmount USB Pen Drive
Step 2: Now unmount the directory in which the USB pen drive is automatically mounted . (As you can see mounted directory path in above ‘Step 1’)
Note: Replace the/media/linux/C38C-099C with the mounted USB pen drive directory path which is showing output in your system after running df -Th
command.
umount /media/linux/C38C-099C
Check And Repair
Step 3: As we know the USB pen drive got /dev/sdd1 partition
and filesystem is vfat(see in Step 1). Now we will run dosfsck command to check and repair the filesystem
Note: The dosfsck
command check and repair MS-DOS filesystems.Because the filesystem of USB pen drive is vfat hence we are using this command
dosfsck -a /dev/sdd1
Re-Attach USB Pen Drive
Step 4: After the dosfsck command get completed.Remove the USB pen drive from system and then re-attach back to system.Now your USB pen drive should working and it should not have read only filesystem.
Note** After mounting the USB pen drive you may see a new file with extension .REC which was created because of dosfsck command.
Reboot The System
Step 5 Reboot the system after completing all the steps. (This step we have added after receiving lots of suggestion in comments section from our readers around the world. Thank you for providing feedback and sure it will help many people.)
very very useful information. Thank you.
Superb! I wrestled with a new USB for hours yesterday, and this fixed it in seconds. Thanks for the clear explanation of the process.
nice! thanks for feedback.
Regards
Sharad
Thanks Sharad. My filesystem reads as hfsplus and the last statement seems like not working. I am getting the output as this.
fsck.fat 3.0.26 (2014-03-07)
Logical sector size is zero.
Any suggestions?
Hi Albert,
Unfortunately it seems the disk is corrupted and could be sectors are also affected.
Use the ‘testdisk’ [please,google it] , if there is any ray of hope then most probably you have to rebuilt the file system by using ‘TestDisk’
You have to “Do it yourself” because I am forgotten and these kind of issue rarely come [once in a blue moon] .
All the best!
Regards
Sharad
Thank you
Welcome Fabio!
Regards
Sharad
Hello sir
please solve my problem i tried these steps but ihe didnt work
sudo su –
df -Th
umount /media/govind/5A85-E61F
/dev/sdb1 vfat 7.5G 3.2G 4.3G 43% /media/govind/5A85-E61F
dosfsck -a /dev/sdb1
fsck.fat 3.0.28 (2015-05-16)
open: Read-only file system
Hello Henmant,
Try formatting USB pen drive in GUI mode. https://sharadchhetri.com/2015/05/11/gui-format-usb-drive-on-ubuntu/
Regards
Sharad
Hi,
I have same problem which Henmant has.
I followed your steps but it didn’t change anything.
Then I tried GUI mode. After formatting when I plug in my pen drive again I received a message:
Error mounting /dev/sdb1 at /media/grarysz/Linux Mint 18 Cinnamon 64-bit: Command-line `mount -t “iso9660” -o “uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,iocharset=utf8,mode=0400,dmode=0500” “/dev/sdb1” “/media/grarysz/Linux Mint 18 Cinnamon 64-bit”‘ exited with non-zero exit status 32: mount: block device /dev/sdb1 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/sdb1,
missing codepage or helper program, or other error
In some cases useful info is found in syslog – try
dmesg | tail or so
This is my third pen drive I’ve lost in the same way…
Thanks, I follow your steps but i got this message:
fsck.fat 3.0.28 (2015-05-16)
open: Permesso negato
What can i do?
Hello Alex,
May be you are not login as super user. Run the command
sudo su -
and then follow the steps.Regards
Sharad
thank u my friend ! u’r a life saver 🙂
Thanks bro!
I wish fixing USB pen drive could be life saver 🙂 Many issues could be solved.
Thanks again for commenting and giving feedback. Keep sharing the knowledge.
Regards
Sharad
I have a similar problem to this. I have a read-only usb pen drive and also one of my folders gives me this error warning when I try to open it: This location could not be displayed. Sorry, could not display contents of “june”: Error when getting information for file ../LEXAR/june/…:Input/output error
I’ve searched online but other topics on this were inconclusive.
Can you please help me out?
Thank you
Hello Janne,
If your USB pend drive is Read Only and has really some malfunction with hardware then it is lucky to get the solution.
Try Gparted (http://gparted.org/) . Also check if your USB pen drive has any small button which is used for making Read Only. Some USB model has this option.
Regards
Sharad
Thanks! Worked perfect for me. You might also want to add that the .REC file can be renamed with the appropriate extension and at least in my case with a .tar.gz file I could recover it.
Thank you Jeffrey,
Approving your comment which can be considered as suggestion also.
Regards
Sharad
Great stuff! It worked. Thanks.
When I give dosfsck -a command it shows permission denied …what I have to do now
Use
sudo dosfsck -a
. Your login user must have sudo privileges .Or login with root usersu -l root
Regards
Sharad
it is taking so much time in my 1000gb external adata hard drive. what should i do in this case stop the process or wait for 1 week .