3

I have a 4GB USB drive and I wrote an iso file to it. Now I want to delete the data on it. Is there any way to take the space back?

I used Linux to burn the iso file following these instructions.

At that time, I thought it would be just like using Pendrive Linux to write the iso so I could format the USB disk if I wanted to get storage back but I was wrong. It was like burning an iso file to CD/DVD, meaning that data was burned but cannot be deleted, now I've lost 3GB of storage.

How can I restore the Flash disk to being a normal storage device?

  • Excuse me, could you be more precise? Have you deleted data on the USB, and now you want to get it back? Or is it something different? – MariusMatutiae Dec 8 '13 at 14:54
  • Yes, you just delete the files in the drive. If its an odd format, and windows won't read it. you can probably delete the current partitions and create a new one. I'm sure it can't be that simple though, could it? – Journeyman Geek Dec 8 '13 at 14:56
  • I use linux to burn iso file following this instruction wiki.manjaro.org/index.php/Burn_an_ISO_File. At that time, I think it just like using pendriverlinux to write the iso so I can format the usb if I want to get storage back but I was wrong. It was like burn an iso file to CD/DVD, mean data burned cannot be delete, now I lost 3GB – user280213 Dec 8 '13 at 15:06
7

The term 'burning' does not apply to USB flash storage. Even if some people still call it 'burning' when you write ISO images, that does not matter at all. The USB stick's memory stores the ISO image's contents in exactly the same way that it would store regular files – that is, they can be erased and overwritten with something else.

The only difference here is that the ISO image was written on top of the partition & filesystem information that the OS would use to decide how much space is available. So instead of a 4 GB partition covering the entire flash memory, the OS now sees the partitions that were in the ISO image – that is, a ~1 GB partition with Linux, and 3 GB of "unused" space.

On Linux, you could use any partitioning tool (like the graphical GParted) to just erase all existing partitions and create a full-sized one again, then format that partition with FAT32 as usual.

Unfortunately Windows likes to discriminate against removable disks and USB sticks, but it's still possible to erase the partition information using dd for Windows`, and Windows would just ask to "format" the USB stick afterwards. This command would nuke the first megabyte, which should really be enough to make the OS think the entire disk is unpartitioned.

dd.exe --filter=removable if=/dev/zero of=\\?\Device\Harddisk?\Partition0 bs=1M count=1

Of course, run dd.exe --list first, and replace Harddisk? with the exact name of your USB stick. (Be careful to not erase your system disk's partition table, even though --filter=removable should prevent that.)

  • So, I can get storage back? Can you explain step by step please. – user280213 Dec 8 '13 at 16:29
  • 1
    Boot Linux. Install the "GParted" program. Run GParted. Select your USB stick in the top-right menu. Delete all partitions. Create a very large partition. Click "confirm". – grawity Dec 8 '13 at 16:35
1

When you write an ISO image to a USB flash drive with dd, you overwrite several things on the device, including the partition table. It's often possible to repartition them with a simple partitioner, but you should ensure that the partitioner checks the size of the actual disk, rather than believing the partition table, as some partitioners do. Doing this may be somewhat complex in some cases.

The easiest way to avoid that complexity, in my opinion, is to wipe the USB flash disk's partition entirely:

dd if=/dev/zero of=/dev/sd[letter] bs=1M count=1

WARNING: double-check that the [letter] part in the above is the letter for your actual USB flash drive that you want to reformat. Do this on your computer's main storage device, and you will lose data.

After you've done this, you can recreate the partitions on your flash drive and reformat them. Your partitioner may complain that the flash drive has no partition table on it; this is normal (the dd command that you just ran wiped it) and you should ignore it.

0

It is so because, instead of detecting usb flash drive, it detect it as usb hard drive having multiple partitions.

whole usb will be /dev/sdb

Partitions will be like /dev/sdb1 /dev/sdb2 /dev/sdb3 and so on....

So you need to delete the whole patition and make single partitions.

do the folllowing:-

  sudo fdisk /dev/sdb

Now press d to delete parition

    Command (m for help):d

delete all partitions.

Now you can create new partitions by fdisk or any other utility without any error as partitions have been removed.

  • 2
    While this advice is correct, please ensure that the /dev/sdb disk is your actual flash drive. If you have two (or more) hard disks, this will wipe your hard disk rather than the flash drive. – Wouter Verhelst Nov 19 '15 at 16:01

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.