Free up a lot of memory on the Raspberry Pi Zero by disabling the desktop

Did you install the full version of Raspian on your Raspberry Pi only to realize that you are going to run it as a headless appliance with no HDMI attached to it?  It turns out you can disable that desktop which will free up enough memory to leave almost 5x available to programs.   

Disable the Desktop using raspi-config

1. Verify the free memory available after a restart with `free -m`
2. Launch the shell-based configuration tool to disable  the desktop with `sudo raspi-config`
3. Move through the screens shown below.
3. Reboot
4. Verify the free memory after a restart with `free -m`


Enabling and disabling the desktop involves changing the System Options

We're going to change the boot/Auto Login 

Select one of the console options.  You can always restore desktop access later by picking one of the Desktop options

The desktop should be disabled upon the end of the next restart.

Before and After disabling the Desktop

Disabling the desktop frees up almost 1/2 the RAM On a Raspberry Pi Zero

Raspberry Pi Zero running the desktop

total used free shared buff/cache available
Mem: 429 172 61 4 196 202
Swap: 99 6 93    

Raspberry Pi Zero with the desktop disabled.

total used free shared buff/cache available
Mem: 429 49 265 1 113 329
Swap: 99 0 99    

YouTube video of this article

Revision History

Created 2022 11


Popular posts from this blog

Understanding your WSL2 RAM and swap - Changing the default 50%-25%

Installing the RNDIS driver on Windows 11 to use USB Raspberry Pi as network attached

DNS for Azure Point to Site (P2S) VPN - getting the internal IPs