Safely remove external hard drives with Nemo

Questions about hardware, drivers and peripherals
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
tim

Safely remove external hard drives with Nemo

Post by tim »

Hi,

I just freshly installed Linux Mint (19.1, Cinnamon) again after a few years of standard Ubuntu and I am very happy with it. There is only one thing I can't figure out. How to safely remove external hard drives with Nemo?

When I have a hard drive plugged in via USB, the right-click menu offers me to mount/unmount only. And unmounting the hard drive doesn't spin it down / power it off.

Thanks a lot,
Tim

PS: While this sounds like a straightforwad problem, I couldn't find results for that.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
RIH
Level 9
Level 9
Posts: 2905
Joined: Sat Aug 22, 2015 3:47 am

Re: Safely remove external hard drives with Nemo

Post by RIH »

Click on the up arrow icon next to the drive..
drives.png
Image
tim

Re: Safely remove external hard drives with Nemo

Post by tim »

RIH wrote: Wed Feb 20, 2019 8:19 am Click on the up arrow icon next to the drive..
drives.png
Unfortunately, that unmounts the drive only. It's still spinning and powered. Is there a way to actually power it down?

Edit: I am currecntly using `udisksctl power-off -b /dev/sdaX` to power the hard drives off, but it would be nice to do that directly via Nemo.
tim

Re: Safely remove external hard drives with Nemo

Post by tim »

I managed to hack together an entry in the right-hand menu. Unfortunately, one has to click in the space where files and folders are shown. I do not know how to add an action to a device.

Adding the two files /usr/share/nemo/actions/power_off_external_drive.nemo_action

Code: Select all

[Nemo Action]
Name=Power off hard drive
Exec=<power_off_external_drive %U>
Selection=none
Extensions=any;
EscapeSpaces=true
#Terminal=true
and /usr/share/nemo/actions/power_off_external_drive

Code: Select all

#!/bin/sh
path=$1
device=$(df $path --output=source | tail -n 1)
label=$(lsblk $device -o LABEL | tail -n 1)
zenity --question --text="Are you sure you want to power off $label ($device)?" && udisksctl unmount -b $device && udisksctl power-off -b $device && notify-send -c "presence.offline" "$label" "$label ($device) has been powered off and can be unplugged."
seems to be okai as a work-around. Still it would be nice if it were working directly out-of-the-box in Nemo or I could add this script to the right-click menu of the devices somehow.

PS: You have to make the second script exectuable for all.
Locked

Return to “Hardware Support”