Is there an auto-dismount in veracrypt or should I always unmount veracrypt volumes manually before shutting down to prevent a broken filesystem/container?
I found the answer for Windows in the veracrypt FAQ, but not for Linux / Ubuntu.
Is there an auto-dismount in veracrypt or should I always unmount veracrypt volumes manually before shutting down to prevent a broken filesystem/container?
I found the answer for Windows in the veracrypt FAQ, but not for Linux / Ubuntu.
There are so-called run levels and script are executed when a new run level is entered. On Ubuntu, these are stored in
/etc/rc<run level>.d
. Run level 0 is shutdown and run level 6 is reboot. So you want your script to be in/etc/rc0.d
and in/etc/rc6.d
.Create the file
/etc/init.d/unmount-veracrypt-volumes.sh
and make this its content:Then execute these commands:
I chose
K00
so the script is executed as the very first one when one of the run levels is entered. Those scripts are executed in increasing ASCII order, so the smaller the number of the symlink's name, the earlier a script is executed.As of March 2017, a user going by the name of Bob indicates that volumes are not automatically unmounted. It is probably a good idea to take UTF-8's advice and create the run level/init script.
Here is an update, which should be the right answer!
I learned in the veracrypt forums that the option to control dismounting upon shutdown and/or suspend was introduced in version 1.19. There is no need to create the init.d scripts described above.
You can see this for yourself. I use the Ubuntu ppa provided a veracrypt package, in which there is a file called
/etc/default/veracrypt
in which the following setings are included:In case you want to try, here's the ppa file:
and the version as of 2018-12-26,
veracrypt-1.23.0vanirl~18.10
.