Monday, 3 September 2018

Blanking a USB stick boot sector

One of these small things that comes up occasionally and that you can never remember at the time but always have to reinvent or rediscover.

Occasionally, a USB stick will end up with an odd partition layout / an Apple media ID or something that means that the size isn't reported correctly or means that you can't use it.

Plug in the USB stick :

dmesg ;

the last line you see is the line showing the USB stick you've just plugged in - say /dev/sdb

From a command line as root:

dd if=/dev/zero of=/dev/sdb bs=512k count=4

Writes 2MB worth of zeroes to the front of the USB stick, overwriting entries already there.

After that, parted /dev/sdb should enable you to partition the USB stick or you can use dd to put a bootable .iso file on it.