Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
31
rated 0 times [  31] [ 0]  / answers: 1 / hits: 170694  / 1 Year ago, sun, april 30, 2023, 5:21:53

Somehow I messed up and accidentally made my usb stick into a read only file system. I have tried a bunch of things to delete the files, including the basic (rm -f myfile) and attempting to allow writing (sudo chmod +w myfile) and then deleting, but none of this seems to work. Any ideas on what I can do. I don't have anything on the usb stick that I need, but I don't want to throw away an otherwise perfectly good piece of equipment.



How can I make it work? Am I going about this completely the wrong way?


More From » filesystem

 Answers
2

Commands like rm and chmod are done on a mounted file-system. So if the file-system is read only those do not work. What you need to do is to mount the file-system as writeable.



Some USB sticks have a switch on the stick to mount them read-only. Maybe that is the
reason. It could also just be broken or damaged due to not correctly umounting it.



Before you do anything: copy the files over from the stick.



If it is not a hardware switch unplug and plug the USB stick and issue a



dmesg | grep -i panic


This will show you any panic messages. If you are seeing alot of them related to the USB stick and if it is a FAT partition you can use dosfsck to fix it.



You can find out how it is mounted with



mount


and use



dosfsck -a /dev/sd{xn}


to fix an MS-DOS partition table or sudo mkfs.vfat /dev/sd{xn} to format the disc. Where {xn} is a letter and digit you got with the mount command.



You can also use gparted to format it by the way.


[#43706] Monday, May 1, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
oileweaty

Total Points: 337
Total Questions: 108
Total Answers: 105

Location: Western Sahara
Member since Mon, May 3, 2021
3 Years ago
oileweaty questions
Thu, Jul 1, 21, 01:57, 3 Years ago
Wed, Nov 24, 21, 11:48, 2 Years ago
Sat, May 14, 22, 00:50, 2 Years ago
;