Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to code a bash script that will automate the several tasks related to truecrypt. Tasks are: Creating a truecrypt volume, mounting it, copying a file in filesystem, modifying the file, unmounting the volume.

I have a question regarding creating the truecrypt volume. mounting and unmounting will not be a problem for me.

The command for creating volume is according to manpages:

> truecrypt -c [volume path]

but after this command trucrypt will prompt user to enter several parameters like volume type, size, encryption, hash, password etc.

How can automate all these so that user doesn't need to enter any value? Ok I can use following command for this:

truecrypt –size 200M –type normal –encryption AES –hash SHA-512 –filesystem FAT -c

But now it asks for password. How to automate that?


share|improve this question
expect is what you need. There may be easier ways, but thats what comes to my mind. – Mahesh Nov 18 '12 at 13:09
up vote 3 down vote accepted

Use the --password=password flag to pass a random/set password through.

I would also use the --non-interactive flag so nothing interrupts the automation process.

Here is a list of all available commands to use with truecrypt:

share|improve this answer
Hey taang, I think we just posted almost at the same time. ;) Still thanks. – ρss Nov 19 '12 at 21:48
and what would be secure way of doing this - without visible password? – Tomáš Fejfar Jun 25 '13 at 12:31

At last I got the solution. I shall provide it here so that it may assist someone else in future.
Before scripting with truecrypt always keep in mind the version number.
The solution worked with charm for version 7.1a
Can't comment about other versions.

Here is the command to create a truecrypt volume without prompting the user to enter any parameters:

truecrypt -t --size=1074000000 --password=123 -k "" --random-source=/dev/urandom --volume-type=normal --encryption=AES --hash=SHA-512 --filesystem=FAT -c

NOTE: This is an insecure method as password is visible!!!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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