I have an old MacBook laying around, and I wonder if it's possible to use it safely when the lid is closed? I want to run it as a network device, store files in my home network on it etc.

Is there a way to use it just plugged in to power and ethernet, close the lid and let it run as a server?

有帮助吗?

解决方案

To use a MacBook as a server with the lid closed, all you need to do is to ensure that it's powered on and not in sleep state.

Closing the lid of a MacBook by default puts it into sleep mode irrespective of whether it is plugged into power or running on battery.

One common way to keep the MacBook powered on with the lid closed is to connect an external display (and keeping it plugged-in to power, to make sure that it doesn't run out of power) to your MacBook.

If that is not feasible, or is not an option that you are looking for, you can refer to the solution in the linked discussion:

You can accomplish this in terminal. No additional software needed.

Display global power settings:
pmset -g

System-wide power settings:
Currently in use:
 lidwake              1
 autopoweroff         1
 standbydelayhigh     86400
 autopoweroffdelay    28800
 proximitywake        1
 standby              1
 standbydelaylow      10800
 ttyskeepawake        1
 hibernatemode        3
 powernap             1
 gpuswitch            2
 hibernatefile        /var/vm/sleepimage
 highstandbythreshold 50
 womp                 0
 displaysleep         10
 networkoversleep     0
 sleep                1 (sleep prevented by sharingd)
 tcpkeepalive         1
 halfdim              1
 acwake               0
 disksleep            10



To stop sleep entirely:
sudo pmset -a disablesleep 1

To revert, allowing sleep again:
sudo pmset -a disablesleep 0

其他提示

The macbook is designed to dissipate a substantial portion of its heat through the keyboard. If you run it closed for a long period of time, it will have reduced performance (as it can't dissipate heat as effectively). Additionally, the added heat could reduce the lifespan of the screen.

None of these effects should be too large, and it will work fine closed, but if you can leave the lid open it will be better for the computer's performance and longevity.

Closing the lid on a MacBook while it is running is common, people do that all the time with a keyboard, mouse, and display attached. Without a display attached it will go to sleep. A headless monitor adapter is one way to rectify that. Here's an HDMI example:

https://eshop.macsales.com/item/NewerTech/ADP4KHEAD/

This is apparently a popular item as I've seen what appears to be the same product sold under different brands by different shops. A common use is to allow VNC/RDP/telework software without need for a monitor, which is not far from what you want. You'll be able to use the macOS screen sharing service to control it over a network for configuration and monitoring.

These HDMI headless adapters are common, if you don't have a HDMI port on your laptop then you will need an adapter or have to seek out a DVI, mini-DP, or whatever version. I did some looking and I haven't found one yet.

Use Amphetamine

No need to get another monitor, or to buy an HDMI connector or to execute some terminal command. You just need to download this free and open source utility called Amphetamine.

When you run it, it will appear in your menu bar, you can go ahead and click on the logo. And from now, two clicks are enough to finish this :

Click the "Indefinitely" button. Click "Indefinitely"

Uncheck the middle option saying "Allow system sleep when display is closed" Uncheck the middle option saying "Allow system sleep when display is closed"

And there you go, if you now close your lid, your Mac won't go to sleep. Additionally, if you want to save power and preserve your Mac, you can set the luminosity to the minimum amount (which should make a black screen).

Try to use the Jiggler

It prevents sleep by jiggling the mouse a pixel at a time after the idle threshold is reached. This bypasses any power configuration set in Mac OS.

I've tested it with a Macbook Pro using the lid closed, with only power and ethernet attached.

PS: This tool is also helpful if you access a remote application (e.g. remote desktop) that times out. You can simply leave the mouse over the application window and let it jiggle and keep the session alive.

I do exactly this with my old MacBook Air and have done for some time. The only difference from the above posts is that instead of using macOS I wiped it clean and installed Ubuntu Server (it's still possible to reinstall macOS should I ever want to).

There are a few things you need to consider. One is that the wi-fi almost certainly won't work out of the box on Linux as it's Broadcom and depends on a proprietary driver that has to be manually installed. In my case I use a wired USB ethernet adapter which is a better fit for a server use case anyway.

To fix the lid closing issue on Ubuntu you have to edit the file /etc/systemd/logind.conf and uncomment the line #HandleLidSwitch=ignore (remove the # symbol at the start).

The other problem you'll encounter is the screen being on, which on older models means the Apple logo staying permanently lit. I would imagine this isn't good for it. On my machine I fixed this by adding a line to my crontab that automatically turns it off when the laptop boots:

Do sudo crontab -e then insert something like the line below:

@reboot echo 0 > /sys/class/backlight/intel_backlight/brightness

This may be specific to my MacBook Air but the setting looks like it probably applies to most or all Intel-based MacBooks.

Finally, I recommend controlling the machine via SSH, there is plenty about this if you are not familiar. The OpenSSH server should be enabled by default when you install Ubuntu Server iirc.

许可以下: CC-BY-SA归因
不隶属于 apple.stackexchange
scroll top