Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[HOWTO] truecrypt resize an existing logical volume
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
magowiz
Veteran
Veteran


Joined: 17 Feb 2005
Posts: 1029
Location: Italy/Milan/Bresso

PostPosted: Sun Sep 14, 2008 2:07 pm    Post subject: [HOWTO] truecrypt resize an existing logical volume Reply with quote

Hi,
since the only way to enlarge or shrink a truecrypt logical volume is to create a new one and copy files over it I made a script that automates this process , the script use the same password you used for the old volume and any eventual key files (these parameters must be input), this script lets you anyway change the other parameters of new volume:
Code:
#!/bin/sh
echo "==GETTING ORIGINAL VOLUME ACCESS DATA=="
echo ""
read -p "Enter the volume path: " vpath;
stty -echo
read -p "Enter the volume Password: " passw;
echo
stty echo
read -p "Enter keyfiles list (empty for none):" kfl;
mkdir /mnt/tcold
echo ""
echo "==MOUNTING ORIGINAL VOLUME=="
truecrypt -p ${passw} -k ${kfl} ${vpath} /mnt/tcold
truecrypt -c ${vpath}.new  --random-source=/dev/urandom -k ${kfl} -p ${passw}
echo""
echo"==SETTING UP NEW VOLUME=="
read -p "Enter new volume filesystem: " fstype;
truecrypt --filesystem=none  -k ${kfl} -p ${passw} ${vpath}.new
orld=`truecrypt --list ${vpath} | grep -o "/dev/loop[0-32]"`
nld=`truecrypt --list ${vpath}.new | grep -o "/dev/loop[0-32]"`
mkdir /mnt/tcnew
mkfs.${fstype} ${nld}
truecrypt -d  ${vpath}.new
echo ""
echo"==MOUNTING NEW VOLUME=="
truecrypt -k ${kfl} -p ${passw} ${vpath}.new /mnt/tcnew
echo ""
echo "==COPYING FROM ORIGINAL VOLUME TO NEW VOLUME=="
cd /mnt/tcold/
cp -av . ../tcnew
username=`stat -c %U .`
groupname=`stat -c %G .`
cd /mnt/tcnew/
chown ${username}:${groupname} .
cd
echo "==DISMOUNTING VOLUMES AND CLEANING UP=="
truecrypt -d ${vpath}.new
truecrypt -d ${vpath}
mv ${vpath} ${vpath}.old
mv ${vpath}.new ${vpath}
rmdir /mnt/tcold
rmdir /mnt/tcnew


I hope you will find it useful , anyway it isn't much elegant and should be improved, any suggestion or critics are welcome .
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum