I set up a TrueCrypt volume in Windows that I want to write to in Linux. It is a file within a hard drive I have mounted to a directory: drwx------ 1 user user 20K Aug 18 02:53 hdd/. I also tried from a local copy of the file. I ran the following commands and was able to read from it, but could not chmod or write to it as root.

user@PC:~$ sudo losetup /dev/loop0 /path/to/volume/file
user@PC:~$ sudo tcplay -d /dev/loop0 -m tcvol
user@PC:~$ sudo mkdir /media/user/tcvol
user@PC:~$ sudo chown user /media/user/tcvol
user@PC:~$ sudo chmod 777 /media/user/tcvol
user@PC:~$ sudo mount /dev/mapper/tcvol /media/user/tcvol
user@PC:~$ sudo cat /media/user/tcvol/somefile
some contents
user@PC:~$ sudo echo "hello world" > /media/user/tcvol/test.txt
bash: /media/user/tcvol/test.txt: Permission denied

At this point, I can read from the volume, but I cannot chmod or write to any volume contents even as root. chmod 777 -R /media/user/tcvol has no output and does not change permissions; same goes for chown. ll produces output like the following:

user@PC:~$ ll /media/user/tcvol
-rwxr-xr-x  1 root root   12 Jul 28 10:06 somefile


I am somehow unable to write to this volume after mounting it. What is going wrong?

Further Details

user@PC:~$ sudo tcplay -d /dev/loop0 -i
Device:         /dev/loop0
PBKDF2 PRF:     whirlpool
PBKDF2 iterations:  1000
Cipher:         SERPENT-256-XTS
Key Length:     512 bits
CRC Key Data:       0x494f9a81
Sector size:        512
Volume size:        1536 sectors
IV offset:      256
Block offset:       256

I was able to figure this out. Since there are only 2 other questions about tcplay and neither address this particular problem, I have decided to share my findings. Without further adieu, my answer:

user@PC:~$ vim /media/user/tcvol/newfile.txt
(i "hello world" esc :wq)
user@PC:~$ cat /media/user/tcvol/newfile.txt
hello world

The writing issue was the echo command, though I am unsure why chmod did not work. After a lot of faffing about. I created a script for mounting and unmounting TrueCrypt volumes as a normal user. I wrote it to /usr/bin/tcmount and chmodded it to 755. The most notable change is this:

user@PS:~$ sudo mount -o uid=`id -u` /dev/loopX /media/user/whatever

The -o uid flag ensures that the user account has rwx access to the mounted volume. Hopefully someone will find this useful.

Edit: I moved the script contents to a pastebin paste. It was cluttering up the answer too much.

| improve this answer | |
  • Hi! Thanks a lot for this answer, amidst all the mega truecrypt-replacement software out there, this simple script worked most reliably for me. I've added this as a github repo (with credits), hope you don't mind: github.com/digital-carver/tcmount – sundar - Reinstate Monica Sep 4 '15 at 11:28
  • +sundar awesome. I've worked on a couple of improvements for the script, but I haven't finalized them; I'll make a pull request when they are done. – Jonathan Voss Sep 6 '15 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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