Android already encrypts the whole device, but there are situations where you need a separate, portable vault:
VeraCrypt client provides a UI wrapper. The steps below give you full control, the ability to script operations, and a deeper understanding of the process./data/data/com.termux/files). Existing data outside this area is untouched, but backing up important files is always a good habit.pkg update && pkg upgrade -y
This ensures you have the latest clang, make, and other build tools.Why this matters: an up‑to‑date toolchain avoids compilation errors caused by missing symbols that older libraries might lack.
pkg install git wget tar proot clang make openssl-dev libcrypt-dev zlib-dev
ncurses-dev if you want the text‑based VeraCrypt UI.
pkg install ncurses-dev
These packages provide the compiler (clang), the GNU make system, and the cryptographic libraries VeraCrypt links against.
~/src:
mkdir -p ~/src && cd ~/src
wget https://launchpad.net/veracrypt/trunk/1.26.7/+download/VeraCrypt_1.26.7_Source.tar.bz2
sha256sum VeraCrypt_1.26.7_Source.tar.bz2
Compare the output with the published checksum; if they differ, abort and re‑download.
tar xjf VeraCrypt_1.26.7_Source.tar.bz2
The source will be placed in a directory called VeraCrypt_1.26.7.
Verification ensures the code has not been tampered with on the way to your device.
cd VeraCrypt_1.26.7
Makefile and locate the line defining OS. Change it to OS=android.
sed -i 's/^OS=.*/OS=android/' Makefile
make
You will see compilation messages. If you encounter an error about sys/mman.h or similar, ensure the libcrypt-dev and openssl-dev packages are installed.
veracrypt will appear in the current directory.
Why we compile locally: Pre‑compiled binaries for Android are rare and often bundled with root requirements. Building from source guarantees the binary runs in Termux’s user space, keeping the device unrooted.
mkdir -p ~/bin && cp veracrypt ~/bin/
PATH. Add the following line to ~/.bashrc (or ~/.zshrc if you use Zsh):
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
Then reload the shell:
source ~/.bashrc
veracrypt --version
You should see the version number and a short usage summary.
Placing the binary in ~/bin keeps it separate from the source tree and makes future updates easier.
veracrypt --text --create ~/veracrypt_container.hc --size 500M --encryption AES --hash SHA-512 --filesystem exfat --pim 0 --keyfiles "" --password
The command will prompt you to enter a password twice. Choose a strong, memorable passphrase (at least 12 characters, mix of letters, numbers, symbols).
--text – runs VeraCrypt in command‑line mode (required in Termux).--create – creates a new volume.--size – size of the container.--encryption – encryption algorithm (AES is the default and widely trusted).--hash – hash algorithm for the key derivation.--filesystem – we use exfat for cross‑platform compatibility; you can choose fat or ntfs if you prefer.--pim 0 – disables the optional Personal Iterations Multiplier; leave at 0 unless you have a specific need.--keyfiles "" – indicates no additional keyfiles.Result: a single file veracrypt_container.hc that holds an encrypted filesystem.
mkdir -p ~/mnt/veracrypt
veracrypt --text --mount ~/veracrypt_container.hc ~/mnt/veracrypt
You will be asked for the password again. If the mount succeeds, the command returns silently.
ls -l ~/mnt/veracrypt
You should see an empty directory (or the files you previously stored).
Why mounting matters: while the container is mounted, the encrypted data is available as a regular directory. When you unmount, the underlying file becomes unreadable without the password.
cp /sdcard/Download/secret.pdf ~/mnt/veracrypt/
SAF (Storage Access Framework) bridge. Install the helper app Termux:API and run:
termux-open ~/mnt/veracrypt
This opens the mounted folder in the system picker, allowing other apps read/write access while the volume remains mounted.
Tip: Keep the mount point inside Termux’s private storage (/data/data/com.termux/files/home) to avoid accidental exposure through Android’s media scanner.
veracrypt --text --dismount ~/mnt/veracrypt
You will see a confirmation line.
rmdir ~/mnt/veracrypt
Unmounting removes the decrypted view from memory and ensures the container is locked again.
vc-mount.sh in ~/bin:
cat > ~/bin/vc-mount.sh <<'EOF'
#!/data/data/com.termux/files/usr/bin/bash
CONTAINER="$HOME/veracrypt_container.hc"
MOUNTPOINT="$HOME/mnt/veracrypt"
if [[ ! -d "$MOUNTPOINT" ]]; then
mkdir -p "$MOUNTPOINT"
fi
veracrypt --text --mount "$CONTAINER" "$MOUNTPOINT"
EOF
chmod +x ~/bin/vc-mount.sh
cat > ~/bin/vc-dismount.sh <<'EOF'
#!/data/data/com.termux/files/usr/bin/bash
MOUNTPOINT="$HOME/mnt/veracrypt"
veracrypt --text --dismount "$MOUNTPOINT"
EOF
chmod +x ~/bin/vc-dismount.sh
vc-mount.sh and vc-dismount.sh with a single tap from Termux or via a widget (Termux:Widget plugin) for quick access.
This automation saves you from re‑typing the long command each time.
Make sure the openssl-dev package is installed. Re‑run:
pkg install openssl-dev
Then clean the build directory (make clean) and start again.
/sdcardTermux runs in its own sandbox. To read/write external storage you must grant the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions:
termux-setup-storage
Accept the Android prompt. After that, /sdcard will be symlinked to ~/storage/shared.
Typical causes:
.hc file.--protect-hidden flag or restore from a backup.VeraCrypt keeps a cache of the decrypted filesystem in RAM. Reduce the container size or use a lighter filesystem like fat instead of exfat. Example:
veracrypt --text --create ~/veracrypt_container.hc --size 200M --filesystem fat
Some app may still hold an open file handle. Close any file manager windows that are viewing the mount point, then retry. If the problem persists, force dismount:
veracrypt --text --dismount "$HOME/mnt/veracrypt" --force
Use the --force option only as a last resort, as it may cause data loss for any unsaved changes.
.hc file to an external SD card or cloud storage (encrypted again) regularly.pkg upgrade -y periodically to receive security patches for the underlying toolchain.If compiling sounds daunting, you can install the pre‑built VeraCrypt APK from the official website (requires allowing installation from “unknown sources”). The app provides a UI but still runs without root. However, the Termux method has two advantages:
Tasker.By following this tutorial you have turned your Android phone into a portable, strong‑encryption vault without touching the system partition. The workflow—install Termux, compile VeraCrypt, create a container, mount, use, and dismount—covers the entire lifecycle of secure file storage on an unrooted device. Remember to keep your password safe, back up the container file, and unmount when finished. With these habits, you can protect sensitive documents, private photos, or any data you wish to keep out of the hands of apps and prying eyes.









