Question: I have an external HDD and use TrueCrypt for keeping encrypted file containers.
After mounting, whenever I try to dismount a file container (using TrueCrypt 7.0a on Ubuntu 11.04), it just does not happen and I get the following message:

```
device-mapper: remove ioctl failed: Device or resource busy
Command failed

```

Further, if I close TrueCrypt and then try to start it again, it says that TrueCrypt is already running, but I cannot access it from the Unity sidebar (because it is not there).

Also, if I power down my external HDD, the TrueCrypt volume still shows as one of the mounted volumes, but I cannot do anything with it.

Any possible work around? I remember this NOT happening in earlier versions of Ubuntu so I am guessing there is something to do with 11.04.

Thanks

Answer: 
`cron` isn't the tool for this. You need to set up an `upstart` job which executes during shutdown, preferably declaring a dependency so that it runs before any services it requires shut down. `man 5 init` for the details on how to properly define a startup or shutdown task; I can't help beyond that without more information, as it depends on what you're trying to do and what other `upstart` jobs it depends on.
Try this one, replacing `$HOME` and `$PROFILE` with vapid values and save it to `~/.init` with permission `644`. 

Before you do anything, make sure there is a line like

```
firefox /home/your_name/.mozilla/firefox/your_profile.default tmpfs size=128M,noauto,user,exec,uid=1000,gid=100 0 0

```

in `/etc/fstab`, where the mount option `noauto` prevents tmpfs from being auto-mounted, which could be changed to `auto` to your preference. I leave it there to keep the whole upstart job in integrity.

```
description     "automatic firefox profile ram caching"

start on started mountall
stop on stopping mountall
env HOME="/home/your_name"
env PROFILE="your_profile.default"

script
if test -z "$(mount | grep -F "${HOME}/.mozilla/firefox/${PROFILE}" )"
then
mount "${HOME}/.mozilla/firefox/${PROFILE}"
fi
end script

post-start script
cd "${HOME}/.mozilla/firefox"
if test -f packed.tar
then
    tar xpf packed.tar
    echo "$(date): firefox profile unpacked to ram" >> unpack.log
else
    tar xpf packed.tar.old
    echo "$(date): backup profile unpacked to ram" >> unpack.log
fi
touch "${PROFILE}/.unpacked"
end script 

pre-stop script
cd "${HOME}/.mozilla/firefox"
if test -f "${PROFILE}/.unpacked"
then
    tar --exclude '.unpacked' -cpf packed.tmp.tar "$PROFILE"
    mv packed.tar packed.tar.old
    mv packed.tmp.tar packed.tar
    rm "$PFORILE/.unpacked"
    echo "$(date) firefox profile packed from ram" >> pack.log
else
    echo ".unpacked is missing. pack current session data to newfile"
    tar -cpf packed-$(date +%Y%m%d%H%M).tar "$PROFILE"
fi
end script

```