The reason need to sleep samba before sleeping on Sonoma because the default behavior of Sonoma 14.4 or after would NOT sleep if you have samba share file sharing enabled. I was trying to stop the smbd service when the Mac sleep with something like this
The reason you need to disable SMB before sleeping because the default behavior of MacOS Sonoma File sharing samba share will keep your Mac from sleeping as detect by Sleep Aid Your computer will NOT sleep if you enable samba share on Sonoma, I don't know why but I use an external meter to track the power consumption, it never sleep if you have File sharing Samba enabled on Sonoma and you have a Windows PC to mount the network share as a drive on Windows.
The power consumption on Mac Studio M1 should use about 9-10w when sleeping (external metered power adapter measure). Anything higher than this indicate your Mac is not sleeping.
Fair point. But my Mac is a desktop, not a laptop, so I don't think this software is particularly useful for me.
The website says "Apple Verified. No malicious software." But the link takes me to a generic Apple site which isn't very comforting. I'm guessing that what they really mean is that they are a developer that has been identified by Apple as being a trusted developer, which is probably verifiable during the installation of the software, but I'm not going to install it. However I did do five minutes of research into the developers of that software and I don't detect anything fishy about them.
Nothing is turned on, I basically turn off any thing that will wake up the mac besides powernap. I use an external metered adapter something like this to check the actual power usage in real time. The power adapter measure how much power drawn by the Mac in real time.
I have a PC mount the samba share of the Mac at all time. If I have access the samba share once on the PC, even if you sleep the Mac it will keep using 20w power and I can still ping the Mac. That means it's not sleeping.
When I kill the smbd before putting the Mac to sleep, the power consumption drop to about 9-10w and I can't ping the Mac.
Just to confirm your sudo launhctl command works on Sonoma.
That's the actual problem -- it's not that your Mac won't sleep because Sharing is turned on, but because a client is connected.
It would be better to have the client disconnect first so that your Mac sleeps "normally". If you can't do that then yes, turning off smbd will "solve" the problem -- but beware of data loss since you are force-disconnecting the client...
Yea, I mounted the samba share on "Y:" Drive on Windows. When I sleep the Mac, I will not access the drive anyway so it should be ok.
Just FYI, MacPort version of samba will sleep the smbd correctly on Sonoma. It's something do with the version of smbd comes with Sonoma. I haven't tried Homebrew version yet so I don't know if that works.