0

If for example I clear the contents of my SD card with command dd if=/dev/zero of=/dev/sdX , I'm guessing this completely wipes (sets to zero) every single content on the card? partitions, file system, data etc.

Now what I can't understand is, when I will plug this device into a computer again afterwards, Linux or Windows, I am able to write to it again. How does the OS know what type of device this is if everything is wiped?

There are different types of flash memory and I'm guessing they need specific drivers to write to them depending on what type, so how does the OS know what type?

Can it be that there is a small part of the flash memory which was not overwritten which contains data explaining what type of memory it is?

  • Your device actually contains many hardware components for work with the computer system, not only the data area you usually read/write. Thoes components may even not exposed to OS. – 炸鱼薯条德里克 Jan 6 at 15:15
3

Your SD card is not just passive memory, like a floppy disk or an optical disc. SD cards include a controller.

[ [flash memory] <=> [controller] ] <=> [your computer]

There are different types of flash memory and I'm guessing they need specific drivers

The controller inside the SD card handles it. So this makes it easy to develop new cards where the flash memory has different details, and older computers/devices can use them without needing any modification.

Writing all zeros to /dev/sdX does not cause the controller to destroy itself. Just like writing all zeroes to a more traditional hard drive does not destroy the controller inside the hard drive.

  • Ok thanks. So where is this controller stored on the card? Do we not delete everything when using dd ? – Engineer999 Jan 6 at 14:31
  • 1
    The controller is a small computer, embedded in the device. It is not software. It is a separate entity to what is being controlled. You can tell it to erase its storage, but you can not tell it to erase its own programming, this is stored else-ware (If the controllers program is stored in the same flash, then the code will stop you from even seeing this code). – ctrl-alt-delor Jan 6 at 14:47
0

There are two answers to this.

The definition of everything

As you have guessed, not everything is erased. It is like a dry wipe board: you can wipe it clean, but the board remains. It still knows how to be a dry wipe board. The device has a fixed set of meta data, that it will not let you erase. This data can be read, but does not appear with the other data. For example A USB device, when you plug it in, the OS will query various things: Serial number, manufacturer number, device type (keyboard, pointing, mass-storage, network, hub, …). Once the OS has this it can load the specific driver, then start reading/writing the content of the storage.

There may also be a program that an embedded cpu (the controller), runs. There is nothing that you can do, to see this, and you definitely can not erase it.

Many different devices or not

There are a limited number of types of device. USB defines several basic types (HID: pointer, keyboard; mass-storage, networking, audio, video, …). If a USB device is certified, then it has to use one of these pre-defined types, so will be compatible (un-certified devices are not guaranteed, to be compatible, and may require proprietary drivers).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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