Linux – How to remove iso 9660 from USB

iso-imagelinuxpartitioningusbusb-flash-drive

I have somehow managed to write an iso 9660 image onto my USB drive, which makes all my computer think that the device is actually a CD. I have tried various methods of removing this partition, but nothing seems to work. I have tried fdisk, which says

$ fdisk -l /dev/sdb
Cannot open /dev/sdb

parted crashes when I try to use it on this device.

I have even tried

$ dd if=/dev/zero of=/dev/sdb

but it just hangs with no output (either on screen or on disk). However, when I plug the USB in, it does mount, and I can view (but not edit) the files on it.

edit: now the result is

$ dd if=/dev/zero of=/dev/sdb
dd: opening `/dev/sdb': Read-only file system

I have also tried re-formatting it on Windows, but it gets to the end of the format process and then says "Couldn't format the drive".

How can I remove this partition and get my whole USB drive back to normal again?

EDIT 1: Trying a simple mkfs doesn't work:

$ sudo mkfs -t vfat /dev/sdb
mkfs.vfat 3.0.0 (28 Sep 2008)
mkfs.vfat: Will not try to make filesystem on full-disk device '/dev/sdb' (use -I if wanted)

I can't do mkfs on /dev/sdb1 because there is no such partition, as shown:

$ ls /dev | grep sdb
sdb

EDIT 2: This is the information posted by dmesg when I plug the device in:

$ dmesg
.
. (snip)
.
usb 2-1: New USB device found, idVendor=058f, idProduct=6387
usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1: Product: Mass  Storage
usb 2-1: Manufacturer: Generic
usb 2-1: SerialNumber: G0905000000000010885
usb-storage: device found at 4
usb-storage: waiting for device to settle before scanning
usb-storage: device scan complete
scsi 6:0:0:0: Direct-Access     FLASH    Drive  AU_USB20  8.07 PQ: 0 ANSI: 2
sd 6:0:0:0: [sdb] 4069376 512-byte hardware sectors (2084 MB)
sd 6:0:0:0: [sdb] Write Protect is off
sd 6:0:0:0: [sdb] Mode Sense: 03 00 00 00
sd 6:0:0:0: [sdb] Assuming drive cache: write through
sd 6:0:0:0: [sdb] 4069376 512-byte hardware sectors (2084 MB)
sd 6:0:0:0: [sdb] Write Protect is off
sd 6:0:0:0: [sdb] Mode Sense: 03 00 00 00
sd 6:0:0:0: [sdb] Assuming drive cache: write through
 sdb: unknown partition table
sd 6:0:0:0: [sdb] Attached SCSI removable disk
sd 6:0:0:0: Attached scsi generic sg2 type 0
ISO 9660 Extensions: Microsoft Joliet Level 3
ISO 9660 Extensions: RRIP_1991A
SELinux: initialized (dev sdb, type iso9660), uses genfs_contexts
CE: hpet increasing min_delta_ns to 15000 nsec

This shows that the device is formatted as ISO 9660 and that it is /dev/sdb.

EDIT 3: This is the message that I find at the bottom of dmesg after running cfdisk and writing a new partition table to the disk:

SELinux: initialized (dev sdb, type iso9660), uses genfs_contexts
sd 17:0:0:0: [sdb] Device not ready: Sense Key : Not Ready [current] 
sd 17:0:0:0: [sdb] Device not ready: <> ASC=0xff ASCQ=0xffASC=0xff <> ASCQ=0xff
end_request: I/O error, dev sdb, sector 0
Buffer I/O error on device sdb, logical block 0
lost page write due to I/O error on sdb

Best Answer

Okay, it turns out that in this case something (possibly when I wrote the iso-9660 file system to the drive) has triggered some form of internal write protection on the drive. There are no external write protection / hold switches, but yet this is the output in dmesg when I run

dd if=/dev/zero of=/dev/sdb

as root:

sd 9:0:0:0: [sdb] Add. Sense: Write protected
end_request: I/O error, dev sdb, sector 4028744
sd 9:0:0:0: [sdb] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE,SUGGEST_OK
sd 9:0:0:0: [sdb] Sense Key : Data Protect [current] 
Info fld=0x0

Note the comments in there about protection! However, when I plug the device in, I get,

scsi 10:0:0:0: Direct-Access     FLASH    Drive  AU_USB20  8.07 PQ: 0 ANSI: 2
sd 10:0:0:0: [sdb] 4069376 512-byte hardware sectors (2084 MB)
sd 10:0:0:0: [sdb] Write Protect is off
sd 10:0:0:0: [sdb] Mode Sense: 03 00 00 00
sd 10:0:0:0: [sdb] Assuming drive cache: write through
sd 10:0:0:0: [sdb] 4069376 512-byte hardware sectors (2084 MB)
sd 10:0:0:0: [sdb] Write Protect is off
sd 10:0:0:0: [sdb] Mode Sense: 03 00 00 00
sd 10:0:0:0: [sdb] Assuming drive cache: write through

Note that this message says that the device is not write protected! So unfortunately, it looks like the disk has had it (i.e kaput).

Related Question