Ubuntu – How to change read-only pendrive

read-onlyusb-drive

I have a generic pendrive with a problem… I can't copy to inside, delete or move any archive or folder from the pendrive. I don't know how this happens, I do not change any kind of permissions… the only change that I made was change the user password feels days ago.

I try use dosfsck -t -a /dev/sdb1 but without results… some minutes before the Terminal shows:

Contains a free cluster (199578). Assuming EOF. Broke cycle at cluster
119648 in free chain. Unable to create unique name.

I can't even format that… it is useless… anyone can help?

The syslog shows:

Feb  1 15:32:13 everton-Vostro1510 kernel: [ 2714.745488] usb 2-4: USB disconnect, device number 4
Feb  1 15:32:13 everton-Vostro1510 udisksd[1979]: Cleaning up mount point /media/everton/Everton (device 8:17 no longer exist)
Feb  1 15:32:18 everton-Vostro1510 kernel: [ 2720.024168] usb 2-4: new high-speed USB device number 5 using ehci_hcd
Feb  1 15:32:18 everton-Vostro1510 kernel: [ 2720.163813] usb 2-4: New USB device found, idVendor=058f, idProduct=6387
Feb  1 15:32:18 everton-Vostro1510 kernel: [ 2720.163824] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Feb  1 15:32:18 everton-Vostro1510 kernel: [ 2720.163832] usb 2-4: Product: Mass Storage
Feb  1 15:32:18 everton-Vostro1510 kernel: [ 2720.163839] usb 2-4: Manufacturer: Generic
Feb  1 15:32:18 everton-Vostro1510 kernel: [ 2720.163846] usb 2-4: SerialNumber: 4B367433
Feb  1 15:32:18 everton-Vostro1510 kernel: [ 2720.166566] scsi6 : usb-storage 2-4:1.0
Feb  1 15:32:18 everton-Vostro1510 mtp-probe: checking bus 2, device 5: "/sys/devices/pci0000:00/0000:00:1d.7/usb2/2-4"
Feb  1 15:32:18 everton-Vostro1510 mtp-probe: bus: 2, device: 5 was not an MTP device
Feb  1 15:32:19 everton-Vostro1510 kernel: [ 2721.167548] scsi 6:0:0:0: Direct-Access     Generic  Flash Disk       8.07 PQ: 0 ANSI: 4
Feb  1 15:32:19 everton-Vostro1510 kernel: [ 2721.170022] sd 6:0:0:0: Attached scsi generic sg2 type 0
Feb  1 15:32:19 everton-Vostro1510 kernel: [ 2721.176841] sd 6:0:0:0: [sdb] 16000128 512-byte logical blocks: (8.19 GB/7.62 GiB)
Feb  1 15:32:19 everton-Vostro1510 kernel: [ 2721.177843] sd 6:0:0:0: [sdb] Write Protect is on
Feb  1 15:32:19 everton-Vostro1510 kernel: [ 2721.177855] sd 6:0:0:0: [sdb] Mode Sense: 23 00 80 00
Feb  1 15:32:19 everton-Vostro1510 kernel: [ 2721.178963] sd 6:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Feb  1 15:32:19 everton-Vostro1510 kernel: [ 2721.193531]  sdb: sdb1
Feb  1 15:32:19 everton-Vostro1510 kernel: [ 2721.197623] sd 6:0:0:0: [sdb] Attached SCSI removable disk
Feb  1 15:32:20 everton-Vostro1510 udisksd[1979]: Mounted /dev/sdb1 at /media/everton/Everton on behalf of uid 1000

Using the command: cat /proc/mounts | grep sdb

everton@everton-Vostro1510:~$ cat /proc/mounts | grep sdb
/dev/sdb1 /media/everton/Everton vfat ro,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0077,codepage=cp437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro 0 0

Best Answer

There is only two ways that will work everytime, even performing a:

:~$ cd /media

:~/media$ sudo bash

:~/media# cd your_user/pen_drive

:~/media/your_user/pen_drive# chmod 0755 *

:~/media/your_user/pen_drive# chown -R 1000:1000 *

WILL NOT WORK!! DON'T WASTE YOUR TIME, ITS A HEADACHE!

The first involves a 125 line recursive shell script.

The second, the one you should try involves copying all your data to your $HOME directory (/home/your_user). The 0400 bug will not transfer to your local drive or $HOME directory.

After transfer all the data re-format the pendrive, then label it. The re-format from command line will blank the disk. Labeling it will initialize the disk in order to move data from the local disk to the pendrive. Shown below is what you need to do.

(No Brainer: Stick the USB drive in the port)

First run the fdisk with -l flag using sudo to verify the where the device is located (should be /dev/sdb1):

:~$ sudo fdisk -l

next unmount the disk using umount

:~$ sudo umount /dev/sdb1

To reformat the disk use the mkdosfs utility

:~$ sudo mkdosfs -F 32 -I /dev/sdb1

Pull the USB out, then re-insert it. Perform an unmount once again.

:~$ sudo umount /dev/sdb1

Now label the device. Check to see if there is a label first:

:~$ sudo mlabel -i /dev/sdb1 -s ::

Next add a label

:~$ sudo mlabel -i /dev/sdb1 ::your_chosen_name

Keep in mind this assumes /dev/sdb1 is where the device is located at. Also you may not have to pull the drive out and reinserted it. On my lenovo I had to pull it then reinsert it. On my dell I did not. I still do it anyways though.

GOOD LUCK, AND MAY THE FORCE BE WITH YOU!

Related Question