0

I would like to use an old raspberry zero 1.3 to share files in my home network, but I wish I could shut down the connected hard drives as the system shuts down.

Initially I thought that it was enough to associate the status of the ACT led to a GPIO pin ( https://forums.raspberrypi.com/viewtopic.php?t=146455#p964587 ), but in case of errors the led will start flashing, then the disks connected could be damaged.

So, using a mosfet, how can I turn off a usb hub if the system is not booted?

Pinguto
  • 103
  • 2

2 Answers2

1

This is the tasks you need to perform:

  1. you need to unmount the drive
  2. then power off the USB hard drive
  3. shut down the Raspberry Pi OS.

Other ways to achive the funtion you describe will involve a separate MCU and electronics.

MatsK
  • 2,791
  • 3
  • 16
  • 20
  • the unmount of the disks I don't think it is a problem as it is done during the system shutdown, right? So I just need a GPIO pin with which to control the power supply to a usb hub connected to the rasberry. – Pinguto Aug 06 '22 at 21:58
  • Have a look at the order ! – MatsK Aug 06 '22 at 22:01
  • that is to say? I'm not understanding.. – Pinguto Aug 06 '22 at 22:04
  • You cant controll a GPIO after the OS has shut down ! And to power of a mounted drive is going to cause corruption. So you need to perform the tasks in the ORDER i described. – MatsK Aug 06 '22 at 22:06
  • I understand! I have yet to try this, but after searching, it seems that the TX pin or the GPIO26 can be used to detect if the OS is running or not ( https://forums.raspberrypi.com/viewtopic.php?t=288723#p1745621 ). – Pinguto Aug 06 '22 at 22:31
1

If you want to shutdown a Pi (regardless of whether it uses SD Card or HD) you should run poweroff which enables a controlled shutdown, flushing buffers etc.
If you do not do this you risk corruption of the FS.

This can be initiated by a GPIO pin using gpio-shutdown.
Run run dtoverlay -h gpio-shutdown for description.

There is NO reliable way of detecting if the Pi is running although there are visual indicators. Any of the various "solutions" for this are unreliable!

See What happens to the GPIO voltage after shutdown?

There is a gpio-poweroff which is intended to control power circuitry BUT you MUST provide circuitry to remove power if you use this.

Milliways
  • 59,890
  • 31
  • 101
  • 209