LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 01-12-2010, 11:25 PM   #1
piratesmack
Member
 
Registered: Feb 2009
Distribution: Slackware, Arch
Posts: 518

Rep: Reputation: 133Reputation: 133
Automount encrypted Windows partition (truecrypt)


I'm trying to automount my encrypted Windows partition in Slackware-Current.

With help from the Gentoo wiki, I came up with this script:
Code:
#!/bin/sh
# /sbin/mount.truecrypt

DEV="$1"
MNTPNT="$2"
FS=""
MNTOPTS=""
FSOPTS=""

shift 3
IFS=","
for arg in $@; do
  case $arg in
    system)
      MNTOPTS="system"
    ;;
    fs=*)
      FS="${arg#fs=}"
    ;;
    password=*)
      PASS="${arg#password=}"
    ;;
    *)
      FSOPTS="${FSOPTS}${arg},"
    ;;
  esac
done

/usr/bin/truecrypt \
  --mount \
  --mount-options="$MNTOPTS" \
  --password="$PASS" \
  --filesystem="$FS" \
  --fs-options="${FSOPTS%,}" \
$DEV $MNTPNT
Then I added this to my fstab:
Code:
/dev/sda4 /mnt/windows truecrypt rw,system,pw=MYPASS,fs=ntfs-3g,umask=000,noatime 1 0
I get this error when I try to mount my partition (as root):
Code:
# mount /mnt/windows/
No protocol specified
Error: Unable to initialize gtk, is DISPLAY set properly?
But if I run my script like this (exactly how mount runs it), it works fine:
Code:
# /sbin/mount.truecrypt /dev/sda4 /mnt/windows -o rw,noatime,system,password=MYPASS,fs=ntfs-3g,umask=000
Any ideas?

EDIT

Fixed it with the -t option.
But if anybody has a better solution, let me know.

New script
Code:
#!/bin/sh
#/sbin/mount.truecrypt

DEV="$1"
MNTPNT="$2"
FS=""
MNTOPTS=""
FSOPTS=""
PASS=""

ARGS="$(echo $@ | sed -e 's/,/ /g')"
for arg in $ARGS; do
  case $arg in
    $DEV | $MNTPNT | -v | -o)
      #ignore these
    ;;
    headerbak | nokernelcrypto | readonly | ro | system | timestamp | ts)
      MNTOPTS="${MNTOPTS}${arg},"
    ;;
    fs=*)
      FS="${arg#fs=}"
    ;;
    pw=*)
      PASS="${arg#pw=}"
    ;;
    *)
      FSOPTS="${FSOPTS}${arg},"
    ;;
  esac
done

#Remove the last comma in list
MNTOPTS="${MNTOPTS%,}"
FSOPTS="${FSOPTS%,}"

echo "$DEV on $MNTPNT type $FS ($FSOPTS)"
[ -n "$MNTOPTS" ] && MNTOPTS="-m=${MNTOPTS}"
[ -n "$FS" ] && FS="--filesystem=${FS}"
[ -n "$FSOPTS" ] && FSOPTS="--fs-options=${FSOPTS}"

/usr/bin/truecrypt -t $MNTOPTS $FS $FSOPTS $DEV $MNTPNT 1>/dev/null <<EOF
$PASS

n
EOF

Last edited by piratesmack; 01-13-2010 at 11:51 PM.
 
Old 01-13-2010, 04:34 PM   #2
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Slackware 14.1 (multilib) with kernel 3.15.5
Posts: 1,536
Blog Entries: 12

Rep: Reputation: 172Reputation: 172
Are you working from an xterm or from the console? I only get the dreaded "Error: Unable to initialize gtk, is DISPLAY set properly?" when logged in as non-root in X (don't ever run as root) but run commands as root in an xterm. There's a way around that exporting your DISPLAY, but since that's basically over my head , I can't remember how do it without looking it up.
 
Old 01-13-2010, 11:38 PM   #3
piratesmack
Member
 
Registered: Feb 2009
Distribution: Slackware, Arch
Posts: 518

Original Poster
Rep: Reputation: 133Reputation: 133
Quote:
Originally Posted by mostlyharmless View Post
Are you working from an xterm or from the console? I only get the dreaded "Error: Unable to initialize gtk, is DISPLAY set properly?" when logged in as non-root in X (don't ever run as root) but run commands as root in an xterm. There's a way around that exporting your DISPLAY, but since that's basically over my head , I can't remember how do it without looking it up.


I was working from an xterm.
The command worked fine when I ran it manually (as both root and my user account), I only got the error when mount tried to run the script.

Oh well, I guess I need the -t switch anyway since I want this mounted on boot.

Bonus question:
Is there any way to make my truecrypt volume unmount with "umount /mnt/windows" instead of "truecrypt -t -d"?

I tried making a script "/sbin/umount.truecrypt", but it doesn't seem to run it.

Last edited by piratesmack; 01-14-2010 at 12:08 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Can't write to encrypted Windows partition (truecrypt) piratesmack Slackware 2 01-12-2010 09:30 PM
encrypted remove backup with truecrypt browny_amiga Linux - General 1 09-03-2009 11:43 PM
Encrypted data backup w/truecrypt Roflcopter Linux - Security 1 04-12-2009 05:41 AM
Truecrypt encrypted USB drive on Linux irairaira Linux - Newbie 9 01-09-2009 01:09 AM
Encrypted Ubuntu with TrueCrypt penguinHugger Linux - General 5 12-19-2008 03:08 PM


All times are GMT -5. The time now is 11:51 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration