helloSystem / ISO

helloSystem Live and installation ISO
https://github.com/helloSystem/
BSD 3-Clause "New" or "Revised" License
807 stars 58 forks source link

Prevent system from sleeping while storage is attached via USB #72

Open grahamperrin opened 3 years ago

grahamperrin commented 3 years ago

A generic title for this issue. For starters:

Suspend/resume versus storage on USB

https://lists.freebsd.org/pipermail/freebsd-current/2020-September/077010.html

… It looks like a problem with USB resume, that no devices are recognized, until you re-plug them …

https://lists.freebsd.org/pipermail/freebsd-current/2020-November/077681.html

… If I export the pool before suspend, no problem at resume time. …

Please

Is there any way to avoid the need to export before suspending the computer?

Might there be a future improvement to support for USB?

Thanks

Degrees of adversity

Where the mounted file system is (for example) FAT 32 or NTFS: adversity may be negligible.

With OpenZFS on FreeBSD: if there's a single-device pool (i.e. USB flash/thumb drive or mobile HDD/SSHD/SSD) then there's near-certainty that the pool will require at least a scrub, which might be frustratingly time-consuming (and I should not recommend writing to its file system(s) during the scrub). https://www.freebsd.org/cgi/man.cgi?query=zpool&sektion=8

… and so on. Not intended to be comprehensive.

probonopd commented 3 years ago

Is this something automount could help with @vermaden? What is your take on this?

vermaden commented 3 years ago

The automount keeps all mounted filesystems in the /var/run/automount.state file so one can add a loop into /etc/rc.suspend or /etc/rc.resume to execute /usr/local/sbin/automount ${cdev} detach command for each mounted by automount device.

grahamperrin commented 3 years ago

Thanks, might that detach a ZFS pool's device before the pool is cleanly exported?

vermaden commented 3 years ago

Thanks, might that detach a ZFS pool's device before the pool is cleanly exported?

If the mounted FS is ZFS then yes but automount do not support ZFS currently.

grahamperrin commented 3 years ago

OK, I should probably refine the subject line of this issue. We need:

– and:

probonopd commented 3 years ago

I cannot imagine we should solve this within helloSystem but should discuss this with FreeBSD upstream.

vermaden commented 3 years ago

IMHO You should submit new FreeBSD bug for that occasion :)

Here: https://freebsd.org/send-pr.html

grahamperrin commented 3 years ago

"Might there be a future improvement to support for USB?" – tumble-weed in the weeks since I asked.

From the silence, I assumed that there's zero interest :-(

probonopd commented 3 years ago

Needs to be clarified whether having FreeBSD installed to a USB disk formatted with ZFS means that we should not put the computer to sleep. This would be a bummer.

cc @crees

grahamperrin commented 2 years ago

With recent changes to sysutils/lsof, it should be easier to tell which files are open at a mount point that uses ZFS.

If the end user can be informed, then there can be a decision. Whether to:

  1. close files; or
  2. defer sleep until those files can be closed.