✅ Requirements

  • Windows 10/11 Pro or higher (or Home with VHDX support)
  • VeraCrypt

🔍 What is a VHDX File?

A VHDX (Virtual Hard Disk v2) is a disk image format introduced by Microsoft. It acts like a virtual hard drive stored in a single file and can be mounted to behave like a physical disk. You can store files, install software, or even boot from it in certain scenarios.

Key features:

  • Supports sizes up to 64 TB
  • Dynamic expansion or fixed size
  • Ideal for encrypted containers or virtual storage

🔹 STEP 1: Create a Dynamic VHDX File

  1. Open Disk Management:
    • Press Win + X → click Disk Management
  2. Create a VHDX:
    • Click ActionCreate VHD
    • Choose:
      • Location: e.g., D:\EncryptedDisk.vhdx
      • Virtual hard disk format: VHDX
      • Virtual hard disk type: Dynamically expanding
      • Size: e.g., 20 GB
    • Click OK
  3. The VHDX will appear as “Not Initialized” in Disk Management.

🔹 STEP 2: Initialize and Format the VHDX

  1. Right-click the new disk (e.g., “Disk 2”) → Initialize Disk
    • Choose GPT
  2. Right-click the unallocated space → New Simple Volume
    • Format with NTFS or exFAT
    • Assign a drive letter (e.g., E:)
  3. Done! You now have a mounted virtual drive.

🔐 What is VeraCrypt?

VeraCrypt is a free and open-source disk encryption software. It allows you to create encrypted volumes or encrypt entire drives. It’s a fork of the discontinued TrueCrypt, offering:

  • Strong AES, Serpent, and Twofish encryption
  • Support for hidden volumes
  • Keyfile-based authentication
  • Portable versions available

📥 Download VeraCrypt


🧰 Why Combine VHDX with VeraCrypt?

Using a VHDX file encrypted by VeraCrypt gives you the flexibility of dynamic disk size and powerful encryption. It’s perfect for:

  • Keeping private files safe
  • Backing up sensitive data
  • Portable encrypted storage on USB
  • Cloud-synced secure containers (e.g., Google Drive, OneDrive)

🔹 STEP 1: Encrypt the VHDX with VeraCrypt

  1. Open VeraCrypt
  2. Click Create Volume → choose:
    • Encrypt a non-system partition/drive

 

      • Click Next
  1. Choose:
    • Standard VeraCrypt volume
    • Click Next
  2. In the device list, select the VHDX-mounted volume (e.g., \\.\Volume{GUID} or E:)
    • Click Next
  3. Choose encryption options (AES is fine) → click Next
  4. Set your strong password → click Next
  5. Format options:
    • Filesystem: NTFS or exFAT
    • Move your mouse around for entropy
    • Click Format (this will erase data on the VHDX volume)
  6. After formatting, VeraCrypt encrypts the entire virtual disk!

🔹 STEP 2: Use the Encrypted VHDX

  1. Next time you want to use it:
    • Mount the .vhdx in Disk Management (or use PowerShell/Batch for automation)
    • Open VeraCrypt
    • Select the volume (E: or \\.\Volume...)
    • Click Mount, enter your password
    • Your encrypted drive appears (e.g., Z:)

🪟 How to Use VeraCrypt VHDX on Another Windows System

  1. Copy the encrypted .vhdx file and VeraCrypt portable folder to USB or cloud.
  2. On the new system:
    • Install or run portable VeraCrypt
    • Use Mount > Select File and enter password/keyfile
  3. Assign a drive letter and mount it normally.

💡 The encryption remains system-independent — any system with VeraCrypt can mount it with the correct credentials.


🔐 Backup: Password and Keyfile Safety

Always keep copies of:

  • Your password in a secure password manager
  • Your keyfile on:
    • A backup USB
    • A cloud drive (Google Drive, encrypted)
    • Another VeraCrypt volume (double-layered encryption)

🛡️ Without your password/keyfile, recovery is nearly impossible!


🚀 Auto-Mount or unmount VeraCrypt VHDX on Windows Login

Requirements:

  • PowerShell script
  • Windows Credential Manager (for password)
  • Optional: USB or cloud-stored keyfile

Steps:

  1. Save your VeraCrypt password:
cmdkey /add:VeraCryptVolume /user:veracrypt /pass:YourSecretPassword
  1. Create MountPrivateVHDX.ps1 script with:
$VHDXPath = "C:\Path\To\Secure.vhdx"
$MountLetter = "Z"
$KeyfilePath = "E:\verakey.key"  # Or Google Drive path
$VeraCryptPath = "C:\Portable\VeraCrypt\VeraCrypt.exe"
$Password = (cmdkey /list | Select-String 'VeraCryptVolume' | Out-String)

Start-Process -FilePath $VeraCryptPath -ArgumentList " /v $VHDXPath /l $MountLetter /a /p $Password /k $KeyfilePath /q /s"
  1. Schedule at login via Task Scheduler:
  • Trigger: At log on
  • Action: Start a program: powershell.exe
  • Arguments: -ExecutionPolicy Bypass -File "C:\Scripts\MountPrivateVHDX.ps1"

📦 Convert to EXE (Optional for Silent Mode)

Use PS2EXE to convert your PowerShell script:

ps2exe -inputFile MountPrivateVHDX.ps1 -outputFile MountPrivateVHDX.exe -noConsole

👋 Auto-Unmount on Shutdown or Logoff

Create a UnmountPrivateVHDX.ps1:

$VeraCryptPath = "C:\Portable\VeraCrypt\VeraCrypt.exe"
Start-Process -FilePath $VeraCryptPath -ArgumentList "/d /f /q"

Schedule in Task Scheduler:

  • Trigger: On shutdown/logoff
  • Action: Run PowerShell script

🔒 Windows Hello + Keyfile Security

While VeraCrypt doesn’t support Windows Hello directly, you can:

  • Store the mount script or keyfile in a Windows Hello-protected folder
  • Use BitLocker or encrypted VHDX that unlocks via biometrics to store your VeraCrypt keyfile

Bonus: Use a biometric USB drive (like Verbatim fingerprint drive) to hold the keyfile.


💡 Tips

  • Enable VeraCrypt’s “Auto-Dismount after inactivity” option
  • Regularly backup your container to a separate encrypted drive
  • Use strong, memorable passwords or a password manager

📥 Download Resources


📺 Watch the Video Tutorial

👉 EngineerHow YouTube Channel


💬 Leave a Comment or Ask a Question!

We’d love to hear your feedback. Share your setup or ask questions in the comments.


🧠 About EngineerHow.com

EngineerHow.com is your go-to resource for IT & engineering tutorials, with a focus on self-hosting, open-source tools, networking, server setups, and civil engineering content.

Subscribe to our YouTube: @EngineerHow