How to remove iso 9660 from USB?

22

2

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

a_m0d

Posted 2009-07-29T05:52:34.903

Reputation: 988

+1, interesting situation. i'm suspicious; i wonder if it's actually the device firmware borking things up or if the linux scsi driver is getting in the way somehow. but since the dd and fdisk attempts all fail, you'd have to hack into scsi directly to know for sure. – quack quixote – 2010-02-27T07:16:29.813

Dunno - but it doesn't seem to work with Windows either, so I'm guessing that it's the device itself that's stuffed – a_m0d – 2010-02-27T08:11:16.393

Are you sure it is always loading at /dev/sdb? If you look at the end of /var/log/messages after the device is installed you will see the log messages relating to its automount. – mas – 2009-07-29T06:20:28.467

Yeah, it definitely is - see edit to question. – a_m0d – 2009-07-29T06:28:08.700

How did you manage to write that image on it? I'll try to reproduce it on my old drive later, maybe I'll be able to find a way to fix it. – Kirill Strizhak – 2009-07-29T06:36:40.650

3Are you sure it isn't currently mounted with cdfs or the equivalent? – RBerteig – 2009-07-29T06:46:49.630

1@Slink84: I think I just went sudo dd if=some.iso of=/dev/sdb - I can't remember doing anything else that could do it – a_m0d – 2009-07-29T06:57:33.447

@RBerteig: No, I made sure that it was unmounted / ejected before trying anything – a_m0d – 2009-07-29T06:58:13.617

I don't know, can't reproduce it :\ I've tried the same sudo dd with iso9600 file, but didn't get the same result. Any additional info on the device and image used? – Kirill Strizhak – 2009-07-29T22:15:01.080

1The image was an eeebuntu-3.0.0-standard image - don't know who makes the device, but I think that it is Toshiba – a_m0d – 2009-07-29T23:02:15.837

1

From the VID/PID pair, it is made by "Alcor Micro Corp.", and is a "Transcend JetFlash Flash Drive". I use the list at http://www.linux-usb.org/usb.ids to look these things up.

– RBerteig – 2009-07-30T07:22:23.607

This is a nifty little problem you have here. I'd upvote your question more than once if I could... – RBerteig – 2009-07-30T07:49:45.237

Yes, it is very interesting, because Linux refuses to let me write anything to the device - it is adamant that the device is read-only! I have zero-ed the whole thing with dd and yet none of that got written to the device! – a_m0d – 2009-07-30T08:41:33.797

Answers

8

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

a_m0d

Posted 2009-07-29T05:52:34.903

Reputation: 988

I heard in the past about flash devices which became bricked if you ever used a non-FAT filesystem with them (because they used the FAT to know which blocks were unused and could be discarded). I have not heard of that for a long time, and I could not find anything about it with a quick Google search. – CesarB – 2009-08-25T15:24:45.930

So far I have found one person mentioning the FAT dependency: http://linux.derkeiler.com/Mailing-Lists/Debian/2008-08/msg00761.html

– CesarB – 2009-08-25T15:38:49.787

Sorry to hear that it's dead... Heh, I should be glad that I didn't manage to reproduce your problem :] Although I've tried it on an old 'disposable' drive, it still would be sad to lose it that way. – Kirill Strizhak – 2009-09-02T06:27:25.650

yeah, especially since it was only about a week old! oh well... – a_m0d – 2009-09-03T01:01:45.253

1

Found what I was looking for: http://lkml.org/lkml/2009/3/16/363 ("Some SDD manufacturers (I don't know which ones) are actually examining the partition table and doing different things. I know this because they are permanently bricked if one writes an invalid partition table.")

– CesarB – 2009-09-10T18:04:12.643

@a_m0d: Is this by chance a stick with warranty? I have some with 2 or 4 years, one even with lifetime warranty. If there's no sensitive data in the image, I'd try to return it. – ott-- – 2011-11-23T20:25:37.410

@ott-- probably not. It was a while ago now, and I've just abandoned the stick. It probably had a small one on it, but since it was only a fairly cheap stick I didn't bother returning it. – a_m0d – 2011-11-24T04:20:53.310

@a_m0d one last thing: has this device node the mount option errors=remount,ro? If yes, you could try to change it to errors=continue. – ott-- – 2011-11-24T08:09:05.103

6

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.

David Cantwell

Posted 2009-07-29T05:52:34.903

Reputation: 61

I'd love to try your steps to see if that would fix it, but I don't seem to have the stick anymore, so unfortunately I don't know if they would help. Nevertheless, this might still be helpful to others with the same problem. – a_m0d – 2011-11-24T04:22:54.227

5

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.

Kim

Posted 2009-07-29T05:52:34.903

Reputation: 2 238

1this worked for me to remove a Centos bootable image when the above solutions had all failed. – Ⴖuі – 2015-09-07T23:23:24.780

Doesn't work - just prints the version number and exits. Also, fdisk is "Unable to write /dev/sdb" – a_m0d – 2009-07-29T07:12:23.963

i just tried the command and it does write to the device specified. It also only prints the version number. You can test this with a regular file that you created with dd. You can see the changes it makes with od. My guess is that it's a hardware problem. – Kim – 2009-07-29T15:17:35.510

2

Looking at the dmesg snippet, it seems something is automaticaly mounting the drive (check with mount). Before doing anything with it, you should umount it by hand.

Then zero the block with the partition table (dd if=/dev/zero of=... bs=512 count=1), and run a partitioning tool to recreate an empty partition table. After that, unplug and replug (should not be needed, but...) and create/format the partitions you want on it. After creating the partitions (perhaps you will have to unplug and replug again), you should have /dev/sdb1 or something like that, which is where you should create the filesystem.

Note that all steps should be done as root (with sudo or an equivalent). Be careful to not write the wrong device name, or you could wipe your harddisk!

CesarB

Posted 2009-07-29T05:52:34.903

Reputation: 4 480

1I have done that, but even though the whole disk seems to be filled with zeros, it still somehow mounts and reads the disk! – a_m0d – 2009-07-29T21:57:17.403

1

Maybe with a simple

mkfs -t vfat /dev/sdb1

Vinko Vrsalovic

Posted 2009-07-29T05:52:34.903

Reputation: 2 276

Doesn't work - see edit to question – a_m0d – 2009-07-29T06:18:37.910

1

I still feel that we are assuming something that's going to turn out to be untrue. Since the device is readable, this line will at least let you see the data for yourself, rather than depending on the other programs' interpretations.

 dd if=/dev/sdb  count=1 | xxd -g1 -u 

Also, maybe we could separate problems with the dev node from problems with what's on the device, by forcing it onto another port. Either plug it into another USB jack, or plug another drive in first, to occupy sdb.

gbarry

Posted 2009-07-29T05:52:34.903

Reputation: 694

hmm ... using this command tells me that the device is filled with zeros, which is probably because I finally managed to get dd if=/dev/zero of=/dev/sdb to run on it. But yet fedora still mounts the device as an ISO9660 fs when it is plugged in! – a_m0d – 2009-07-29T21:54:59.980

Does Linux still use /etc/fstab ? That's where these "associations" used to be stored. – gbarry – 2009-07-30T06:51:24.480

No, its using (I think) udev, or whatever it is that automatically mounts the drive. – a_m0d – 2009-07-30T13:39:05.487

1

Currently your USB drive got no partition table, iso9660 filesystem sits directly on whole disk (just like a cdrom)

sd 6:0:0:0: [sdb] Assuming drive cache: write through
 sdb: unknown partition table

I think you need make a partition first

sudo cfdisk /dev/sdb

(make sure it's not mounted before) in the fdisk application create a new partition.

after that is done, make the filesystem on the new partition

sudo mkfs -t vfat /dev/sdb1

Joakim Elofsson

Posted 2009-07-29T05:52:34.903

Reputation: 2 056

Tried this; cfdisk doesn't produce any error messages, but a quick look in dmesg shows there is actually an error message. (see Edit 3 in question above) – a_m0d – 2009-07-29T22:00:22.090

1

I had the exact same problem as you. However, I was able to find a solution from a surprising place. An old laptop with Windows 98SE on it, which is the last Windows system I ever owned. Anyway just put it in and when you try to access the drive Windows will ask you if you'd like to format it. Click yes and you'll have a fat16 formatted drive that's fully functional. I don't know if it works with newer versions of Windows though. Best of luck.

Anonymous

Posted 2009-07-29T05:52:34.903

Reputation: 11

All the way up to Windows 8 :) – Sebastian Godelet – 2013-07-02T19:40:28.777

1

Last night I did

dd if=fedora.iso of=sdx  

After four hours I had an unbootable, unchangeable, iso9660 brick. Following David's train of thought, I called Ubuntu's 'startup disk creator' (Type 'startup disk creator' in the dash), and merely selected 'erase'. That did it.

The USB drive was then reported as FAT32 and all is well.

dan

Posted 2009-07-29T05:52:34.903

Reputation: 11

Sometimes it is appropriate to use a hammer, like this. I wonder what was in the first few sectors of the drive. – vgoff – 2012-11-05T15:20:10.290

0

The best and proper way to do it is:

# wipefs --all /dev/sdX

As from the wipefs manual:

wipefs can erase filesystem, raid or partition-table signatures (magic strings) from the specified device to make the signatures invisible for libblkid.

wipefs does not erase the filesystem itself nor any other data from the device. When used without any options, wipefs lists all visible filesystems and the offsets of their basic signatures.

wipefs calls the BLKRRPART ioctl when it has erased a partition-table signature to inform the kernel about the change.

This has many advantages like informing the kernel about the change (so you don't get any errors when formatting afterwards), not erasing data nor filesystems, and so on.

emi

Posted 2009-07-29T05:52:34.903

Reputation: 121

0

Remove the drive and see if you can still read from it. I wonder if somehow /dev/usb (or wherever you read from) has become an ordinary file directory.

gbarry

Posted 2009-07-29T05:52:34.903

Reputation: 694

Tried this - when I plug it back in, it mounts it fine, and I can read everything fine. According to mount, it is an iso9660 file system. However, gparted just shows 2GB of un-allocated space on the drive. dd complains that /dev/sdb is a read-only file system – a_m0d – 2009-07-29T07:49:22.843

0

Have you tried to re-mount it with -t option?

umount /dev/sdb
sudo mount -t vfat /dev/sdb /mnt/point

If that won't work, I'll try to reproduce it later, when I get home. Seems like an interesting problem. Will be fun to tinker with :]

Kirill Strizhak

Posted 2009-07-29T05:52:34.903

Reputation: 1 119

Hah, nah, doesn't work, because mount checks the file type first – a_m0d – 2009-07-29T09:30:38.223

Yep, suspected as much :] Ok, no more 'out of the blue' ideas. – Kirill Strizhak – 2009-07-29T10:10:35.430

-1

U3 has a utility to remove their U3 partition. It also removes the partition/device created by the utility that creates the iso 9660. This has been confirmed only on a u3 usb stick, but it is able to be formatted now and totally recover the entire space as a flash drive. You might give it a shot.

knockNrod

Posted 2009-07-29T05:52:34.903

Reputation: 1