You are not logged in.
Hi folks.
I have noticed a bad thing™ using DeviceNotifier today. I wanted to remove a hard disk which was mounted, but spun down due to inactivity. After clicking the eject button in DeviceNotifier, the message "It is now safe to remove the device" appeared almost immediately. I went ahead to pull the plug, noticing that the drive's led started to blink again just before I actually unplugged the drive. The interval from clicking the unmount button to the blinking of the led was consistent with the typical spin-up time of the device. Checking `dmesg` revealed that the kernel was actually still in the process of reading from the device and, as far as i know, may still had planned to write something, too.
[344340.518911] usb 4-1: USB disconnect, device number 6
[347081.539229] usb 3-3: USB disconnect, device number 8
[347081.542777] scsi 9:0:0:0: rejecting I/O to offline device
[347081.542785] scsi 9:0:0:0: [sdd] killing request
[347081.542798] scsi 9:0:0:0: [sdd] FAILED Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
[347081.542802] scsi 9:0:0:0: [sdd] CDB: Read(10) 28 00 00 00 18 00 00 00 08 00
[347081.542804] print_req_error: I/O error, dev sdd, sector 6144
[347081.542858] Buffer I/O error on dev sdd1, logical block 512, async page read
So apart from the known "bug" that plasma does not spin down drives before removal (https://bugs.kde.org/show_bug.cgi?id=270808), it does not even wait for the kernel to finish everything it wants to do with the device. This is alarming!
Any chance this is just a configuration issue? Anyone here who has some idea where to look next?
Last edited by Sunday87 (2018-06-08 13:44:58)
Offline
Sorry for answering to this very old thread of mine, but since nothing happened on this issue, I would like to share my workaround. The thread can then be closed if no one else has something to add.
My work-around consists of adding a new action to the DeviceNotifier, that will run a bash script that will unmount and power down the device. It is not testing all edge cases, but it will work in most cases. Just add the following two files. After a restart of kded5 removable devices should have a new action "Unmount & Power-Off USB device". Make sure you have the package `util-linux` installed, and note that the script requires udisks2.
~/.local/bin/power-device-off (make sure to chmod +x this)
#!/bin/bash
PART=$( findmnt -n -o SOURCE --target $1 )
DEV=$( lsblk -no pkname $PART )
if udisksctl unmount -b $PART; then
if udisksctl power-off -b /dev/$DEV; then
notify-send "Device /dev/$DEV powered off and can be removed safely."
else
notify-send "Unmounted $PART, but could not power /dev/$DEV down."
fi
else
notify-send "Could not unmount $PART."
fi
~/.local/share/solid/actions/power-devices-off.desktop
[Desktop Entry]
X-KDE-Solid-Predicate=[ [ [ StorageVolume.ignored == false AND StorageVolume.usage == 'FileSystem' ] OR [ IS StorageAccess AND StorageDrive.driveType == 'Floppy' ] ] OR StorageAccess.ignored == false ]
Type=Service
Actions=open;
[Desktop Action open]
Name=Unmount and Power-Off USB device
Exec=power-device-off "%f"
Icon=emblem-unmounted
EDIT: I went back to the bug report that I linked to in my original post, just to find out that someone posted a similar but simpler thing there. However, I still like the separate script in order to be able to show notifications. But some things can be simplified:
~/.local/bin/power-device-off (make sure to chmod +x this)
#!/bin/bash
if udisksctl unmount -b $1; then
if udisksctl power-off -b $1; then
notify-send "Device $1 powered off and can be removed safely."
else
notify-send "Unmounted $1, but could not power down."
fi
else
notify-send "Could not unmount $1."
fi
~/.local/share/solid/actions/power-devices-off.desktop
[Desktop Entry]
X-KDE-Solid-Predicate=[ [ [ StorageVolume.ignored == false AND StorageVolume.usage == 'FileSystem' ] OR [ IS StorageAccess AND StorageDrive.driveType == 'Floppy' ] ] OR StorageAccess.ignored == false ]
Type=Service
Actions=open;
[Desktop Action open]
Name=Unmount and Power-Off USB device
Exec=power-device-off "%d"
Icon=emblem-unmounted
Last edited by Sunday87 (2018-09-17 15:56:38)
Offline