Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

BitLocker Encrypted Container File: Step-by-Step

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide shows you how to create an encrypted container file using BitLocker, a built-in Windows encryption tool. You'll end up with a single file that acts like a virtual drive; when you mount it and enter your password, you can store files inside it, and when you unmount it, the file is locked and encrypted. No extra software is needed if you're on Windows 10 or 11 Pro, Enterprise, or Education editions.

What You'll Need

  • Windows 10 or 11 Pro, Enterprise, or Education (BitLocker is not available on Home editions).
  • Administrator access to your computer.
  • A fixed drive (not a USB flash drive) with enough free space for the container file you plan to create.
  • A strong password or a smart card (if you choose that option).

Step-by-Step

  1. Create a blank virtual disk file. Open Command Prompt as Administrator (search for “cmd”, right-click, and select “Run as administrator”). Type the following command and press Enter, replacing D:\Container.vhd with your desired path and filename, and 2048 with the size in megabytes (2048 MB = 2 GB):
    diskpart
    create vdisk file="D:\Container.vhd" maximum=2048 type=fixed
    select vdisk file="D:\Container.vhd"
    attach vdisk
    After running these commands, DiskPart will create a fixed-size VHD file and attach it as a new unallocated disk on your system.
  2. Initialize and format the virtual disk. Open Disk Management (right-click the Start button and select “Disk Management”). You should see a new disk labeled “Unknown” and “Not Initialized”. Right-click the disk name on the left (e.g., “Disk 1”) and select “Initialize Disk”. Choose GPT (or MBR if you prefer, but GPT is recommended for modern systems), then click OK. Now right-click the unallocated space on the disk and select “New Simple Volume”. Follow the wizard: assign a drive letter (e.g., E:), choose NTFS as the file system, and leave the default allocation unit size. Complete the wizard; the disk will now appear as a normal drive.
  3. Enable BitLocker on the virtual drive. In File Explorer, right-click the new drive (e.g., E:) and select “Turn on BitLocker”. If the option is greyed out, make sure you are using a Pro/Edu/Enterprise edition of Windows.
  4. Choose an unlock method. BitLocker will ask how you want to unlock the drive. Select “Use a password to unlock the drive”, then enter a strong password (at least 8 characters, mixing upper/lowercase, numbers, and symbols). Confirm it and click Next.
  5. Back up your recovery key. BitLocker will offer to save a recovery key—a 48-digit number that can unlock the drive if you forget your password. Choose “Save to a file” (recommended) and store it somewhere safe, like a different physical drive or a password manager. Do not store it on the same virtual drive. Click Next.
  6. Choose how much to encrypt. Select “Encrypt used disk space only” if you want it to finish quickly, or “Encrypt entire drive” for maximum security (recommended for new drives). Click Next.
  7. Select encryption mode. Choose “Compatible mode” if you might need to use the drive on older Windows versions, or “New encryption mode” for better security on current systems. Click Next.
  8. Start encryption. Click “Start encrypting”. The process may take a few minutes to a few hours depending on the size of the virtual disk and your hardware. You can continue using your computer, but avoid turning it off during encryption.
  9. Detach the virtual disk. Once encryption is complete, you can safely detach the VHD. Open Command Prompt as Administrator and run:
    diskpart
    select vdisk file="D:\Container.vhd"
    detach vdisk
    Your container file is now ready. To use it later, double-click the .vhd file (or use DiskPart to attach it), enter your password when prompted, and it will appear as a normal drive.

Common Mistakes

  • Using a dynamic VHD instead of fixed. Dynamic disks grow over time, which can cause performance issues and make BitLocker encryption slower. Always use type=fixed for a container you plan to encrypt.
  • Not saving the recovery key. If you forget your password and have no recovery key, your data is permanently inaccessible. This is a common and costly mistake.
  • Choosing “Encrypt used disk space only” on a new drive. On a freshly formatted drive, this is fine, but if the drive has any residual data from previous use, it won't be encrypted. For a clean container, “Encrypt entire drive” is safer.
  • Detaching without unmounting. If you unplug or detach the VHD while files are open, you may corrupt the filesystem. Always close all files and safely eject the drive (or detach via DiskPart) before removing it.

Tips

  • Use a fixed-size VHD rather than VHDX for maximum compatibility with older Windows versions, though VHDX is fine for newer systems.
  • Keep the container file on an NTFS or ReFS drive; FAT32 cannot store files larger than 4 GB.
  • If you need to move the container to another computer, just copy the .vhd file and attach it there—BitLocker will prompt for the password.
  • Consider using a password manager to store the recovery key, but never store it on the same virtual drive.
  • For extra security, you can also use a smart card or TPM-based unlock, but a password is simplest for a portable container.

Troubleshooting

  • BitLocker option is greyed out. Ensure you are on Windows 10/11 Pro, Enterprise, or Education. Home editions do not support BitLocker. Also, the drive must be formatted with NTFS (or exFAT on some systems) and have a drive letter assigned.
  • DiskPart says “The disk is not initialized”. Go to Disk Management, right-click the disk, and initialize it. If the option is missing, make sure the VHD is attached (check DiskPart or Disk Management).
  • Encryption fails or stops. Check that the virtual disk has enough free space (at least 1% of its size) and that your computer is not in sleep mode. Try running chkdsk on the virtual drive before encrypting.
  • Forgot your password. You can use the recovery key to unlock the drive. If you lost that too, the data is unrecoverable—there is no backdoor.
  • VHD file won't attach. Make sure the file is not corrupted and that you have permission to read it. Try attaching via DiskPart or Disk Management instead of double-clicking.

Frequently Asked Questions

Can I use BitLocker on a USB flash drive?

Yes, BitLocker To Go works on USB drives, but the container file method described here is for a VHD on a fixed drive. For a USB drive, you can enable BitLocker directly on the drive itself.

Is the container file encrypted when I'm not using it?

Yes, when the VHD is detached, the file is fully encrypted. When attached and unlocked, the data is accessible to anyone with the password.

Can I resize the container after creating it?

For a fixed-size VHD, no. You would need to create a new, larger VHD and copy the contents. For a dynamic VHD, you can expand it using DiskPart, but BitLocker may not support resizing an encrypted dynamic disk.

Does BitLocker slow down performance?

There is a slight performance overhead, especially on older hardware. Modern CPUs with AES-NI instructions make the impact minimal for most tasks.

Can I use the same container on a Mac or Linux?

BitLocker is a Windows feature. Mac and Linux can mount BitLocker-encrypted drives with third-party tools, but the VHD file itself may need to be attached first using a virtual disk utility.

What happens if I delete the VHD file?

All data inside is permanently lost. There is no way to recover it unless you have a backup of the file itself.