脚本化的truecrypt装载,不使用/dev/或UUID



我有5个truecrypt加密的驱动器。运行ubuntu 13.04。我正在尝试在脚本中运行以下命令来装载驱动器。

truecrypt -t /dev/disk/by-uuid/25f8c629-d0c8-4c39-b4c2-aacba38b5882 /media/P --password="$password"  -k "" --protect-hidden=no

由于truecrypt的工作方式,我不能使用它,因为只有在安装驱动器后才能访问UUID。

有没有可能用硬盘序列号或型号做同样的事情?一些更持久的东西?

我不能使用/dev/,因为它们几乎每次重新启动电脑时都会随机更改。这是因为我的两个驱动器是通过PCI卡连接的。

改为使用磁盘ID:

#!/bin/bash
# Run this script as root to avoid entering the root password twice
secret=0xa52f2c38
# Generate tempfile
tempfile=fdisk.tmp
sudo fdisk -l > $tempfile
# --------------------------------------------------------------------------
# Locate secret drive and mount it
# --------------------------------------------------------------------------
num=$[ $(grep -n "^Disk identifier: $secret" $tempfile | cut -f1 -d:) - 5 ]
if [ $num > 0 ] # num will be greater than 0 if drive exists
then
 # Get line containing /dev
 # ----------------------------------------------------------------------
 dev=$(sed -n "${num}p" $tempfile | cut -f2 -d' ' | sed 's/://')
 truecrypt $dev /media/secret
# Check (Create .truecrypt on the mounted volumen beforehand)
# ----------------------------------------------------------------------
 if [ ! -f /media/secret/.truecrypt ]
 then
   zenity --error --text="There was a problem mounting secret"
 fi
fi
rm $tempfile

脚本的来源是:http://delightlylinux.wordpress.com/2012/05/21/mounting-truecrypt-volumes-by-disk-id/如果你很难理解剧本的内容,我建议你通读一遍。解释得很透彻。

最新更新