How do I reformat a USB stick containing read-only files?

Too many suggestions already give for you.
As last alternative: Try to format in a PC with Windows.
Any a can solve. Win 7, 8, or 10. :exploding_head:

1 Like

Again, thank you to you all for suggestions to try and solve this difficulty. At the moment, I am learning how to use the terminal and navigate my way through the file heirarchy. I started using Dan Tripp’s suggestion because I was imitating his typing; however after entering the command: w enter, a message appeared:
fdisk: failed to write disk label:operation not permitted.
Disk label type is: dos
And so I could not get any further with that one.
cordx suggested seeing if my drive was in /etc/mtab and if it was mounted read-only. What do I type in the terminal to do that please?
Am I right in thinking for gparted to delete a partition the drive needs to be unmounted?
Will try the other methods and report back. Thanks again

1 Like

cat /etc/mtab will print out the contents of your mtab in the terminal. there will be a lot of info printed out. my three usb’s are at the very bottom so hopefully the drive you are looking for will be as well.

for example, my 4 gb usb is listed as:

/dev/sdcX /media/myusername/vol_work vfat rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro 0 0

the part you are interested in is just after the filesystem type (vfat in this case) where mine says rw (read/write), you are looking to see if yours says ro (read only).

I can only think that you didn’t use sudo… make sure nobody (e.g. you) doesn’t have a file manager (e.g. nautilus) session looking at the mounted drive, or - a shell session in the mount point directory (check all your terminal sessions, close any you don’t need, make sure you’re in “~” - i.e. $HOME - “cd ~”).

sudo fdisk /dev/[device]” shouldn’t care whether it’s mounted, but might barf if a user has a “session” looking at the mount point…

I don’t usually use youtube for software tech support or recommend it - but his might help you :

1 Like

Hi Guys: Thanks for the suggestions. Here is some promised feedback of how I am getting on. I ‘cat /etc/mtab’ my usb drive and yes it is ro. I then used the method in the youtube video Daniel suggested and it indicated it had changed the ro to rw. However when coming to format the disk, the files were still present.
While using GParted on the usb disk, it was written the File system was fat 16, status : unmounted; Path: /dev/sdd1
Cant’t open /dev/sd11: No such file or directory
Cannot initialise ‘::’
label: Cannot initialise drive
Can’t open /devsdd1: No such file or directory
Cannot initialise ‘::’
fsck.fat4.1 (2017-01-24)
open: No such file or directory
Unable to read the contents of this filesystem!
Because of this some operations may be unavailable.
The cause might be missing software package.
The following list of software packages is required for fat 16 filesystem support: dosfstools, mtools
Does this suggest I need to install added software to read the filesystem before it can be altered?
I have also tried using Windows to format the usb but it did not.
Will keep trying the above suggestions.

1 Like

What do you mean? After formatting?

WARNING: the -f option allows usage on a mounted drive, so be absolutely sure you select the correct drive.
You can remove the f option, if you manage to dismount the target drive.

sudo badblocks -svf /dev/sdd -o badblocks1.log

You also may add the w option, since you don’t care to keep the files on the drive. Adding the w option usually overwrites all files on the target drive.

1 Like

After I tried formatting the USB drive with GParted, I got the warning message above in my previous post which to me indicated the drive had not been formatted.
I then checked to see if the files in the locked folder had gone; but they had not.
It seems to me because I did not create the locked folder I need to either change the ownership or override the write protection. I will continue trying the above suggestions. Thanks again for your help.

1 Like

Another phenomenon that could explain this is that you try to mount the stick with the wrong file system. E.g. I once mounted a ZFS enabled disk as NTFS and it showed some old data from before I enabled ZFS on it. The data was, as expected, still on the HDD, but it just became visible after deletion because of using the wrong file system when mounting the medium.

A post was split to a new topic: How to enable read-write permissions on a USB flash drive

Use the Gparted and delete the partition.
After make other with the system files intended: ext4, reiserFS, ntfs …egc…
Done ! :grinning:

@ Sheli
Very sorry I entered in this thread very late. I have suggestion to make. Please open" Disks" from Menu Dash and you will find your Pen drive listed in the left side… Select it And Press Ctl+F. After that right click on the USB icon on the destop and you will have Format Menu as context Menu. Click it anf format will start. I found it working in Linux Mint 19.2.

Thank you again to everyone who has tried to solve this problem. I have tried ubhat’s suggestion but that has not worked either. I have used Gparted to delete the partition and the locked files are still there. I shall keep trying because this has become a challenge and perhaps all of us could learn something from this.

did you ever try

and/or something like smartmontools to try and make sure that the disk itself is sound?


Hi. Yes, I have just tried the ‘badblocks’ method and got the following message: Checking blocks 0 to 7711
Checking for bad blocks (read-only test): 0.00% done, 0.00 elapsed. (0/0/0 errors)
Pass completed, 0 bad blocks found. (0/0/0 errors)

Do you think it actually checked the USB drive since it gave 0.00% done?
As to the smartmontools, I have not tried. I clicked on the link and had a look around but my Linux experience at present does not extend to that. Thanks for getting back, it’s taking a while.

1 Like

Your device is probably broken.

There was a discussion about a very similar situation. You should read that one, as it explains a lot of possible reasons for the symptoms you experience.

Oh dear. Could you roughly point me in the general direction the discussion was held please so I can read it? Thanks

There is a search button in the top bar.

Thanks. I think I have found what you were referring to.

@sheli I am interested in this subject. I would like to suggest three methods which you may tryif you and have not tried already:

  1. click on Disks in main menu. find you USB and click on it . in the right side you will fin wheel s (3rd item) click on it and you will find a list of Menus relating to the disk. You may try all one by one or any selected by you.

  2. in your terminal issue lsblk to find out your drive and the issue the following command
    sudo dd if=/dev/zero of=/dev/yourdrive

  3. in your terminal issue the following commands
    sudo add-apt-repository ppa:mkusb/ppa # and press Enter
    sudo apt-get update
    sudo apt-get install mkusb
    you will get a prompt click “YES”
    Now “mkusb” will ask you if you wish to proceed with the formatting of the data, ‘Stop’ will be selected by default. You now select ‘Go’ and click ‘OK’.
    The window will close and your terminal will look like this.

    In a few seconds, the process will be completed and you will get a window popup saying "IMAGE NOT FOUND
    Please remove the disk and reinsert again to see whether it is formatted.
    Hope one of the method will work for you.:slightly_smiling_face:

@Sheli SorryI forgot the most important one. It is “Testdisk” This used by forensic. You will have to install it by
sudo apt install testdisk
and after installation in terminal issue: $ testdisk
you may find about it in :