USB devices showing as read only

402,120

Solution 1

See this bug.

Run this command to kill Nautilus (Files):

killall nautilus

Solution 2

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 dosfsck on 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.

Solution 3

I 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 /media

I 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!

Solution 4

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.

Solution 5

I'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.

Share:
402,120

Related videos on Youtube

oodles2do
Author by

oodles2do

Updated on September 18, 2022

Comments

  • oodles2do
    oodles2do over 1 year

    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        boot
    

    Results 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)
    
    • davidbaumann
      davidbaumann over 9 years
      chown it, when mounted? How do you mount it? As root? Auto-mount with the file manager's automount?
    • oodles2do
      oodles2do over 9 years
      I normally plug the usb sticks in and then either the window pops up or it's available for me to open and drag and drop files into. I don't normally use the terminal for any copying or anything like that.
    • davidbaumann
      davidbaumann over 9 years
      Plug in, open, and add the result of mount please.
    • oodles2do
      oodles2do over 9 years
      Don't mean to sound stupid, but what exactly do you mean? What code shall I put into the terminal? If that's what you mean to do it in. Thanks!
    • oodles2do
      oodles2do over 9 years
      Oops, here it is simon@simon-VPCEH1L8E:~$ 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)
    • oodles2do
      oodles2do over 9 years
      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)
    • Xen2050
      Xen2050 over 9 years
      You might want to add the results of sudo parted -l and lsblk too, too see what's on what drive. And were the problem devices mounted at the time you ran the mount command? Only see sda5...
    • oodles2do
      oodles2do over 9 years
      Thanks, this is from 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 boot
    • oodles2do
      oodles2do over 9 years
      this is from 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
    • oodles2do
      oodles2do over 9 years
      Is there any way I can edit the original post? The formatting isn't great in the comments
    • Xen2050
      Xen2050 over 9 years
      I'll try & add the info to the Q...
    • oodles2do
      oodles2do over 9 years
      Found out how to do it, I'll do it all now
    • Léo Léopold Hertz 준영
      Léo Léopold Hertz 준영 over 7 years
      Have you found any answer acceptable?
  • oodles2do
    oodles2do over 9 years
    Thanks for your help! I tried to do what you said, is typing umount /dev/sdb1 correct for unmounting my usb stick? Also, I don't know how to use dosfsck. Thanks for the link too
  • Admin
    Admin over 9 years
    @SimonBremford if your USB is mounted in /dev/sdb1 of course your command is right. For your other question, just type: dosfsck -a /dev/sdb1
  • oodles2do
    oodles2do over 9 years
    Thanks for your help, however it didn't work. The usb stick is read only still. I think it's an issue with Ubuntu rather than the usb stick itself, seeing as it was so sudden. And the fact that it's affected more than one usb device at the same time.
  • Xen2050
    Xen2050 over 9 years
    At least the HD is working... USB should be writeable... if you cd into a USB folder, can you write any files with echo stuff >> newusbfile or similar? Or echo stuff | sudo tee newusbfile? Or first run sudo su to "become" root, then the echo, cat, etc?
  • oodles2do
    oodles2do over 9 years
    How do I do the cd commands into the USB folder? I think I just did it into /media/simon and it worked, but the USB is /media/simon/LYDIA
  • Xen2050
    Xen2050 over 9 years
    If the USB isn't mounted, then the /media/simon/LYDIA is just an empty folder (if it's even there). After it's mounted you can see where it's mounted folder is with mount or lsblk, then cd mounted_folder and try writing files, mkdir, etc... and as sudo su to see if you can write as root too...
  • oodles2do
    oodles2do over 9 years
    Thanks for all your help, I just tried to write a file into the usb file but it didn't work, it says it's a read only file system. I've added the code to the question so you can see what I did.
  • Xen2050
    Xen2050 over 9 years
    read-only FS, probably mounted ro (or FS errors preventing rw, or a non-writeable FS like iso9660/cd format). See answer, check mount & try sudo mount -o remount,rw, maybe check logs/dmesg?
  • Xen2050
    Xen2050 over 9 years
    It looks like the usb's filesystem is corrupted - I had that happen often when I used FAT and didn't always umount and wait a few seconds before unplugging. Switching to ext3 seems to have stopped corruption (probably writes a little more though) but maybe there's just something about USB that makes it easily get errors, maybe dirty plugs get worn out easy. Anyway, see the answer about running fsck. And if my answer helps out, select it as correct / check mark it :)
  • oodles2do
    oodles2do over 9 years
    Thanks for helping me, it still hasn't worked though. It probably doesn't help I don't really know what I'm doing. Do you think I should uninstall Ubuntu and reinstall it again to sort this out?
  • Xen2050
    Xen2050 over 9 years
    I think the HD was ok (if it's sda5 with Ubuntu), as a regular user you're not "allowed" to write to every file, maybe a review of Linux filesystems might help (they're generally confusing compared to windows ;) But it could be the USB keeps having problems, maybe fat, and getting remounted read-only too (I added a note about mount might not see changes to ro, but /proc/mounts and dmesg should). Reinstalling Ubuntu probably won't help with the USB, but could always try a different "distro", Xubuntu, Mint (my fav) they might handle usb's different from regular Ubuntu, try some live?
  • oodles2do
    oodles2do over 9 years
    There must be a way to fix this, I just tried sudo chmod 777 /media/simon/LYDIA. The response was: chmod: changing permissions of ‘/media/simon/LYDIA’: Read-only file system
  • oodles2do
    oodles2do over 9 years
    I also tried chmod 666
  • oodles2do
    oodles2do over 9 years
    I don't know if it matters but on both of my FAT32 usb devices in the properties option in the file window it says: Filesystem type: msdos. I thought that it would have said FAT32?
  • Davidenko
    Davidenko over 8 years
    This answer helped me, tnx @PleaseDeleteMe Also I think you should edit the question by adding explanation from the comment for dosfsck command!
  • Gayan Weerakutti
    Gayan Weerakutti about 8 years
    Sometimes the easiest thing to do is to restart
  • vestlen
    vestlen about 8 years
    Worked like a charm!
  • vskubriev
    vskubriev over 7 years
    Yeah, that works. You must create a new partiton table as msdos type, and then create a one big parititon with fat32.
  • Nateowami
    Nateowami over 7 years
    On 16.04 running dosfsck /the/mount/point says open: No such file or directory. I unmounted with umount.
  • Léo Léopold Hertz 준영
    Léo Léopold Hertz 준영 over 7 years
    I think this answer is a stub. Please, expand it.
  • Yasser Sinjab
    Yasser Sinjab about 7 years
    does not work for me
  • Tejaskumar Tank
    Tejaskumar Tank about 7 years
    I tried, but failed to resolve.
  • Nicolas
    Nicolas about 7 years
    For me sudo chown [username] /media/[username] worked fine. I even did not have to take the usb stick out and in (nor did I need chgrp - I am on Xubuntu 16.04)
  • ProProgrammer
    ProProgrammer about 7 years
    Thanks for your answer.. this should be the accepted answer, since there is not really a problem with the media itself but with the mounting point.
  • Xen2050
    Xen2050 about 7 years
    chown can change the group too, chown [username]:[groupname] files is equivalent to running chown and then chgrp. See man chown
  • Lucas
    Lucas about 7 years
    @Xen2050, even better is chown [username]: files since `chown`` will default to the users login group.
  • Xen2050
    Xen2050 about 7 years
    @Lucas thanks that is better. It's cleverly hidden in the man page, but visible in the info page [would be really nice if man & info pages matched...]
  • cst1992
    cst1992 almost 7 years
    This'll erase all data on the drive.
  • OBLE Codemonkey
    OBLE Codemonkey almost 7 years
    It would be useful to add to the answer that a reboot is indeed needed.
  • wayofthefuture
    wayofthefuture over 6 years
    I love spending all day banging my head cause Ubuntu can't even write to a USB stick. Unbelievable.
  • JeD
    JeD over 6 years
    Wow, I cannot believe that worked
  • Tek
    Tek over 6 years
    I'll be damned, this works haha
  • Plenus Franckly
    Plenus Franckly over 6 years
    As the only answer I tried that worked, this should probably be considered the legitimate answer. Thanks.
  • wjandrea
    wjandrea over 6 years
    @PlenusFranckly As helpful as this is, it doesn't fix the same issue that OP is reporting, since in OP's case, the issue affects CLI programs too.
  • tatojo
    tatojo over 6 years
    Uf! It works!!!!!
  • Oki Erie Rinaldi
    Oki Erie Rinaldi over 6 years
    I'm using nemo, so I did killall nemo and it works.
  • travelingbones
    travelingbones over 6 years
    ok, so after killall nautilus, then what? I reopen nautilus and try to copy a file into the mounted usb and it gives the same error
  • wayofthefuture
    wayofthefuture over 6 years
    Then this solution doesn't apply to you I guess... Good luck.
  • Andrew
    Andrew about 6 years
    It's sad that still works in 2018 (Ubuntu 16.04.3 LTS)
  • Antonio
    Antonio about 6 years
    OK. Thanks, this was the solution. However at the end you need to restart your computer in order to have full access to the mounted USBs. Another point worth it I believe, this problem occured after creating a new gpt partition table on a USB stick with GParted. Subsequently all of my USBs were affected. Definitely the guys at GParted should behave differently ...
  • Antonio
    Antonio about 6 years
    See the working solution below posted by Serrano and my comment about it. As well for me the origin came from using GPated ...
  • Vadim Kotov
    Vadim Kotov almost 6 years
    What if I need NTFS? The same for NTFS did not work for me.
  • Pavan Jadda
    Pavan Jadda almost 6 years
    Give this man a medal
  • Edwin Diaz
    Edwin Diaz almost 6 years
    What a strange fix!
  • CodeMonkey
    CodeMonkey almost 6 years
    Strangest fix I've seen. Still works on Ubuntu 18.04
  • wayofthefuture
    wayofthefuture almost 6 years
    Yeah... I went back to Windows. Enough of pulling my hair out.
  • While-E
    While-E over 5 years
    +1 my dude, would not have assumed that was the issue
  • mvsagar
    mvsagar over 5 years
    In my case, the problem is due to usb stick not unmounted earlier properly. Command dosfsck reset the dirty bit and after a few corrections, it could be auto mounted in read/write mode and the problem was solved.
  • Ishtiaque05
    Ishtiaque05 over 5 years
    Wow, amazing it worked!!
  • Márton Tamás
    Márton Tamás over 5 years
    On Trisquel GNU/Linux it will be killall caja (Caja is a Nautilus derivative).
  • Ismail Sensei
    Ismail Sensei about 5 years
    I couldn't believe this worked, my god thank you. for people using Mate instead of Gnome the command should be killall caja (caja is forked from nautilus).
  • marcus
    marcus about 5 years
    I'm on Xfce and just closing all Thunar windows and reopening them worked. I can't believe I had to google that but here I am.
  • mazunki
    mazunki almost 5 years
    This worked for me too. I had lost all sudo access due to being an idiot, and was going to backup some stuff. Cancelled a copy mid-progress, and didn't umount before detaching. Mounted it back in, and was stuck with read-only permissions. killall Thunar fixed it.
  • Achim Schmitz
    Achim Schmitz almost 5 years
    This solution worked for me. The first answer in the list did not apply, because I couldn't work on the USB disk with the console either. Two things to note: 1. The dosfsck stated that the "dirty bit" was set and asked whether to remove it. I said "Yes". 2. There was a directory which "points to root" which was deleted. This resulted in the free cluster count needing to be corrected.
  • davidmw
    davidmw over 4 years
    Make sure you aren't cd'd into the drive when you try to umount it.
  • Digital Ninja
    Digital Ninja over 4 years
    After reading this solution and everyone saying that it works, it became so much funnier reading the comments on that linked bug thread where people are saying they were installing Thunar for a workaround and it works fine, but then also having the original problem on Thunar and installing Nautilus for a workaround :D
  • Xaqron
    Xaqron over 4 years
    List of problems with nautilus is long enough to dedicate a shortcut key to such a command (CTRL+ALT+N I'm using).
  • ubuntuUssser
    ubuntuUssser about 4 years
    For me it did not work
  • Vitor Luiz da Silva
    Vitor Luiz da Silva almost 4 years
    Wow, it is magic!!
  • BioInfo
    BioInfo over 3 years
    Worked for me too :)
  • RNA
    RNA almost 3 years
    worked on Jun 17 '21, Ubuntu 16.04
  • Jeffrey Ross
    Jeffrey Ross almost 3 years
    Didn't work for me with Ubuntu 18.04 and neither did dosfsck, but fsck did resolve it.
  • Jeffrey Ross
    Jeffrey Ross almost 3 years
    dosfsck didn't work for me with Ubuntu 18.04 but fsck did resolve it (FAT32 partition vfat file system).
  • Charlie
    Charlie about 2 years
    This works perfectly.