Unplugging external drive doesn't trigger a shutdown

Take a look at luksSuspend

I would execute a luksSuspend followed by shutdown. If you want a faster shutdown, try echo o > /proc/sysrq-trigger &. See how we do this at the end of the BusKill self-destruct script:

#################################
# WIPE DECRYPTION KEYS FROM RAM #
#################################

# suspend each currently-decrypted LUKS volume
${ECHO} "INFO: removing decryption keys from memory"
for device in $( ${LS} -1 "/dev/mapper" ); do

	${ECHO} -e "\t${device}";
	${CRYPTSETUP} luksSuspend "${device}" &

	# clear page caches in memory (again)
	sync; echo 3 > /proc/sys/vm/drop_caches

done

#############################
# (IMMEDIATE) HARD SHUTDOWN #
#############################

# do whatever works; this is important.
echo o > /proc/sysrq-trigger &
sleep 1
shutdown -h now &
sleep 1
poweroff --force --no-sync &
1 Like