Use the following to lock and unlock disk: DEVICE will be disk dev node like /dev/sda etc. DEV_PASSWORD is user define, e.g. DEV_PASSWORD=PaSsWoRd Be careful with above operations as if done incorrectly or incompletely device may be difficult to recover. For leaving the device in locked state, you just need to do: echo "Setting temporary password on $DEVICE ..." hdparm --user-master u --security-set-pass $DEV_PASSWORD $DEVICE For unlocking the device: DEV_EN=$(hdparm -I $DEVICE | grep enabled | cut -c 2-4) if [ "$DEV_EN" != "not" ]; then hdparm --user-master u --security-disable $DEV_PASSWORD $DEVICE fi