Add function for safe removal of external HDDs

Add zsh function that can be used for safely removing external HDDs
since only unmounting them will not make them stop spinning.
This commit is contained in:
2020-07-31 16:41:57 +02:00
parent 158a1c757d
commit e8eaec0798

View File

@@ -321,3 +321,12 @@ function urlenc() {
function urldec() {
python3 -c "from urllib import parse; print(parse.unquote('$@'), end='')"
}
safe-remove() {
[ $# -gt 0 ] || return 1
[ -e "$1" ] || return 1
sync
udiskctl unmount -b "$1" || return 1
udiskctl power-off -b "/dev/$(lsblk -no pkname "$1")"
}