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?

  • The command mount (probably as root) is the one to use to change mounted filesystem state, not mkfs. – Isaac Dec 18 '17 at 19:35
  • 2
    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. – bu5hman Dec 18 '17 at 20:43
  • 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). – Gaultheria Dec 18 '17 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 – ali73 Dec 19 '17 at 7:31
  • 1
    Have you read unix.stackexchange.com/questions/74090/… is proposes blockdev --setrw or hdparm -r 0 – Sandburg May 20 '18 at 20:26
  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)


  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.

  • I unmount it before I use these commands. – ali73 Dec 18 '17 at 19:46
  • 5
    wipefs also invokes error read only file system – ali73 Dec 19 '17 at 7:28
  • 1
    mkfs.vfat: unable to open /dev/mmcblk0: Read-only file system still the same error – mirkobrankovic Apr 6 at 14:26
  • 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. – Bernd Wechner Nov 29 at 4:25


backup usb data first !!!

# install
apt install gparted

# run  

# remove partition from usb and create new with:

# show discs
fdisk -l

# command line
mkfs.ext4 -F -L "usb" /dev/sdc1

# clear read only
hdparm -r0 /dev/sdc1

# media user folder
chown -R username:username /media/username
chmod -R 0777 /media/username

# mounted usb folder
chown -R username:username /media/username/usb
chmod -R 0777 /media/username/usb

And it works (how long ... who knows)

Mount example with params

# un mount
umount -a

# create dir
mkdir usb9

# mount dev
mount -o uid=500,gid=user,rw,mask=0007 /dev/sdc1 /media/username/usb9

# mounted usb9 folder
chown -R username:username /media/username/usb9
chmod -R 0777 /media/username/usb9

For dev test

fsck /dev/sdc1
dosfsck -a /dev/sdc1
df -Th
modprobe usb_storage
badblocks -v /dev/sdc1
hdparm -r0 /dev/sdc1
# warning
dd if=/dev/zero of=/dev/sdc1

Not the answer you're looking for? Browse other questions tagged or ask your own question.