USB Power shutdown method? And Hard drives?

Not helpful when CE is updating and and the HD goes CLUNK when it reboots lol

CE does not reboot automatically after updating if you don’t let it, to give you ample time to remove safely all your USB drives :wink:

Ah yeah thats true, but if i unplug the hdd it still goes clunk lol

I really don’t see why hdds can’t be automatically shut down before Coreelec turns off like win10 does? Oh well, it’s really not that hard to do before quitting-just 1 or 2 more remote button presses.

That would be great improvement, but according Eject(mountpath) would need to be called before shutdown/poweroff.

But there must be some decision making whats removable disc (ie sdX or such).

I think its not too hard implement it only for AML (CE), but in optimal way (not workaround) this should be handled within Kodi itself. bash script is called on shutdown:
It should be easy to write a script to unmount all devices mounted under /media.

For a start:


thats nice and easy option there, thanks. I will add umount commands for installations using USB HDD for /storage (as I think USB flashdrives are just fine).

Not sure if HDD shouldnt be handled also for restarts though…

Can you make such a “” for us that are not at home with Linux ?

Run this two commands in ssh console and check if reboot or powering off unmounts usb disks.

wget -O /storage/.config/
dos2unix /storage/.config/
1 Like

Is ‘umount’ a sufficient command?
Yes it will unmount the filesystem, but is ‘eject’ not required to withdraw power from the device?

… maybe that has changed …

Does Kodi eject really eject the drive or just unmount it? I think it only unmount.

I did, it downloaded and placed in proper place, then I run the second command and turned off N2. When USB power was cut off disk “clanked” as it does when I don’t remove it safely in Kodi Power Menu. So this does not work for my USB disk…

Btw, my USB HD is mounted as /dev/sda1; should that be put in the command instead
/dev/disk/by-id/usb-* ?

Seems Kodi eject is doing something more.

You can try using hdparm like

hdparm -y /dev/sda

Running hdparm -y /dev/sda1
response: issuing standby command

and USB HD drive goes to sleep.

Then use this command after partitions are unmounted in

Where exactly do I put it, like this:

for usb_dev in /dev/disk/by-id/usb-*; do
dev=$(readlink -f $usb_dev)
grep -qw ^$dev /proc/mounts && umount $dev
hdparm -y /dev/sda1

for usb_dev in /dev/disk/by-id/usb-*; do
  dev=$(readlink -f $usb_dev)
  grep -qw ^$dev /proc/mounts && umount $dev
  hdparm -y $dev

Or maybe better

for usb_dev in /dev/disk/by-id/usb-*; do
  dev=$(readlink -f $usb_dev)
  grep -qw ^$dev /proc/mounts && umount $dev
for usb_dev in /dev/disk/by-id/usb-*; do
  dev=$(readlink -f $usb_dev)
  hdparm -y $dev

No change with the first version, will try second version later when wife lets me fiddle with the player again :slight_smile:

EDIT, after some sweet talk I could try the second command also :slight_smile:

But, no change with reboot or power off, the drive still goes “clank”. Checking in System Info after running dos2unix /storage/.config/ command my USB HD is still mounted and all content is accessible.

dos2unix command only changes dos formatted shell script to unix :slight_smile:
If you want to execute manually run

sh /storage/.config/ poweroff

Well, no wander that there is no change :slight_smile:

But also no luck with proper command:
CoreELEC:~ # sh /storage/.config/ poweroff
/dev/disk/by-id/usb-*: No such file or directory

About | FAQ | Terms of Service | Privacy Policy | Legal Notice