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:
@@ -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")"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user