【问题标题】:Scripted truecrypt mount, without using /dev/ or UUID脚本化 truecrypt 挂载,不使用 /dev/ 或 UUID
【发布时间】:2013-07-19 19:36:07
【问题描述】:

我有 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/,因为它们几乎在我每次重新启动 PC 时都会随机变化。这是因为我的 2 个驱动器是通过 PCI 卡连接的。

【问题讨论】:

    标签: truecrypt automount


    【解决方案1】:

    改用磁盘 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/ 如果您难以理解脚本在做什么,我建议您通读一遍。解释很透彻。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-14
      • 1970-01-01
      • 2020-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-11
      相关资源
      最近更新 更多