71

I've started using TrueCrypt to encrypt a partition on an external USB hard drive. I've opted for using a raw partition as opposed to a file container.

But here's the annoyance. Whenever I connect this drive to a computer running Vista or Windows 7, I get the message popup "You need to format the disk in drive J: before you can use it".

The default option is "Format disk", and I'm afraid one of these days I'll accidentally trigger it.

Is there any way to disable this message?

  • 7
    Note there are two great answers here: The answer by Snark is great if you only want to solve to problem for one host computer and/or have added the truecrypted partition as a Favorite on any computer. The answer by SylikC solves the problem even for computers who haven't seen your USB drive before, but it (kind of) breaks adding that USB drive to TrueCrypt Favorites. – Jonas Heidelberg Aug 30 '11 at 15:02
  • 1
    I'm having the same problem with W7 wanting to format a BTRFS partition on my Android whenever I plug it in to charge... Windows = data loss by design – Mark K Cowan Aug 13 '14 at 12:56
55

Try to go to the Control Panel - Administrative Tools - Computer Management. In the Disk Management part, remove the drive letter for the raw partition.

It should prevent Win7 from asking you to format the partition, while letting you mount the partition in TrueCrypt.

If it doesn't work, you could try this suggestion, which is to use Autokey to automatically dismiss the messagebox when it appears.

  • +1 that does work, i'm using the same trick for my 'truecryped' sticks – Molly7244 Oct 1 '09 at 12:42
  • 4
    I believe the OP is looking for a solution that will work on any computer. Software installation is not then an option. – harrymc Oct 1 '09 at 13:10
  • 2
    A quicker way to open "Disk Management" is to Press Ctrl+R and type "diskmgmt.msc" :-) – Jonas Heidelberg Aug 30 '11 at 14:29
  • 2
    @msorens: no it won't; Windows identifies the USB hard drive through an ID written to its boot sector, so it will only ignore the partition from that specific hard drive. – Jonas Heidelberg Jan 10 '12 at 20:56
  • 1
    I used this "remove drive letter technique" to have 2 partitions (one un-encrypted and encrypted) on a removable drive by using VeraCrypt. Format the original partition as NTFS, use VeraCrypt to define a "container" encrypted file smaller than the total size of the partition. This creates another internally formatted partition that is useful under Windows. I make sure to simply remove the drive letter assigned to this new encrypted partition - to prevent windows from complaining about needing to format it. Just mount as a device partition the encrypted partition. Works well for me. – John C Jun 30 '17 at 18:08
26

I have finally found a solution. I've tested this on Windows XP and Windows 7. With this solution device can't be accidentally formatted, when you plug it on another PC.

When you create a raw partition with TrueCrypt, it specifies it as partition type 0x06. This is a FAT partition, and Windows will always try to mount it.

Using a utility such as Beeblebrox (or your favorite RAW partition editor), change it to something else. I chose 0x64 which (based on the partition lists available) is a "PC-ARMOUR encrypted partition".

After changing it and then unplugging and replugging your device (power cycle), Windows will treat this partition as foreign and will not attempt to mount it. I will test it on Linux later, but I believe that'll prevent Linux from mounting it as well.

P.S. As Beeblebrox seems a bit outdated (last update of the Windows version in 2002) for newer Windows you can use internal diskpart. The commands for diskpart are:

list disk
select disk # <- your disk number here
list partition
select partition # <- your partition number here
set id=64
exit 

Credits are for @jonas-heidelberg and @mhenry1384.

  • 3
    Beeblebrox seems a bit outdated (last update of the Windows version in 2002) and I couldn't get it to run under Win7x64; under Linux you can change the partition type with fdisk (t option); in Windows 7 the build-in diskpart can do it with set id=64. – Jonas Heidelberg Aug 30 '11 at 14:19
  • 4
    Only ceveat is that afterwards TrueCrypt doesn't recognize the volume as a favorite any more (if it was one). You can add it again but you can't give it a label, with the result that it is only recognized when its name of the form \Device\Harddisk5\Partition3 does not change. I.e. adding a different USB stick to your system before plugging in the TrueCrypted one makes the Favorite not work :-( – Jonas Heidelberg Aug 30 '11 at 14:24
  • 1
    I have tried working around the caveat using different partition types, in particular 0x27 and 0xc7, but it seems that either you get the format warning (when Windows thinks it should be able to read the partition and considers it a volume), or you can't assign a Label in TrueCrypt (when Windows ignores the partition). – Jonas Heidelberg Aug 30 '11 at 14:27
  • 2
    The commands for diskpart are: list disk / select disk # / list partition / select partition # / set id=64 / exit – mhenry1384 Oct 4 '11 at 1:09
  • 1
    set id=64 doesn't work in Windows 10 (diskpart won't let you do it), but I seem have had luck with "set id=8DA63339-0007-60C0-C436-083AC8230908" – mhenry1384 Apr 16 '17 at 20:23
4

I use a program called USB Safely Remove, which knows about TrueCrypt and can be configured to automatically pop up the TrueCrypt password dialog when certain USB drives are inserted. It also allows you to unmount the TrueCrypt drive and safely remove the USB drive with a single click.

It's a commercial product (with a free trial), but they are currently giving away some free licenses, if you're quick. It's legit -- I got my license in their last giveaway.

2

The simplest and safest solution would be to simply format the usb disk and recreate the TrueCrypt virtual encrypted disk as the only file on the disk.

For completeness only : I note the need to first save all existing data within the TrueCrypt disk.

2

I tried this: My portable HDD was NTFS-formatted and blank.

  • Encrypted it mounted
  • Added data
  • Unmounted it, re-connected and had this Windows message "you need to format…"
  • I unassigned the drive letter in disk management to the encrypted USB drive

That did the trick – no more pesky messages for me. I connect the drive and invoke TrueCrypt, select the portable HDD, click mount and provide the password. Voilà: The volume is mounted.

2

I want to re-confirm the answer that SylikC has given. You don't want to screw with your system, you want to indicate on the partition that it should not try mounting it. But there are 2 parts to this as I have found out.

First you do as SylikC says using diskpart set id=64 or choose from a wide range of partition types. But if you had previously assigned a drive letter to the partition, Windows 10 will still give you a "Format this Disk" dialog. To prevent that, you need to remove the drive letter assignment on the disk too.

To do that, before you set the partition type do

  list volume
  select volume <your volume with the drive letter>
  remove letter=<your drive letter you want to remove>
  set id=<now set the partition type>
  ...

If you had changed the partition type already, you have to first bring it back again to

  set id=6
  list volumes
  select volume <your volume with the drive letter>
  remove letter=<your drive letter you want to remove>
  set id=64

And that is it. Next time you pop in that USB drive, no more warning comes up. And I had no problems mounting a TrueCrypt drive.

  • At first, once you get past the nonsense you start with, it sounds as though you're just copying SylikC's answer. But you appear to have added some helpful and relevant information. If so, I'd recommend you edit out the nonsense and make it more clear that you have something to contribute, and then feel conflicted because you've now joined the sweaty, distasteful hordes earning "credits". – music2myear Jul 28 '17 at 17:44
1

On Windows 10 with USB stick that has UEFI boot and TrueCrypt/VeraCrypt partitions nothing works.

Windows 10 assigns letters in some way that neither DiskPart nor Disk Management sees them, but registry keys are present on HKLM\SYSTEM\MountedDevices, so the “Format” message appears... also on “safely remove hardware” it appears with letters on all partitions.

Windows 10 does it so badly that the EFI partition isn't in Disk Management with the letter, and in DiskPart it is also not seen as a volume and without letter, but if you go to Explorer (use “safely remove hardware” to learn the letter but do not remove it) you see it with a letter and can enter it, modify files/folders, etc.

That keys are re-created upon re-connect, so no possible solution.

This Windows 10 is a headache... all caused by treating external media with the Removable Media Bit as 'special', one-partition devices, even while they have multiple partitions.

Example: USB EFI Boot with NTFS+EFI+... on a USB stick that is impossible to re-set the removable media bit.

Warning: Changing the partition type can corrupt data on VeraCrypt partitions.

But there is a trick touching registry... take a lot of care when doing this and quadruple-check that the hex data is identical.

On the registry key, there are two entries with same exact hex data for each partition... well, one has the letter, one starts with \??\Volume{ ...

The trick is to rename the one that starts with \??\Volume{ that belongs to the partition you want to avoid getting a letter.

Instead of starting with \??\Volume{ make it start with #{.

And of course, delete the one starting with \DosDevices\.

Then, remove it (using the “safely remove” function) and plug it again. Press F5 to refresh the key in regedit to check if it worked.

On my tests it works, but must done be with a lot of care... I insist on quad checking hex data to be the same... a lot of times I didn't quad check it, I made a mistake, and sometimes on the next reboot Windows didn't start, so I needed to fix it with an ugly bootable Windows install DVD by going into console mode and running regedit from the DVD (no need to reinstall).

So, prior to deleting anything, save that registry hive, and quad check what you do.

But ensure the HEX DATA is what you want or else you can make your system unbootable. Quad check it!!!

ADDED:

  • If you take the care to not delete (only rename) the \??\Volume{ one, and also to not edit the hex data of it, you can be safe
  • In the worst-case scenario, you to need to boot with a Windows install DVD and go to console mode, run regedit, and rename it back to start with \??\Volume{

SO:

  • Always do one at a time...better to stay on the safe side

You have been warned, it is touching the registry by hand.

Why does this work?

  • It is telling Windows to ignore that 'volume', so it doesn't assign a letter or list it in the Safely Remove Hardware list for that device.

Yes, this works for USB memory cards, sticks, etc., without needing to touch the Removable Media Bit... it is just only to hide such partitions.

Side note: This is also valid for any other partition you do not want to auto-mount on USB connect.

1

I used gparted on linux to change the partition table to GPT and set the flag 'hidden', then did 'fdisk -t' to set the guid as microsoft reserved (10), no more 'format disk' messages on windows. Even on first time plug. The truecrypt volume mounts just fine on both windows and linux. If that is not enough for you, you can use diskpart on windows and use 'GPT ATTRIBUTES=0x4000000000000000', that should most definitely work.

DISKPART> detail partition

Partition 1
Type    : e3c9e316-0b5c-4db8-817d-f92df00215ae
Hidden  : Yes
Required: Yes
Attrib  : 0X0000000000000001
Offset in Bytes: 1048576

There is no volume associated with this partition.
  • Welcome to SuperUser! Your post doesn't appear to address the question in a useful manner, since the OP specifies Windows and your answer is about Linux. Also, this is a VERY old post with various answers, one of which is accepted. You will find that you will have a better experience if you take moment to take the Stack Overflow tour. If you follow the norms of the Stack Overflow community and approach it with an attitude of helping others too, it will serve you well. – Rey Juna Jan 18 at 19:40
  • @Rey Juna, the answer also said that OP could use "DISKPART on windows" and set GPT ATTRIBUTES. By the way, StackExchange doesn't exist only for solving the OP question. KopetePanda provided a possibly useful answer, too. I came here because I am not a regular Windows user (most of time I use Linux) and I faced a windows system with this annoying error, Windows 7 opens dozens of popups, offering to format the disk - even if the disk was formatted in Windows itself! I'll try KopetePanda's linux solution, since all the Windows solutions proposed (even the accepted answer) didn't work for me. – mguima Mar 17 at 22:03
  • @mguima I'm glad this answer worked for you. However, I think that another question/answer specific to Linux would be easier to find for anyone in your situation rather than burying it in a post that has a different configuration. – Rey Juna Mar 18 at 15:20
  • @Rey Juna, Of course the same answer in a question especific to linux would be easier to find. But this question didn't existed. And, after searching for a while in a lot of places, I was able to find it. – mguima Apr 27 at 21:13
-1

I managed to achieve it by creating the drive as a GPT and then using diskpart to modify the partition GPT ATTRIBUTES...

list disk
select disk # <- your disk number here
list partition
select partition # <- your partition number here
GPT ATTRIBUTES=0xC000000000000001
exit

0x0000000000000001 marks the partition as required.
0x8000000000000000 Prevents the partition from having a drive letter automatically assigned.
0x4000000000000000 Defines the partition's volume as hidden.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.