magowiz Veteran
Joined: 17 Feb 2005 Posts: 1029 Location: Italy/Milan/Bresso
|
Posted: Sun Sep 14, 2008 2:07 pm Post subject: [HOWTO] truecrypt resize an existing logical volume |
|
|
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 . |
|