Raspberrypi Memory partition in dunfell

Created on November 9, 2021

For a raspberrypi image, mainly there are two partitions, kernel and rootfs.  The size of kernel size is ~48M.  Rootfs is mounted on  SD card and its value can be increased using gparted,fdisk or similar tool.  By default while flashing an  image to SD card, two partitions are created, namely mmcblk0p1 and mmcblk0p2. rootfs image is stored in mmcblk0p2 whereas mmcblk0p1 holds boot information.

The details of sd card partions and its sizes can be found using “fdsik -l command”

root@raspberrypi-rdk-hybrid:~# fdisk -l
Disk /dev/mmcblk0: 14 GB, 15552479232 bytes, 30375936 sectors
474624 cylinders, 4 heads, 16 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device                          Boot StartCHS    EndCHS        StartLBA     EndLBA        Sectors      Size           Id Type
/dev/mmcblk0p1 *       64,0,1                   841,0,32          8192          107679          99488          48.5M    c Win95 FAT32 (LBA)
/dev/mmcblk0p2          896,0,1               1023,3,32       114688       10711039     10596352    5174M    83 Linux

For changing sd card partition using gparted refer below link.

         Partioning and Resizing using GParted GUI

Memory Usage 

      The memory in raspberrypi is partitioned into different sessions and the details of these partitions and allocated size for these partitions  can be found out using df command.  df -h command gives size allocated to each of these partitions and the size that is already used by different components.

root@raspberrypi-rdk-hybrid:~# df -h
Filesystem                   Size          Used        Available   Use%      Mounted on
/dev/root                    865.5M    552.0M     252.0M        69%        /
devtmpfs                   339.6M         0            339.6M        0%           /dev
tmpfs                          468.1M      8.0K        468.1M         0%          /dev/shm
tmpfs                         194.3M      8.8M        185.6M         5%         /run
tmpfs                          468.1M         0            468.1M        0%         /sys/fs/cgroup
tmpfs                          468.1M      6.6M        461.5M       1%          /tmp
tmpfs                          468.1M      6.6M        461.5M       1%          /etc/snmp/snmpd.conf
tmpfs                          468.1M      236.0K    467.9M        0%        /var/volatile
/dev/root                   865.5M      552.0M    252.0M       69%      /var/lib
/dev/mmcblk0p1      48.5M        27.4M     21.0M          57%      /boot
tmpfs                            93.6M         0            93.6M          0%        /run/user/0

 The total   amount of RAM memory used and the available memory can be found using free command.  free -lh command gives the details of the amount of memory used out of the total memory and the available memory that can be used for functions like audio/video playback. 

root@raspberrypi-rdk-hybrid:~#  free -lh
                        total         used        free          shared    buff/cache   available
Mem:           936M        571M        217M         26M           147M        311M
Low:           936M          718M        217M
High:            0B               0B          0B
Swap:            0B              0B          0B

Boot memory Information

   The memory allocated for each component at the time of boot up is given below.

Kernel code9216K
RW data737K
RO data2928K
cma  total262K
KernelStack2536 kB
Shmem14596 kB

Graphics memory 

   Graphics memory, commonly called GPU memory is the amount of memory available on graphics card and is used by graphics processor. We can use vcgencmd for getting gpu memory information.

Please refer below link for GPU memory details.

   GPU Memory Consumption Analysis

root@raspberrypi-rdk-hybrid:~# vcgencmd get_mem gpu

Changing tmpfs partition size

   Size of tmpfs partition can be changed by using fstab. Below are the list of tmpfs partitions. 

tmpfs                   468.1M      4.0K     468.1M   0%   /dev/shm
tmpfs                   194.3M      8.8M     185.5M   5%   /run
tmpfs                   468.1M         0         468.1M   0%   /sys/fs/cgroup
tmpfs                   468.1M      2.2M     466.0M   0%    /tmp
tmpfs                   468.1M      2.2M      466.0M   0%   /etc/snmp/snmpd.conf
tmpfs                   468.1M    320.0K    467.8M   0%    /var/volatile

The size of these partitions can be changed by mentioning size in /etc/fstab.  For example, we reduce size of /run to ~100M by mentioning size as below.  Reboot the device after fstab is modified.

root@raspberrypi-rdk-hybrid:~# vi /etc/fstab
# stock fstab – you probably want to override this with a machine specific one

/dev/root            /                            auto       defaults              1  0
proc                     /proc                   proc         defaults              0  0
devpts               /dev/pts             devpts     mode=0620,ptmxmode=0666,gid=5      0  0
tmpfs                /run                       tmpfs      mode=0755,nodev,nosuid,strictatime,size=103741824 0  0
tmpfs                /var/volatile        tmpfs      defaults              0  0

# uncomment this if your device has a SD/MMC/Transflash slot
#/dev/mmcblk0p1       /media/card          auto       defaults,sync,noauto  0  0

/dev/mmcblk0p1    /boot    vfat    defaults    0    0

The changed size can be verified using df command.  The above change results in

root@raspberrypi-rdk-hybrid:~# df -h
Filesystem                            Size      Used          Available Use%   Mounted on
/dev/root                           865.5M    557.0M    247.0M       69%     /
devtmpfs                           339.6M         0          339.6M       0%       /dev
tmpfs                                  468.1M      8.0K      468.1M       0%      /dev/shm
tmpfs                                 98.9M      8.8M        90.2M         9%       /run
tmpfs                                468.1M         0          468.1M       0%      /sys/fs/cgroup
tmpfs                                468.1M      6.6M      461.5M      1%     /tmp
tmpfs                                468.1M      6.6M      461.5M      1%      /etc/snmp/snmpd.conf
tmpfs                                468.1M    428.0K    467.7M      0%      /var/volatile
/dev/root                        865.5M    557.0M    247.0M      69%   /var/lib
/dev/mmcblk0p1           48.5M     27.4M       21.0M       57%   /boot
tmpfs                               93.6M         0            93.6M         0%   /run/user/0

Leave a Reply

Your email address will not be published.

Go To Top