Linux Delete / Remove MBR

I‘ve installed an usb image on Pen drive along with MBR. Now, I need to use this USB pen for other purpose. Is there a way in Linux to delete the mbr (just like dos fdisk /mbr command)?

You can delete the mbr (master boot recored) using the dd command itself. A master boot record (MBR) is the 512-byte boot sector that is the first sector of a partitioned data storage device of a hard disk.

Understanding MBR size

The mbr size is as follows in bytes:

Where,446 + 64 + 2 = 512

  1. 446 bytes – Bootstrap.
  2. 64 bytes – Partition table.
  3. 2 bytes – Signature.
WARNING! These examples may crash your computer if executed. The following command will completely delete your MBR including all your partition information. So make sure you use the correct device name and block size in bytes.

Option #1: Command to delete mbr including all partitions

Open a terminal and type the following command command to delete everything:
# dd if=/dev/zero of=/dev/sdc bs=512 count=1
Sample outputs:

1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.00308483 s, 166 kB/s

Where,

  • if=/dev/zero – Read data from /dev/zero and write it to /dev/sdc.
  • of=/dev/sdc – /dev/sdc is the USB drive to remove the MBR including all partitions.
  • bs=512 – Read from /dev/zero and write to /dev/sdc up to 512 BYTES bytes at a time.
  • count=1 – Copy only 1 BLOCK input blocks.

Option #2: Command to delete mbr only

The following command will erase mbr, but not your partitions:
# dd if=/dev/zero of=/dev/sdc bs=446 count=1
Where,

  • bs=446 – Read from /dev/zero and write to /dev/sdc up to 446 BYTES bytes at a time.
See also

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.