5

I have a usb flash memory which I can't do anything on it because its read only:

sudo fdisk -l

Device     Boot   Start     End   Sectors  Size Id Type
/dev/sdc1  *     2048    7864319 7862272  3.8G  b W95 FAT32

I've tried to fix file system with mkfs and I got this :

sudo mkfs.fat -F 32 /dev/sdc1

mkfs.fat 3.0.28 (2015-05-16)
mkfs.fat: unable to open /dev/sdc1: Read-only file system

How can I fix this?

PS: Let's assume the USB is not write-protected by design, such as with a manual switch.

12
  • The command mount (probably as root) is the one to use to change mounted filesystem state, not mkfs. Commented Dec 18, 2017 at 19:35
  • 5
    Is this a sandisk usb? Some have a hardware 'safety lock' that locks the usb to read-only in the event of a usb power fluctuation. I had one that did this and had to be returned, though they replaced it FOC. Commented Dec 18, 2017 at 20:43
  • 1
    Is it plugged into a USB 3.0 socket (the blue kind)? I have a 4 GB flash drive that mounts as read-only when connected to USB 3.0, but I can write to it when I use the older USB sockets on the same computer (running Xubuntu 16.04). Commented Dec 18, 2017 at 21:46
  • we have same distro but unfortunately my laptop does not have any USB 2.0 socket.I will try it on another laptop .Thanks Commented Dec 19, 2017 at 7:31
  • 2
    Have you read unix.stackexchange.com/questions/74090/… is proposes blockdev --setrw or hdparm -r 0 Commented May 20, 2018 at 20:26

1 Answer 1

4
  1. Make sure you are performing filesystem management actions with escalated privileges. Most systems do not let users modify filesystems.

  2. Ensure the device isn't already mounted. As root, execute lsblk and look for any filesystems using /dev/sdc1. If it is mounted you will have to unmount prior to formatting with mkfs.

  3. Make sure the device is not a read-only UFD. Though uncommon, these do exist ... usually as hand-outs from vendor booths with product sheets or other vendor info on them.

Quick walkthrough of steps

  1. Verify you are performing all tasks as root. Best way is to simply open a shell as root: In a terminal, execute sudo -i is usually the easiest way.
  2. Unmount the device with umount /dev/sdc1 (may give error info if it is not mounted, no worries if this happens)

VVV WARNING THIS WILL DESTROY ALL DATA ON THE DEVICE VVV

  1. Format the device mkfs.vfat /dev/sdc1 (you can force 32bit size if you wish, but mkfs will select whatever fits best for the size of the volume)

If this does not work, you may want to wipe the device, recreate the partition with fdisk, and try again:

wipefs -a /dev/sdc

Again, this will destroy any remaining data. You have been warned.

7
  • I unmount it before I use these commands. Commented Dec 18, 2017 at 19:46
  • 11
    wipefs also invokes error read only file system Commented Dec 19, 2017 at 7:28
  • 7
    mkfs.vfat: unable to open /dev/mmcblk0: Read-only file system still the same error Commented Apr 6, 2019 at 14:26
  • 1
    How does this help one get write access to the filesystem? I mean sure, I can overwrite it, no problem. But there is a deep mystery as to why this DOS image I wrote to it only mounts readonly. Commented Nov 29, 2019 at 4:25
  • This worked for me: I used the pendrive to create boottable linux installer Commented Apr 26, 2020 at 18:29

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.