USB Power shutdown method? And Hard drives?

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/shutdown.sh 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/shutdown.sh poweroff

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

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

This indicates that there is no USB disk attached.

Will try to find some external USB disk to try it myself.

Strange, because just before running the command, and after it I watched my TV series from that disk :slight_smile:

It had previously been ejected?

there are two installations with two USB discs. Cant test “clank” as they are remote, not in my flat, but I guess Sholander has maybe disc with no usb prefix?

One would be WD obviously, second one is Transcend:

FIRST INSTALLATION

/dev/disk/by-id$ ls -la
total 0
drwxr-xr-x    2 root     root           160 Jun 22  2018 .
drwxr-xr-x    7 root     root           140 Jun 22  2018 ..
lrwxrwxrwx    1 root     root            13 Jun 22  2018 mmc-SD16G_0x3f680909 -> ../../mmcblk0
lrwxrwxrwx    1 root     root            15 Jun 22  2018 mmc-SD16G_0x3f680909-part1 -> ../../mmcblk0p1
lrwxrwxrwx    1 root     root            15 Jun 22  2018 mmc-SD16G_0x3f680909-part2 -> ../../mmcblk0p2
lrwxrwxrwx    1 root     root             9 Jun 22  2018 usb-WD_Elements_25A2_575841314141374632375032-0:0 -> ../../sda
lrwxrwxrwx    1 root     root            10 Jun 22  2018 usb-WD_Elements_25A2_575841314141374632375032-0:0-part1 -> ../../sda1
lrwxrwxrwx    1 root     root            10 Jun 22  2018 usb-WD_Elements_25A2_575841314141374632375032-0:0-part2 -> ../../sda2

/dev/disk/by-id$ mount
rootfs on / type rootfs (rw,size=823556k,nr_inodes=205889)
devtmpfs on /dev type devtmpfs (rw,relatime,size=823556k,nr_inodes=205889,mode=755)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
/dev/mmcblk0p1 on /flash type vfat (ro,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
/dev/sda1 on /storage type ext4 (rw,noatime,data=ordered)

SECOND INSTALLATION

/dev/disk/by-id # ls -la
total 0
drwxr-xr-x    2 root     root           180 Jun 22  2018 .
drwxr-xr-x    7 root     root           140 Jun 22  2018 ..
lrwxrwxrwx    1 root     root             9 Jun 22  2018 ata-WDC_WD10SPZX-22Z10T0_WD-WXT1A77L239C -> ../../sda
lrwxrwxrwx    1 root     root            10 Jun 22  2018 ata-WDC_WD10SPZX-22Z10T0_WD-WXT1A77L239C-part1 -> ../../sda1
lrwxrwxrwx    1 root     root            13 Jun 22  2018 mmc-SB16G_0xd3e81aad -> ../../mmcblk0
lrwxrwxrwx    1 root     root            15 Jun 22  2018 mmc-SB16G_0xd3e81aad-part1 -> ../../mmcblk0p1
lrwxrwxrwx    1 root     root            15 Jun 22  2018 mmc-SB16G_0xd3e81aad-part2 -> ../../mmcblk0p2
lrwxrwxrwx    1 root     root             9 Jun 22  2018 wwn-0x50014ee607e0266c -> ../../sda
lrwxrwxrwx    1 root     root            10 Jun 22  2018 wwn-0x50014ee607e0266c-part1 -> ../../sda1
/dev/disk/by-id # mount
rootfs on / type rootfs (rw,size=823556k,nr_inodes=205889)
devtmpfs on /dev type devtmpfs (rw,relatime,size=823556k,nr_inodes=205889,mode=755)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
/dev/mmcblk0p1 on /flash type vfat (ro,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
/dev/sda1 on /storage type ext4 (rw,noatime,data=ordered)

You are right, my disk is in /dev/disk/by-id/ata-WDC_xxxxxxxxx like the one in your second installation.

I updated my script on pastebin. It looks for usb and ata devices.

EDIT: Found another USB disk and it got ejected with hdparm. So script should work now.

Yes, now it works, big thnx :smile:
The script removes all my USB drives (HDs and sticks) and runs before power is turned off.

One thing though, wouldn’t it be simpler to put commands only under the last entry *) ?
As I understand, then it will cover all above instances halt) , poweroff) and reboot)

1 Like

Should this be done on reboot too? Try using it under * and report back.
I though reboot actions should not be needed but maybe I’m wrong.

EDIT: I update my script again and put all the actions under * and actions are executed always when script is called.

During reboot the drive also goes “clank” so will try tonight only on * with all rest removed to see if it works for all actions - halt, poweroff and reboot.

Wish i never started this im now lost :rofl:

Works perfect with Reboot and Power_Off; unmouts all drives before the power is cut off.

1 Like

Is the latest version still unde this link?
https://pastebin.com/raw/ypmbcrEu

Yes, I edited script on same address.

1 Like

Nice & Thanks.
Maybe good idea to pin this, or commit to CE

I think that several issues here are caused by corrupted data/fs.

Is the emmc also ejected before powerdown by CE/BL? This is a managed NAND, which may also have background maintenance running, which does not like brownout.
EDIT: both linux Kernel drivers support Power off notification, just checked. Hopefully the host notifies the mmc driver…

1 Like

Is it safe to use it, when you have /storage partition on USB? Not sure about shutdown actions after halt service…

no, it’s not a good idea.

Working perfectly for me:) Thank You!