USB Disk stuck in read only after dd an ISO

This has probably been asked before but I have not been able to find it so I'll ask again. Here's what I did:

sudo dd if=./windows.iso of=/dev/sdb

#sdb is a 64gb USB disk

Afterwards I was unable to add to the disk so I formatted it to NTFS and tried to manually copy the files over at which point I got this error:

enter image description here

I don't think it is a problem with Ubuntu so much as it is a problem with dd, or my ability to use dd, because I have previously had the same problem with dd on both mint and cyanogenmod.


Solution 1:

A quick fix (and sort of a hack) to get it out of read only mode, (this will delete the contents of the usb device!!!) is to open "startup disk creator" in ubuntu and choose to erase the device and it will be out of read only mode.

"that worked. but why? how can I do that in terminal?"

I don't know exactly why but it seems to be python related. I'm doing some digging and will report back with any findings.

How to in terminal:

According to this post you can change the read only attribute using hdparm like so (assuming the device is /dev/sdb):

sudo hdparm -r0 /dev/sdb

Then, remount the device. That may involve simply unplugging and plugging the device back in or you could run the following command to remount the device in read/write mode:

sudo mount -o remount,rw /dev/sdb /media/$USER/8E22-6590

Solution 2:

First find out the device: lsblk

Suppose the USB stick is on /dev/sdb. If any of its partitions are mounted, then unmount them all.

Let's zero out the device. This will completely wipe out all of its partitions and data. Please make sure you dd the correct device, here in case /dev/sdb

$ sudo dd if=/dev/zero of=/dev/sdb; sudo sync

Use any disk utility of your choice (gdisk, fdisk, gparted) and create a partition on it.

$ sudo gdisk /dev/sdb

Command (? for help): n
Partition number (1-128, default 1): <enter>
First sector (34-15634398, default = 2048) or {+-}size{KMGTP}: <enter>
Last sector (2048-15634398, default = 15634398) or {+-}size{KMGTP}: <enter>
Hex code or GUID (L to show codes, Enter = AF00): 0700
Changed system type of partition to 'Microsoft basic data'

Command (? for help): w
    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/disk1.
The operation has completed successfully.

gdisk doesn't create filesystems, so run ..

$ sudo mkfs.vfat /dev/sdb1