When you've previously created bootable USB drives (like Clonezilla, Ubuntu installer, or Windows installation media), the Master Boot Record (MBR) remains even after standard formatting. This causes annoying behavior where systems attempt to boot from the USB even when you're just using it for storage.
Windows' built-in formatting tools only affect the partition table and file system, not the first sector where bootloaders reside. Here's what happens at the low level:
+---------------------+ | MBR (boot code) | ← Survives normal formatting |---------------------| | Partition Table | ← Gets rewritten |---------------------| | File System | ← Gets reformatted +---------------------+
We'll use diskpart, Windows' built-in disk partitioning utility:
# Open Command Prompt as Administrator diskpart list disk # Identify your USB disk number select disk X # Replace X with your USB disk number clean # Wipes all partition data create partition primary # Creates new raw partition format fs=ntfs quick # Quick NTFS format assign # Assigns a drive letter exit
For more precise control or scripting scenarios:
# Wipe the first 1MB (covers MBR + some padding) $diskNumber = 1 # Confirm this first! $disk = Get-Disk -Number $diskNumber $disk | Clear-Disk -RemoveData -RemoveOEM -Confirm:$false $disk | Initialize-Disk -PartitionStyle GPT $partition = $disk | New-Partition -UseMaximumSize $partition | Format-Volume -FileSystem NTFS -NewFileSystemLabel "CleanUSB"
For situations requiring byte-level precision (like when preparing forensic media):
# Using fsutil (requires admin rights) fsutil file createnew \\?\GLOBALROOT\Device\HarddiskX\Partition0\bootsect.bin 1048576 # This creates a 1MB null file overwriting the boot sector area
Confirm the MBR is cleared by checking the first 512 bytes:
certutil -encodehex \\.\PhysicalDriveX mbr.txt # Then examine mbr.txt - first 512 bytes should be zeros
- Incorrect disk selection (always double-check disk numbers)
- UEFI systems may still show USB in boot menu (this is firmware-level behavior)
- Some USB controllers may cache old partition info (physically replug to reset)
For frequent USB preparation tasks:
@echo off :: sanitize_usb.cmd setlocal diskpart /s sanitize_usb.txt exit /b :: Contents of sanitize_usb.txt: select disk %1 clean create partition primary format fs=ntfs quick label="CleanDrive" assign exit
html
When you create a bootable USB (like Clonezilla or Ubuntu installer), the drive gets a Master Boot Record (MBR) that survives regular formatting. Even after deleting partitions, the system may still attempt to boot from it, causing errors or delays during startup.
Windows' built-in formatting tools only affect partition tables, not the first sectors where bootloaders reside. Here's what happens when you check the disk structure:
diskpart
list disk
select disk X (your USB number)
detail disk
We'll use DiskPart's clean command with a crucial parameter:
diskpart
list disk
select disk X
clean all
The clean all performs a secure erase, overwriting every sector (including MBR) with zeros. For smaller drives, this takes minutes; for larger ones, consider using just clean for faster operation.
For scriptable solutions, use this PowerShell command:
Clear-Disk -Number X -RemoveData -RemoveOEM -Confirm:$false
Initialize-Disk -Number X -PartitionStyle GPT
Check the first sector using HxD (free hex editor):
- Open HxD as Administrator
- Extra > Open Disk > Select your USB
- Verify the first 512 bytes are now empty (00 or FF)
To only clear the boot code (keeping partition table):
debug.exe
-a
mov ax,0301
mov bx,0800
mov cx,0001
mov dx,0080
int 13
int 20
-g
-q
Warning: This advanced method requires precise disk numbering.
After wiping, create a new partition scheme:
diskpart
create partition primary
format fs=ntfs quick
assign
For UEFI systems, consider GPT instead of MBR:
convert gpt