Page 1 of 1

How to zero out just the MBR of a USB?

Posted: Sat Feb 06, 2021 9:59 am
by mohittomar13

I often use dd command for filling my USB with zeroes and then later formatting it using the style that I want. However, my USB stick is 16 GB and it takes around 40 mins for dd to fill it with zeroes. I just want to erase the partition details so that the USB appears to be non-formatted instead of actually filling it with zeroes. Is there some option that I can use with dd so to stop filling the USB after a certain amount of disk if filled with zeroes? I suppose this would not render my USB unusable.

any help will be greatly appreciated.


Re: How to fill zeroes to only starting portion of USB

Posted: Sat Feb 06, 2021 12:14 pm
by user1111

dd if=/dev/zero of=/dev/xxxx bs=1M count=1

where xxxx is the usb device (sdb/whatever).

Then run gparted and create a new partition table, create a new partition, format it, set boot flag on if its to be a bootable usb.


Re: How to fill zeroes to only starting portion of USB

Posted: Sat Feb 06, 2021 1:25 pm
by mohittomar13

Thanks for the reply. I think this is what I was looking for. bs=1 and count=1 means to write '0's for a total of 1MB in size. Right? If I put count=2 and bs=4mb that would mean a total size of 8mb.

Thanks... :D :D


Re: How to fill zeroes to only starting portion of USB

Posted: Sat Feb 06, 2021 1:40 pm
by mikewalsh

@mohittomar13 :-

AFAIK, you only want the first 512 bytes to be cleared, since this is the amount of space occupied by your MBR - Master Boot Record. So that 1 MB in rufwoof's 'code' snippet should more than do the job.....once the MBR is erased, the drive, to all intents & purposes, is empty.

Mike. ;)


Re: How to fill zeroes to only starting portion of USB

Posted: Sat Feb 06, 2021 2:19 pm
by user1111
mohittomar13 wrote: Sat Feb 06, 2021 1:25 pm

Thanks for the reply. I think this is what I was looking for. bs=1 and count=1 means to write '0's for a total of 1MB in size. Right? If I put count=2 and bs=4mb that would mean a total size of 8mb.

Thanks... :D :D

bs=1 count=1 ... would just write 1 byte, needs to be suffixed with K or M (or specified bs=1000000 count=1 would write 1,000,000 bytes).

bs of 512 is a reasonable choice but a more awkward one to work out multiples of, but in the case of the MBR just one 512 byte write would likely do the trick of 'wiping' it. 1MB however is more certain, and relatively quick/easy.

If I put count=2 and bs=4mb that would mean a total size of 8mb.

Yes that is correct. But use bs=4M (not sure whether bs=4mb would work).


Re: How to zero out just the MBR of a USB?

Posted: Sun Feb 07, 2021 7:02 am
by mohittomar13

Thanks @mikewalsh and @rufwoof
:thumbup: :thumbup:


Re: How to zero out just the MBR of a USB?

Posted: Sun Feb 07, 2021 3:21 pm
by Clarity
mohittomar13 wrote: Sat Feb 06, 2021 9:59 am

I often use dd command for filling my USB with zeroes and then later formatting it using the style that I want.

Without your ever doing this, the answer from @rufwoof will work in any of the choices your reference for reuse of your USB. Just format it for whatever future use you want.

mohittomar13 wrote: Sat Feb 06, 2021 9:59 am

filling it with zeroes. Is there some option that I can use with dd so to stop filling the USB after a certain amount of disk if filled with zeroes?

Again, @rufwoof answer to limit the zeros to the 1st 1 million will work. For just MBR removal, use bs=512.

Code: Select all

dd ... bs=512 ...

ALSO, his answer of using GParted when you want to format is probably the one most of us would use vs the fussing with all the terminal commands to achieve a blanking and formating. Menu>System>Gparted where everything is visual.

GParted GUI.jpg
GParted GUI.jpg (18.91 KiB) Viewed 693 times
mohittomar13 wrote: Sat Feb 06, 2021 9:59 am

I suppose this would not render my USB unusable.

any help will be greatly appreciated.

Correct, his instructions will safely achieve your request.

I seem to remember that PUPPY has an editor, somewhere, for "looking" at the contents of blocks (in hex) on an I/O device. But cannot remember where it is.

Hope this is reassuringly helpful


Re: How to zero out just the MBR of a USB?

Posted: Sun Feb 07, 2021 7:58 pm
by rcrsn51

You really don`t need to zero out anything. Just run Gparted > Device > Create Partition Table.


Re: How to zero out just the MBR of a USB?

Posted: Tue Mar 09, 2021 10:03 am
by gruhyrose

thanks for share, that's awesome.