Smart Systems for Home

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

Encrypt Folders Files on Linux With VeraCrypt

· 8 min read · Home Tech

In this article
  1. What VeraCrypt Does and How It Works
  2. Container vs. Partition Encryption: Which Should You Choose?
  3. Step-by-Step: How to Create and Use an Encrypted Container
  4. Encrypting a Whole Partition or External Drive
  5. Common Problems and Troubleshooting
  6. Alternatives to VeraCrypt on Linux
  7. Security Considerations and Best Practices
  8. Frequently Asked Questions

Yes, you can encrypt folders and files on Linux with VeraCrypt. VeraCrypt creates encrypted containers (a single file that acts as a virtual disk) or encrypts entire partitions/drives, and you mount them to access the data with a password. This article explains the process, the differences between container and device encryption, and how to choose the right approach for your files.

What VeraCrypt Does and How It Works

VeraCrypt is a free, open-source disk encryption tool that descended from TrueCrypt (which was discontinued in 2014). It works by creating an encrypted volume—either a file that behaves like a separate disk (a container) or a whole partition or storage device. When you mount the volume, you enter a password (and optionally a keyfile), and the data is decrypted on the fly. While mounted, you can read and write files normally; when you unmount it, the data is locked and appears as random noise to anyone without the password.

The encryption algorithms include AES, Serpent, and Twofish, and you can combine them (e.g., AES-Twofish-Serpent). The hash functions are SHA-512, Whirlpool, and Streebog. VeraCrypt also offers plausible deniability through hidden volumes—a hidden volume inside a normal volume whose existence cannot be proven without the hidden volume's password.

Container vs. Partition Encryption: Which Should You Choose?

You have two main options when encrypting on Linux:

  • Encrypted container (file) – A single file that you create with VeraCrypt, which acts like a virtual disk. You can store it anywhere (on your hard drive, USB stick, cloud drive) and move it easily. It's ideal for encrypting a folder of files without affecting the rest of the system.
  • Encrypted partition or device – The entire partition (e.g., /dev/sdb1) or a whole drive is encrypted. This is useful for external drives or a dedicated data partition. You cannot use the partition for anything else while it's encrypted; you must mount it with VeraCrypt to access its contents.

For most users who want to encrypt a folder or a set of files, a container is simpler and more flexible. You can create a container that is, say, 2 GB in size and treat it like a USB stick—copy your sensitive files into it, then unmount it. The container file itself is just a regular file; you can back it up or move it without losing the encryption.

Step-by-Step: How to Create and Use an Encrypted Container

Here's how to set up a VeraCrypt container on Linux (the steps are similar across versions):

  1. Install VeraCrypt – Download the Linux installer from the official VeraCrypt website (or use your distribution's package manager if it's available). For Debian/Ubuntu, you can download the .deb package; for Fedora, the .rpm. Run the installer and follow the GUI prompts.
  2. Launch VeraCrypt – From the application menu or terminal (run veracrypt). The main window lists mounted volumes.
  3. Create a volume – Click “Create Volume”. Choose “Create an encrypted file container” and click Next.
  4. Select container type – Choose “Standard VeraCrypt volume” (hidden volumes are an advanced option). Click Next.
  5. Set the container path – Click “Select File” and choose a location and name for the container file (e.g., ~/Documents/private.tc). Click Next.
  6. Choose encryption options – The defaults (AES, SHA-512) are fine for most users. Click Next.
  7. Set the size – Enter the desired size (e.g., 500 MB or 10 GB). This is the maximum capacity of the container. Click Next.
  8. Set a password – Enter a strong password (at least 20 characters recommended). You can also use a keyfile for extra security. Click Next.
  9. Choose filesystem – For Linux, select ext4 or ext3 (or FAT if you need compatibility with Windows). Click Next.
  10. Format the volume – Move your mouse randomly in the window as instructed to generate encryption keys, then click “Format”. Wait for it to finish, then click “Exit”.

Now you have an encrypted container. To use it:

  1. In the main VeraCrypt window, select an unused slot (e.g., slot 1).
  2. Click “Select File” and choose your container file.
  3. Click “Mount”. Enter your password when prompted.
  4. The container will appear as a mounted drive (e.g., /media/veracrypt1). You can copy files into it, edit them, etc.
  5. When done, right-click the mounted volume in VeraCrypt and select “Dismount”.

Encrypting a Whole Partition or External Drive

If you want to encrypt an entire USB drive or a separate hard disk partition, the process is similar but you select “Encrypt a non-system partition” during volume creation. You'll need to identify the device (e.g., /dev/sdb1) and be careful to choose the correct one—VeraCrypt will warn you that formatting will erase all data on that partition. After creation, you mount the partition by selecting “Device” instead of “File” in the main window.

Note: VeraCrypt cannot encrypt the Linux system partition (where the OS is installed) because the bootloader would need to prompt for a password before the OS loads. For full disk encryption of your system drive, use LUKS (Linux Unified Key Setup) which is built into the Linux kernel and is the standard for system encryption.

Common Problems and Troubleshooting

Here are a few issues you might run into:

  • “No free slot” error – You can only mount a limited number of volumes at once (usually 64). Dismount unused volumes or use a different slot.
  • Filesystem not recognized – If you have trouble mounting, ensure you selected the correct filesystem when creating the volume. If you chose ext4, you need the ext4 driver (standard on Linux).
  • Forgot password – There is no recovery. VeraCrypt does not have a backdoor. If you forget the password, the data is lost forever.
  • Slow performance – Encryption/decryption uses CPU. If you have an older CPU, consider using a simpler algorithm (e.g., AES only) or enable hardware acceleration if your CPU supports AES-NI.
  • Cannot mount as non-root – On some distributions, you may need to run VeraCrypt with sudo or add your user to the appropriate group (e.g., fuse).

Alternatives to VeraCrypt on Linux

VeraCrypt is not the only option. Here are a few alternatives:

  • LUKS (cryptsetup) – The standard for full disk encryption on Linux. It's integrated into the kernel and works with the cryptsetup tool. You can create encrypted partitions and use them with LVM, and it supports key management with multiple passphrases.
  • gocryptfs – A file-based encryption system that encrypts individual files, allowing you to sync only encrypted files to cloud storage. It uses per-file keys and is designed for cloud backup.
  • Cryptomator – A user-friendly tool that creates an encrypted vault for cloud storage. It's cross-platform and has mobile apps, but it's not as low-level as VeraCrypt.
  • eCryptfs – A stacked filesystem that encrypts files at the file level, used in older Ubuntu installations. It's less common now but still available.

For most users who want to encrypt a folder or a few files, VeraCrypt's container approach is straightforward and portable. For full system encryption, LUKS is the recommended choice.

Security Considerations and Best Practices

Encryption is only as strong as your password and habits. Here are some important points:

  • Use a strong password – At least 20 characters, mixing uppercase, lowercase, numbers, and symbols. Consider a passphrase like “correct horse battery staple” but make it unique.
  • Back up the header – VeraCrypt allows you to back up the volume header (which contains encryption parameters). If the header gets corrupted, you can restore it. Do this when you create the volume and store the backup in a safe place.
  • Unmount before shutdown – Always dismount your volumes before turning off the computer to avoid filesystem corruption.
  • Hidden volumes – If you need plausible deniability, create a hidden volume inside a standard volume. The hidden volume is protected by a different password, and without it, there is no way to prove it exists.
  • Do not store the container in a location that is automatically synced while mounted – If you mount the container and it's inside a cloud-synced folder (e.g., Dropbox), the entire container file will be uploaded in its raw form. That's fine, but if you modify files while mounted, the whole container may be re-uploaded, which could be slow and leak metadata.

Frequently Asked Questions

Can I encrypt just a single folder without creating a container?

VeraCrypt does not have a “right-click to encrypt folder” feature. You must create a container and move the folder's contents into it. Alternatively, you could use a file-based encryption tool like gocryptfs that encrypts individual files in a directory without a fixed-size container.

Is VeraCrypt safe to use in 2025?

Yes, VeraCrypt is actively maintained and has undergone security audits. It is widely used and considered secure when used correctly. The main risks are password weakness and user error (like forgetting to unmount).

Can I mount a VeraCrypt container on Windows or macOS?

Yes, VeraCrypt is cross-platform. You can create a container on Linux and mount it on Windows or macOS, provided you use a filesystem that all systems can read (like FAT or exFAT). For Linux-native filesystems like ext4, Windows and macOS cannot read them without additional drivers.

How do I change the password of an existing VeraCrypt volume?

Mount the volume first, then in the main VeraCrypt window select the mounted volume and click “Volume” → “Change Volume Password”. You'll need the current password and then enter the new one twice.

What happens if I lose the keyfile?

If you used a keyfile in addition to a password, the keyfile is required to mount the volume. If you lose it, you cannot access the data. There is no way to recover it. Always keep a backup of the keyfile in a safe location.

Is it possible to encrypt an external USB drive with VeraCrypt and still use it on Windows?

Yes, create the volume on the USB drive and choose a filesystem like FAT or exFAT. Then you can mount it on both Linux and Windows with VeraCrypt. Just remember to dismount before unplugging.