How to remove iso 9660 from USB?

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).


I am new to this Linux sys admin stuff, so when I had exactly the same problem I poked and prodded with no madness to my method but managed to remove the iso9660 fs and reclaim the thumb drive.

sudo fdisk -l  /dev/sdb1

returned

Disk /dev/sdb1: 16.0 GB, 16037969920 bytes
64 heads, 32 sectors/track, 15295 cylinders, total 31324160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I>/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x57155aa7

     Device Boot      Start         End      Blocks   Id  System
/dev/sdb1p1            2048    31324159    15661056    5  Extended

So I then tried

sudo fdisk /dev/sdb1

Command (m for help): m
Command action
  . . .

followed by

Command (m for help): d Extended
Selected partition 1

Command (m for help): v
Remaining 31324159 unallocated 512-byte sectors

Then when prompted again selected for fdisk to create an empty dos partition table (something I figured I could overwrite with whatever I wanted later)

Command (m for help): v
Remaining 31324159 unallocated 512-byte sectors

Command (m for help): o
Building a new DOS disklabel with disk identifier 0xea06616f.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

I took the returned messages to mean that I at least "broke" the iso9660 fs so went on to try mkfs

sudo mkfs /dev/sdb1

mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
979200 inodes, 3915520 blocks
.195776 blocks (5.00%) reserved for the super user
First data block=0
.Maximum filesystem blocks=4009754624
120 block groups
32768 blocks per group, 32768 fragments per group
8160 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

All this left me with the "lost+found" directory on the thumb drive.

sudo mount /dev/sdb1 /media/
ls /media/
lost+found

Finally, I went to the Ubuntu website (http://www.ubuntu.com/download/ubuntu/download, section 2) and used the stick to create a bootable image of Ubuntu for trial use, and it let me. The beauty of the Ubuntu images made on the stick this way is that they can be deleted easily and the stick reclaimed for other use.

I mention this very last step because in hindsight I wonder if I had done just that in the first place that it would have worked, I dunno. As mentioned, I am new to this Linux stuff and am trying different distro's (e.g. Fedora, Ubuntu, etc.) on live cd's with whatever media is most convenient, and I sure do break a lot of stuff along the way.


mkdosfs -I /dev/sdb

will create a vfat file system on the drive. The -I has to be passed if you want the file system to be created on the entire drive and not on a partition. If you want to partition the drive first, use fdisk. Of course fdisk can't read the drive now, because it doesn't have any partitions. But I'm sure it will be able to write to it.