I'm using Ubuntu 14.04.
I have an SD card that I use with my camera, and I'm trying to delete photos from it. I was able to move them to the Trash, but when I try to delete any of the files out of the Trash I get Failed to delete the item from the trash
.
I can navigate to the .Trash-1000/files
directory on the device, but when I try to sudo rm
the files, I get rm: cannot remove ‘IMG_1483.JPG’: Read-only file system
.
mount
gives me this:
/dev/sdb1 on /media/zack/6562-61611 type vfat (ro,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks2)
I tried re-mounting the device using sudo mount /dev/sdb1 /media/zack/SD -o rw,dmask=0000
and got the same error when I tried to delete the files.
Finally, I have checked the switch on the card itself and confirmed it's in the unlocked position. I tried switching it to locked just in case it was a goofy card and I couldn't delete off of it then either.
What's going on here? How can I get rid of these files?
Update 1: I tried a couple other things in response to aventurin's comment. I took a new picture, then tried to sudo rm
it and that worked. When I went back to .Trash-1000/files
and tried it again, I was able to delete some files but not others:
$ ls
100___12
101___01
102___02 # directories
103___03
...
IMG_1365.JPG
IMG_1374.JPG
IMG_1375.JPG
IMG_1380.JPG
...
$ sudo rm -rvf *.JPG
removed ‘IMG_1365.JPG’
removed ‘IMG_1374.JPG’
removed ‘IMG_1375.JPG’
rm: cannot remove ‘IMG_1380.JPG’: Read-only file system
rm: cannot remove ‘IMG_1381.JPG’: Read-only file system
rm: cannot remove ‘IMG_1383.JPG’: Read-only file system
...
...and so on. I did an ll
right before I deleted those files, and the permissions for all of the .JPG files look exactly the same.
Update 2:
$ dmesg | grep sdb1
[ 714.950034] FAT-fs (sdb1): error, invalid access to FAT (entry 0x6ce0c8c0)
... # a bunch more of those
[ 2192.017345] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[ 2192.663466] sdb1: rw=0, want=105540772768, limit=62325760
[ 2192.663470] sdb1: rw=0, want=105540772744, limit=62325760
[ 2192.663499] FAT-fs (sdb1): error, invalid access to FAT (entry 0xad23600b)
[ 2192.663501] FAT-fs (sdb1): Filesystem has been set read-only
[ 2192.663601] FAT-fs (sdb1): error, invalid access to FAT (entry 0x58f3a807)
[ 2271.537913] sdb: sdb1
[ 2273.782060] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[ 2407.374492] FAT-fs (sdb1): error, fat_free_clusters: deleting FAT entry beyond EOF
[ 2407.374496] FAT-fs (sdb1): Filesystem has been set read-only
I tried sudo fsck /dev/sdb1
and got a lot of errors:
0x41: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
1) Remove dirty bit
2) No action
? 1
...
/.Trash-1000/files/IMG_1483.JPG and
/.Trash-1000/files/117___09/IMG_1737.JPG
share clusters.
1) Truncate first to 5439488 bytes
2) Truncate second to 0 bytes
? 1
I told it to fix them all, but when I run it again they all show up again.
Update 3:
I unmounted the card, and ran sudo fsck /dev/sdb1 -a
. It ran for about 6 hours and still wasn't finished so I eventually Ctrl-C'd it. It mostly seemed to be renaming files with corruped usernames, and was up to almost 18000 files renamed before I killed it (I've certainly never taken that many photos before...).
I then tried sudo mount /dev/sdb1 /media/zack/SD -v -o rw
and got this output:
$ sudo mount /dev/sdb1 /media/zack/SD -v -o rw
mount: you didn't specify a filesystem type for /dev/sdb1
I will try type vfat
/dev/sdb1 on /media/zack/SD type vfat (rw)
Despite not having an error, I still cannot delete the files and get the same old "read-only file system" error.
sudo
for just about everything. I've updated the question with that change, as well as the results of your second suggestion.