How to find Raspberry Pi memory amount (complete guide)


When working with small computers it can be important to monitor the amount of memory and storage space that is available to the programs running on the device. Small and embedded computers often have memory and storage constraints compared to mainstream computers and the software that runs on them. As part of my series on unleashing the power of small computers, I put together this guide on how to find out the amount of memory that a Raspberry Pi has (whether that’s RAM or SD card storage space).

To find the amount of memory that is available on a Raspberry Pi, open up a terminal and type in cat/proc/meminfo | less. This command will display the amount of memory that the Raspberry has in total, and has available for use. To find out the amount of space on the SD card, the command df -h can be used.

Output of the cat /proc/meminfo | less command when run on my Raspberry Pi

Another way to find out the amount of memory is to figure out which model you have and then find out the total amount of memory from the Raspberry Pi spec sheet. To find out which model you have, check out the guide I wrote here: chipwired.com/identify-raspberry-pi-board

In this guide on Raspberry Pi memory I’ve looked at:

  • How to find the amount of random access memory (RAM)
  • How to find the amount of memory on the SD card
  • Some ways to add more memory to your Raspberry Pi

How to find the amount of RAM

The special system file meminfo contains details of the Raspberry Pi memory, including how much is available and how much is currently being used. By accessing this information from the terminal, we can find out how much memory a Raspberry Pi has.

To access information about the amount of memory that the Raspberry Pi is using as RAM, open up the terminal and type the command:

cat /proc/meminfo | less

The number next to MemTotal is the amount of memory (as RAM) that your Raspberry Pi has access to. This number, in kilobytes, is slightly less than the advertised amount due to decimal-binary conversion and the kernel reserving some for itself (see Slab amount).

I ran this command on a Raspberry Pi 4 with 4GB of memory. As you can see, it contained roughly 3.8 million kilobytes of memory.

You can scroll through meminfo to see other details about the Raspberry Pi’s RAM use by using the up and down arrow on the keyboard. Other info to look out for in this command includes:

  • Slab – memory used by the kernel for itself
  • MemFree – memory not used for anything
  • MemAvailable– memory that can be allocated to a program (e.g. if you write some code, this is the physical memory that is available to you)

If you’re interested in more detail about kernel memory, check out the rabbit-hole of kernel memory allocation that starts here. For more detail about meminfo, check out the guide here.

An alternative command that can be used for displaying the amount of memory on your Raspberry Pi is free. To use this command, open a terminal and type the following:

free -h

The -h instructs the command to print the output in a “more human” readable format (i.e. rounding to MB and GB instead of millions of bytes).

How to find amount of SD card memory

The easiest way to find the amount of memory (storage) on your Raspberry Pi SD card is by using the fdisk command. This command is intended to be used to help you partition your storage so that it can support various file systems or operating systems. It has an option to report to you the size of storage available on your SD card as well.

To access information about the size of your SD card, open up a Raspberry Pi Terminal and type the following command:

fdisk -l

This command lists out all the partitions on your SD card, including the size of each partition. By default, there should be 2 partitions on your SD card – 256MB for the boot files, and the remainder of the SD card that can be used by the Pi.

Storage partitions on my Raspberry Pi listed using fdisk

In my photo above, I have 59.2GB available for Raspberry Pi OS and to store files on my Raspberry Pi.

By separating the storage into partitions like this, a Windows computer is able to change boot files (such as HDMI and WiFi settings), while the Raspberry Pi OS can use the Linux file systems for storage and running the Pi.

The amount of storage is less than the SD card total. This is due to the conversion between decimal and binary bytes, as well as overhead in formatting and partitioning the storage space. In my example above, I’m using a 64GB SD card for Raspberry Pi OS.

To find out how much is used, we can use the df command. The df command is designed to tell us how much disk space is being used by files (including the operating system).

To use the df command to find out how much space is free on the Raspberry Pi SD card, open a Terminal and type the following command:

df -h

This runs df with the -h flag making the numbers more readable to humans (rounding to the nearest gigabyte or megabyte depending on what makes the most sense.

Free space available on my Raspberry Pi

How to add more memory to the Raspberry Pi

More RAM can be added to the Raspberry Pi by allocating a portion of the SD card to act as swap space. The swap space is used by the Raspberry Pi if the physical RAM is filled up. To find out more about swap space, check out the detailed explanation here; the process of adding swap is complicated, but if you’re interested check out the guide here.

If more SD card space is required, there are two options: Adding an additional SD card via the USB or GPIO interfaces with the respective reader, or by migrating Raspberry Pi OS to a bigger SD card. Check out the guide here if you’re interested in how to migrate Raspberry Pi OS to a bigger SD card.

If you’re looking to add storage for data collected by the Raspberry Pi, there are a few more options such as cloud storage, network storage, or even on-board flash memory. Check out my guide here for more info: chipwired.com/raspberry-pi-store-data.

Chris

Engineer and electronics enthusiast. Enjoys solving problems with electronics and programming.

Recent Posts