format us protected write linux ubuntu code example

Example: remove write proteced in usb ubuntu

Unmount it, and make it writeable

sudo umount /dev/sdb1
sudo hdparm -r0 /dev/sdb
Create a new mount point and mount it there (my userID from /etc/passwd is 1000)

sudo mkdir /media/andrew/temp
sudo mount -o uid=1000 /dev/sdb1 /media/andrew/temp
it'll still complain that it's read-only. I don't know why I had to change this flag before AND after mounting, but that's the only way it worked for me. Set it to writeable again, and remount it at the same place

sudo hdparm -r0 /dev/sdb1
sudo mount -o remount,rw /dev/sdb1
Now I can write to the disk as my normal user. I'm being very careful with it in case it is actually failing, but those commands allowed me to finish what I was doing.