Stop Windows from Prompting to Format Disks

3 minute read

You need to format the disk If you’re the type of person who works a lot with removable disks not formatted as FAT, exFAT, or NTFS on Windows, you’ve probably come close to wiping out partitions because of this message. Luckily we can use some dirty tricks to prevent Windows from generating this prompt for specific partitions, and avoid accidentally wiping out useful data.

While this behavior in Windows is useful for a typical user who may have purchased an unformatted thumb drive, it can be particularly annoying for power users. If you deal a lot with VeraCrypt encrypted partitions or have thumb drives with separate partitions for Windows and Linux you’re probably going to want to prevent them from being wiped out by an accident press of the enter key.

Abusing Partition Types

Luckily for us, Windows is set up to ignore certain types of partitions and hide them from the user. We can abuse this functionality by assigning specific partition types to our encrypted or Linux partitions.

The different types have slightly different behavior, so you’ll want to pick the one most suited to your use. VeraCrypt for example, generally doesn’t allow you to select the partitions that Windows hides completely. The tables below show the type IDs that will not prompt for formatting on Windows. Unfortunately, in my testing I was unable to find any MBR partition types that Windows ignores. You’ll need to wipe the disk and format with GPT before attempting any of this.

Type IDs

Name Code Notes
Microsoft Reserved E3C9E316-0B5C-4DB8-817D-F92DF00215AE Requires System attribute set. Linux probably won’t auto-mount.
Microsoft Recovery DE94BBA4-06D1-4D40-A16A-BFD50179D6AC Requires System attribute set. Linux probably won’t auto-mount.
Storage Spaces Protective E75CAF8F-F680-4CEE-AFA3-B001E56EFC2D Doesn’t appear in VeraCrypt.
Logical Disk Manager Metadata 5808C8AA-7E8F-42E0-85D2-E1E90434CFB3 Doesn’t appear in VeraCrypt. Empty volume shows up in Disk Management.
Logical Disk Manager Data AF9B60A0-1431-4F62-BC68-3311714A69AD Doesn’t appear in VeraCrypt. Error volume shows up in Disk Management.

Modifying the Type IDs

Windows: DiskPart

On Windows, you can use the built-in utility DiskPart to modify most of these partition IDs. Unfortunately, on GPT disks you are not allowed to set the “Microsoft Reserved” or LDM partition types. Trying to set these IDs will return an error. You also won’t be able to set the System attribute. You’ll have to use one of the Linux tools for that.

> diskpart

Microsoft DiskPart version 10.0.17134.1

Copyright (C) Microsoft Corporation.
On computer:

DISKPART> select disk X

Disk X is now the selected disk.

DISKPART> select part X

Partition X is now the selected partition.

DISKPART> setid id=E75CAF8F-F680-4CEE-AFA3-B001E56EFC2D

DiskPart successfully set the partition ID.

Linux: fdisk / gdisk

On Linux you can use either fdisk or gdisk. The commands are mostly the same, but they differ slightly.

fdisk:

> fdisk /dev/sdx

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help):t

Selected partition 1
Partition type (type L to list all types):E3C9E316-0B5C-4DB8-817D-F92DF00215AE

Changed type of partition 'Linux filesytem' to 'Microsoft Reserved'.

Command (m for help):w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

gdisk:

> gdisk /dev/sdx

GPT fdisk (gdisk) version 1.0.1

...

Command (? for help): t

Using 1
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):E3C9E316-0B5C-4DB8-817D-F92DF00215AE

Changed type of partition to 'Microsoft Reserved'

Command (? for help):w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N):y
OK; writing new GUID partition table (GPT) to /dev/sdx.
The operation has completed successfully.

If you want to set the system attribute too, you’ll need to run these commands in gdisk:

> gdisk /dev/sdx
GPT fdisk (gdisk) version 1.0.1

...

Command (? for help):x

Expert command (? for help):a

Using 1
...

Attribute value is 0000000000000000. Set fields are:
  No fields set

Toggle which attribute field (0-63, 64 or <Enter> to exit):0

Have enabled the 'system partition' attribute.
Attribute value is 0000000000000001. Set fields are:
0 (system partition)

Toggle which attribute field (0-63, 64 or <Enter> to exit):64

Expert command (? for help):m

Command (? for help):w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N):y
OK; writing new GUID partition table (GPT) to /dev/sdx.
The operation has completed successfully.

Testing

Once this is complete, you should be able to plug your portable disk into a Windows computer without being prompted to format. Depending on the type ID you chose you may or may not see a drive letter appear.

As always, your mileage may vary as this is an undocumented behavior and there is no guarantee Windows will continue working like this in the future. Exercise caution if your drive contains irrecoverable data.