Other dd conversion vs dd deletion

Let's say I install a .img file to my USB device. It has software already on it. If I write the img file to the usb device, would it delete the rest of the data that wasn't converted by dd equivalent of a /dev/zero wipe?

Am I wasting my time by /dev/zero wiping my USB before I install .isos and .imgs?
 
Yes, you are wasting time and write cycles on flash memory, at least with image files. An image has everything from the original device. It's not sparse, like a list of files.
 
Thanks! Just to be clear, converting without notrunc deletes everything that isn't from the conversion like a low-level format, not like a 'delete all files' thing, right?
 
The directory information in the image overwrites anything present on the disk. There will still be old information in any space the image does not overwrite, but that is at the end and does not matter because the directory information only refers to the image.
 
There's a bit of chaos concerning terms here ...
  • low-level format: This means the creation of the physical structure (tracks, sectors) on a medium. It doesn' make any sense for anything else than magnetic discs. In fact, even with hard disks, last time I've seen a situation where it was necessary to do this as a user was back in the days of MFM controllers for the PC XT.
  • truncation (or, the notrunc option of dd, avoiding truncation): This means setting the target file size to 0 (zero) before starting to copy. When your target is a physical device, it's meaningless, cause the size of the device is fixed. On a side note, even with a regular file, dd would just call truncate(2) and any sane file system would just update the directory entry and mark the blocks as unallocated.
  • conversion: dd has options to convert some data while copying. But that's NOT what you use when copying an image to a device. You just use the primary purpose of dd: copying some data block-wise.
What dd really does is just copy data, on a "lower" level than e.g. cp. It's not limited to copying whole files, you can control the blocksize and block count while copying, and thus, it's well suited for writing to (or reading from) device files.

What are you trying to achieve dding /dev/zero to your USB drive? If you think you need a "clean" device for putting a new image on it ... it is indeed pointless. If you're -- for whatever reason -- worried, someone could access old data on the drive in the area not covered by the new image: take a look at dd's seek parameter to save time.
 
(Un)Fortunately the first. I have a bit of an obsessive compulsive disorder for "clean" things technology-wise.
 
Back
Top