Burnt Leap ISO to USB, now cannot get it back to normal usage

On an old Leap 42.3 PC I did

dd if=/path/to/openSUSE_Leap_15.1.iso of=/dev/sdX bs=4M status=progress && sync

It did work, and I was able to clean-install Leap 15.1 through the USB.

Now I want it back to normal data usage, but I cannot.
Yast Partitioner sees no partitions at all inside this USB device, yet when plugging the USB file browser notifies a new volume was detected! Showing indeed all ISO’s contents. And when trying to just creating a new one here, it pops an error of “mkvfat” or something like that, as in “device busy”.

What happened here? How can I get back the USB to normal data usage?

Thanks.

Hi
As root user run lsblk to identify the partitions and then use wipefs -a /dev/sdXN to delete and prepare again;


lsblk

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 223.6G  0 disk 
├─sda1   8:1    0   260M  0 part /boot/efi
├─sda2   8:2    0    40G  0 part /
├─sda3   8:3    0   182G  0 part /data
└─sda4   8:4    0   1.3G  0 part [SWAP]
sdb      8:16   0 931.5G  0 disk 
└─sdb1   8:17   0 931.5G  0 part /stuff
sdc      8:32   1  14.8G  0 disk 
├─sdc1   8:33   1   3.8M  0 part 
└─sdc2   8:34   1   3.8G  0 part /run/media/username/openSUSE-Leap-15.1-DVD-x86_64470 <==

umount /dev/sdc2

wipefs -a /dev/sdc2
/dev/sdc2: 5 bytes were erased at offset 0x00008001 (iso9660): 43 44 30 30 31

wipefs -a /dev/sdc1
/dev/sdc1: 8 bytes were erased at offset 0x00000036 (vfat): 46 41 54 31 36 20 20 20
/dev/sdc1: 1 byte was erased at offset 0x00000000 (vfat): eb
/dev/sdc1: 2 bytes were erased at offset 0x000001fe (vfat): 55 aa

wipefs -a /dev/sdc
/dev/sdc: 5 bytes were erased at offset 0x00008001 (iso9660): 43 44 30 30 31
/dev/sdc: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
/dev/sdc: calling ioctl to re-read partition table: Success

fdisk /dev/sdc

Welcome to fdisk (util-linux 2.33.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xb0943396.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-30965759, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-30965759, default 30965759): 

Created a new partition 1 of type 'Linux' and of size 14.8 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

lsblk

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 223.6G  0 disk 
├─sda1   8:1    0   260M  0 part /boot/efi
├─sda2   8:2    0    40G  0 part /
├─sda3   8:3    0   182G  0 part /data
└─sda4   8:4    0   1.3G  0 part [SWAP]
sdb      8:16   0 931.5G  0 disk 
└─sdb1   8:17   0 931.5G  0 part /stuff
sdc      8:32   1  14.8G  0 disk 
└─sdc1   8:33   1  14.8G  0 part 

mkfs.exfat /dev/sdc1
mkexfatfs 1.3.0
Creating... done.
Flushing... done.
File system created successfully.

(remove and plug in device or run partprobe)

lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 223.6G  0 disk 
├─sda1   8:1    0   260M  0 part /boot/efi
├─sda2   8:2    0    40G  0 part /
├─sda3   8:3    0   182G  0 part /data
└─sda4   8:4    0   1.3G  0 part [SWAP]
sdb      8:16   0 931.5G  0 disk 
└─sdb1   8:17   0 931.5G  0 part /stuff
sdc      8:32   1  14.8G  0 disk 
└─sdc1   8:33   1  14.8G  0 part /run/media/username/31C0-B6C9

Even if you repartition with “fdisk”, the label for the “iso9660” file system remains. At one time, I investigated where that label is, and overwrote it with zeros. But writing 1M from “/dev/zero” to the device will probably do the job.

Based on the man page, it looks as if Malcolm’s suggestion (using “wipefs”) will find the file system labels and erase just those.

Why does anyone want to preserve anything at all?
Why not just blow away any readable partitions on the disk (if any can be read at all),
Create a new partition layout and reformat?

BTW-
It’s well known that sometimes when a USB is completely reformatted like this, for odd reasons the size may not end up exactlyas before, but should be completely usable.

TSU

So first I tried

dd if=/dev/zero of=/dev/sdX status=progress && sync

Heck, took a while, around 1 hour or bit more, for a 16 Gb USB stick…
Sync command didn’t even enter: dd exited with a non-zero code saying “no more space in device”, or something like that.
But seemingly it worked: there were no partitions in device and Yast Partitioner worked again as normal.

Wrote Leap 15.1 ISO again with dd, and this time tried Malcolm’s advise.
Worked as well.

So now, if I may,

  1. What’s the explanation behind wipefs? Why isn’t Partitioner (or even Gparted or sgdisk as well?) enough and fails?

  2. I didn’t exactly harm the USB stick by writing /dev/zero entirely, or did I?

  3. In KDE at least (didn’t try GNOME…), plugging the newly written Leap 15.1 USB normally does nothing, no partitions auto-mounted. Why? Some issue with the ISO file system, or multiple partitions in an external device like in Windows?

Thanks.

Hi
It wipes the partition signatures, it doesn’t get rid of the data. As you discovered dd takes awhile, just a super quick way to recover a device.

Just a more writes to the device… quicker to wipe, fdisk/gdisk and format… I normally use gdisk and expert mode to also wipe the mbr out then fdisk/gdisk to create the new layout.

Don’t know, I use GNOME…

I can usually repartition with “fdisk”. But “parted” is too smart by half and still finds the ISO9660 label. I have not tried “wipefs” but it looks as if it knows how to zap that label.

  1. I didn’t exactly harm the USB stick by writing /dev/zero entirely, or did I?

No, except that if the device has a limited number of writes, then you may have slightly shortened its life.

  1. In KDE at least (didn’t try GNOME…), plugging the newly written Leap 15.1 USB normally does nothing, no partitions auto-mounted. Why? Some issue with the ISO file system, or multiple partitions in an external device like in Windows?

I’m not sure what KDE is looking for. With an openSUSE install DVD iso written to USB, there are two partitions. The first partition is the EFI partition, and the second is an iso9660 partition. I have noticed that some distros are putting the EFI partition as the second partition instead of the first. And KDE recognizes USBs formatted that way. Perhaps somebody can persuade the openSUSE developer team to try that.

First, sorry for necroposting, albeit I do think what I just found is completely relevant and adds to this.

I tried again the process now with more information:

# fdisk -c=dos /dev/sdb

Welcome to fdisk (util-linux 2.33.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

DOS-compatible mode is deprecated.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (1-4, default 1): 
First sector (32-31948799, default 32): 128
Last sector, +/-sectors or +/-size{K,M,G,T,P} (128-31948799, default 31948799): 

Created a new partition 1 of type 'Linux' and of size 15.2 GiB.
Partition #1 contains a vfat signature.

Do you want to remove the signature? [Y]es/[N]o: y

The signature will be removed by a write command.

Command (m for help): t
Selected partition 1
Hex code or alias (type L to list all): L

00 Empty            24 NEC DOS          81 Minix / old Lin  bf Solaris        
01 FAT12            27 Hidden NTFS Win  82 Linux swap / So  c1 DRDOS/sec (FAT-
02 XENIX root       39 Plan 9           83 Linux            c4 DRDOS/sec (FAT-
03 XENIX usr        3c PartitionMagic   84 OS/2 hidden or   c6 DRDOS/sec (FAT-
04 FAT16 <32M       40 Venix 80286      85 Linux extended   c7 Syrinx         
05 Extended         41 PPC PReP Boot    86 NTFS volume set  da Non-FS data    
06 FAT16            42 SFS              87 NTFS volume set  db CP/M / CTOS / .
07 HPFS/NTFS/exFAT  4d QNX4.x           88 Linux plaintext  de Dell Utility   
08 AIX              4e QNX4.x 2nd part  8e Linux LVM        df BootIt         
09 AIX bootable     4f QNX4.x 3rd part  93 Amoeba           e1 DOS access     
0a OS/2 Boot Manag  50 OnTrack DM       94 Amoeba BBT       e3 DOS R/O        
0b W95 FAT32        51 OnTrack DM6 Aux  9f BSD/OS           e4 SpeedStor      
0c W95 FAT32 (LBA)  52 CP/M             a0 IBM Thinkpad hi  ea Linux extended 
0e W95 FAT16 (LBA)  53 OnTrack DM6 Aux  a5 FreeBSD          eb BeOS fs        
0f W95 Ext'd (LBA)  54 OnTrackDM6       a6 OpenBSD          ee GPT            
10 OPUS             55 EZ-Drive         a7 NeXTSTEP         ef EFI (FAT-12/16/
11 Hidden FAT12     56 Golden Bow       a8 Darwin UFS       f0 Linux/PA-RISC b
12 Compaq diagnost  5c Priam Edisk      a9 NetBSD           f1 SpeedStor      
14 Hidden FAT16 <3  61 SpeedStor        ab Darwin boot      f4 SpeedStor      
16 Hidden FAT16     63 GNU HURD or Sys  af HFS / HFS+       f2 DOS secondary  
17 Hidden HPFS/NTF  64 Novell Netware   b7 BSDI fs          fb VMware VMFS    
18 AST SmartSleep   65 Novell Netware   b8 BSDI swap        fc VMware VMKCORE 
1b Hidden W95 FAT3  70 DiskSecure Mult  bb Boot Wizard hid  fd Linux raid auto
1c Hidden W95 FAT3  75 PC/IX            bc Acronis FAT32 L  fe LANstep        
1e Hidden W95 FAT1  80 Old Minix        be Solaris boot     ff BBT            

Aliases:
   linux          - 83
   swap           - 82
   extended       - 05
   uefi           - EF
   raid           - FD
   lvm            - 8E
   linuxex        - 85
Hex code or alias (type L to list all): 0c
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.

Command (m for help): a
Selected partition 1
The bootable flag on partition 1 is enabled now.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.



$ lsblk -f
NAME   FSTYPE  FSVER  LABEL    UUID   FSAVAIL  FSUSE%  MOUNTPOINT
...]
sdb                                                                                     
└─sdb1



# mkfs.fat -F 32 /dev/sdb1   # or just: mkfs.vfat /dev/sdb1

# fatlabel /dev/sdb1 KINGSTON



$ lsblk -f
NAME   FSTYPE  FSVER  LABEL    UUID   FSAVAIL  FSUSE%  MOUNTPOINT
...]
sdb                                                                                     
└─sdb1 vfat    FAT32  KINGSTON <uuid> 15.2G    0%      /run/media/user/KINGSTON

All these specifics to leave the USB drive as it actually came from factory; the “-c=dos” fdisk option is to be able to set a first sector lower than 2048.

Also, just using fdisk to delete the “ISO” partitions seemed enough to make the USB drive usable again; in fact, wipefs actually also deletes the partitions…

The “catch” in all of this, however, is that even after all of this there seems to remain things from the ISO burning: just try “mount -t iso9660 /dev/sdb” and it does. Seems to be clearable only with the long dd /dev/zero process…

EDIT:
Regarding the ISO remains, nrickert’s initial advise of writing 1 Mb seems to also work:
dd if=/dev/zero of=/dev/sdX count=2048 status=progress; sync

Thanks.