I am using Ubuntu 14.04.
I have an 8gb FAT32 USB stick and a 500gb FAT32 HDD; both of these have suddenly become read only devices.
I've tried deleting the directory inside /media and then creating it again, renaming it, then giving that directory full permissions. However, this didn't work.
Results of mount:
$ mount
/dev/sda5 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none on /sys/fs/pstore type pstore (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,user=simon)Results of sudo parted -l:
Model: ATA ST9500325AS (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags 4 1049kB 500GB 500GB extended 5 2097kB 496GB 496GB logical ext4 6 496GB 500GB 4238MB logical linux-swap(v1)
Model: Verbatim STORE N GO (scsi)
Disk /dev/sdb: 8028MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags 1 24.6kB 8028MB 8028MB primary fat32 bootResults of lsblk:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 461.8G 0 part /
└─sda6 8:6 0 4G 0 part [SWAP]
sdb 8:16 1 7.5G 0 disk
└─sdb1 8:17 1 7.5G 0 part /media/simon/LYDIA
sr0 11:0 1 1024M 0 rom USB write test:
$ cd /media/simon/LYDIA
$ touch newfile001
touch: cannot touch ‘newfile001’: Read-only file system Results of dmesg:
[ 159.366772] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[ 159.383252] FAT-fs (sdb1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[ 159.383258] FAT-fs (sdb1): Filesystem has been set read-only
[ 159.383571] FAT-fs (sdb1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[ 159.384251] FAT-fs (sdb1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[ 159.384319] FAT-fs (sdb1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[ 159.475111] systemd-hostnamed[2966]: Warning: nss-myhostname is not installed.
Changing the local hostname might make it unresolveable. Please install nss-myhostname!
[ 159.480141] FAT-fs (sdb1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[ 159.480224] FAT-fs (sdb1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[ 159.480497] FAT-fs (sdb1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[ 159.480516] FAT-fs (sdb1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[ 2893.091767] wlan0: deauthenticating from c0:3e:0f:31:21:05 by local choice (reason=3) 15 19 Answers
See this bug.
Run this command to kill Nautilus (Files):
killall nautilus 26 When you attach your USB key to your laptop:
- run
sudo -i(so that you won't type your password all the time) - run
df -Th(to see where your USB stick is mounted) - unmount your USB stick
- run
dosfsckon the device you saw from your previous command. Example:dosfsck /dev/sdc1 - remove and reattach your USB stick
Problem should be solved now.
Now, for your HDD, please follow the answer to this question. It is about an external HDD but it is the same thing for your case.
15I had this problem too. I got an error while copying to my USB stick. I am using Mint 17.1 Cinnamon, with the 3.13.0-43 kernel with and Caja as the file manager.
When I looked at the media directory using this terminal command:
dir /mediaI saw that the layout had changed. Normally, you expect to see the drives listed here, but now they are listed under your username, and guess what? That username has only ROOT permissions.
What I did was to run:
sudo chown [username] /media/[username]and:
sudo chgrp [username] /media/[username]where I replaced [username] with my username. After that I removed the USB stick, waited and then put it back in. The problem was solved, I can now write to it!
I got the same error when using GParted to set partition table and format my USB stick.. after that all USB drives went to "read-only".
But under root copying worked fine...
Issue was gone after machine restart. So I guess that this problem may occur when using GParted.
1I've been having the same problem on Ubuntu, and none of the answers given here so far worked for me. Here's what I tried:
- Format the device using GParted. I even tried re-creating the partition table, without success.
- Check the device with
fsck. No issues were found. - Fixed the permissions of the mount point. Turns out that the mount point was root owned, but even after making myself the owner, I could only write to the device from the command-line (I still could not create files from the GUI).
When I connect a USB stick, it gets mounted under /media/<username>/<label>/, where <username> is my username and <label> is the label of the USB stick or storage device.
I looked again at the permissions:
$ ls -ld /media/<username>
drwxrwx---+ 2 <username> <username> 4096 Mar 4 18:32 /media/<username>Notice the + at the end of the permissions. That's new to me and I never noticed it before. It means the directory has extended permissions called Access Control List (ACL) (see this related question). I listed the ACL details for this directory:
$ getfacl /media/<username>
# file: <username>/
# owner: <username>
# group: <username>
user::rwx
user:<username>:r-x
group::---
mask::r-x
other::---As you can see, there is an additional entry user:<username>:r-x for my username, which only gives me read access. I fixed this with a simple command:
setfacl -m u:<username>:rwx /media/<username>I detached my USB devide, attached it again, and the problem was solved.
1I formatted using Gparted. That wiped all data in the disk and it turns out it also fixed the problem.
2When you ran mount only sda5 (your /) was mounted, and it was read-write (rw) so you should be able to write to it. Normally, most of the directories like /sys, /bin are only writeable by root (you'd need sudo first), but your home folder should be writeable to your regular user.
Can you create any files in your home folder? Maybe your gui file manager is stuck thinking they're read-only, if you try in a terminal does it work? For example, do these commands work?:
cd ~
touch newfile001
echo stuff >> newfile001
cat newfile001If those work successfully then you can write to your HD (sda5).
For the USB drive, after it's plugged in and mounted, look at mount to find it (the /dev/sdb1 ... line) and see if the mount option in the ()'s is rw (read-write) then you should be able to write to it. If it's ro (read-only) try this and see if it changes:
sudo mount -o remount,rw /dev/sdb1 /media/simon/LYDIAIf the filesystem (fs) has errors it may get mounted as ro, there should be messages about it in dmesg & /var/log/syslog too. This is what your logs show:
[ 159.366772] FAT-fs (sdb1): Volume was not properly unmounted. Some data may
be corrupt. Please run fsck.
[ 159.383252] FAT-fs (sdb1): error, fat_get_cluster: invalid cluster chain (i_pos 0)
[ 159.383258] FAT-fs (sdb1): Filesystem has been set read-onlyThat includes a clue to how the fs could have gotten corrupted - "not properly unmounted", you should always unmount before unplugging anything. Most file managers have an "eject" to help with that.
The dmesg log also say how to fix it: fsck can try to fix fs errors, it attempts to pick the right check program, or you can pick one explicitly with fsck.vfat or fsck.[other] pressing TAB after fsck. should list options.
- For a FAT system (often have to run it twice, doesn't always fix all errors the first time)
fsck.vfat -vaV [device]should work automatically (-a) & display more info (-v) & do a "verification" pass (-V), or just:fsck.vfat -a [device]
NOTE: This will not guarantee that the filesystem will stay fixed, it could get corrupted again & it may be impossible to know exactly why. Always unmount / "eject" before removing USB drives.
Note if a fs mounts as rw, but then errors are seen & it gets automatically remounted as ro, the mount command may still report it's mounted rw. Looking at this file with less /proc/mounts should usually show more reliable information (see man mount).
If something is mounted rw but you still can't add/delete/edit files on it, you may not be the owner of the files. In some fs's you can chown to become the owner, but a FAT32 fs like on sdb1 doesn't have those permissions; they're set when it mounts with the mount option uid=value (value is your userid, learn it with echo $UID or id -u) then you can try this & see if it works afterwards:
sudo mount -o remount,rw,uid=[userid] /dev/sdb1 /media/simon/LYDIA- Note: Sometimes, you may need to restart your gui file manager to get it to "notice" the mount change that lets you write to the filesystem/drive, but a terminal should always work.
Or if the above doesn't work, try sudo su to "become" root, to see if anything can write to files on the USB (with touch, echo, etc)?
Goto Disks.
Select your USB drive.
Click on Additional partition options and select Format Partition.
Then select erase Overwrite existing data with zeroes(slow) and type FAT.
I have tried many things after searching on internet but this worked for me.
2This worked for me
sudo su -
df -Th
umount /media/username/USBdriveName
dosfsck -a /dev/sdb1It should end with the message like this.
fsck.fat 3.0.28 (2015-05-16)
0x41: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt. Automatically removing dirty bit.
/.Trash-1000/files/yolo Start does point to root directory. Deleting dir.
Reclaimed 2109 unused clusters (69107712 bytes) in 817 chains.
Free cluster summary wrong (95371 vs. really 94567) Auto-correcting.
Performing changes.
/dev/sdb1: 3633 files, 154405/248972 clusters`Then goto your USB drive and delete all the .REC files.
Remove your USB stick and plug it back. Now you should be able to use it.
As like in wayofthefuture's answer above when you're using Nemo (like me, if you use the Cinnamon desktop environment) try:
killall nemo Run the following commands on the terminal(ubuntu) to give write permission to a Pendrive.
df -Thumount /media/madusanka/KINGSTON- "/media/madusanka/KINGSTON" is "Mounted on" value that is given by the first command
sudo dosfsck -a /dev/sdb1- "/dev/sdb1" is "Filesystem" value that is given by the first command.
Enter your password
Check the Pendrive by pasting or creating a new file.
Quick fix methods:
Method 1
Sometimes we can accomplish the task from bash without trouble I usually do (no sudo required)
mkdir /media/$USER/mydrive/myfolder
cp -r src/ /media/$USER/mydrive/myfolderHowever, sometimes, when I need to use file browser,
sudo nautilus /media/$USER/mydrive/Note: this is a quick fix, use it only if you get frustrated because no other answers above worked
Method 2
Reboot OS
try below strategies
edit /etc/fuse.conf as superuser
change
#user_allow_othertouser_allow_otherenable write support for external devices
sudo apt-get install ntfs-configsudo ntfs-config
This is because your file system is NTFS and it is in an unsafe stat, maybe you are using your disk in windows, one of the reasons is that you hibernated the windows or fast restarted it., so use one of these steps:
unmount the media using the below command, go to windows (maybe Dual boot mode or maybe in an another computer) and shut down the windows completely, not hibernate or fast restart,
sudo umount /media/"your media label"
then come to Linux again and mount your media using this command:
'sudo mount -o rw,mount /your media'if you are using macOs , plug your media to your mac device and use this command:
'sudo /usr/sbin/diskutil disableJournal /Volumes/name-of-media'
All you need is following 3 commands.
df -Th
umount /media/user/KINGSTON(this is mount on path)dosfsck -a /dev/sdb1(this is Filesystem path)
When you attach your Pendrive to your laptop:
1. run sudo -i (so that you won't type your password all the time)
2. run df -Th(to see where your USB stick is mounted)
3. unmount your USB stick
4. run dosfsck on the device you saw from your previous command. Example: dosfsck /dev/sdc1
5. Run above command again and again until you get this responsefsck.fat 4.1 (2017-01-24) /dev/sdb1: 4 files, 170684/976272 clusters
6. Mount device nowNow try to remove or add more files
I have the same bug with Thunar (Xubuntu 16.04-18.04). Killing it wouldn't be an option as sometimes I already have opened Thunar windows that I need. I discovered a workaround. First, we need to turn off automount: Settings => Removable Drives and Media => Turn off first two options. Second, after inserting the USB medium, right-click on it and choose "Connect". Or disconnect then connect using the right-click.
It is sad, that the workaround usually works with FAT, but doesn't always work with EXT4. :(
One thing I find unique regarding Ubuntu users is that you guys find these ubiquitous problems, and solve them by trial and error. FAT file systems don't have acls, so changing those (chown, chmod, etc) won't be preserved. The changes are made in system memory and applied to the file systems with pointers.
FAT wouldn't work with Linux if not for the pseudo-acls. It makes Linux think they're there, but they're just for compatibility. Ubuntu and most other *NIXs remount ro on file system errors. So if you run dosfsck on a file system that won't mount rw, and unplug and replug, it should mount rw.
UDEV controls automounter, so depending on the way the rules are written, that can cause mount to switch to ro. You just have to look in the rules' files and figure out what it's doing in /sys`.
But it really looks pretty good, lots of solutions. Thanks everyone!
What did it for me was plugging it in a different USB port on my machine; possibly a USB 1.0 or 2.0 one.