Extend Partition on SD Card or eMMC
The default capacity of the official Debian image root file system is about 4GB
. When installing software or other data increases, there will be insufficient space. We can expand the file system to the full capacity of the SD card or eMMC.
Whether Mar CM is a version with eMMC or a Lite version without eMMC that uses an SD card as the storage medium, the device recognized in the system is /dev/mmcblk0
The following uses a Mars CM booted from a 32G SD card as an example to introduce how to expand the capacity through commands. The expansion method for the eMMC version is also the same.
Check the current status of the partitions
Use the df -h
command to view the current partition status
# df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.4G 0 1.4G 0% /dev
tmpfs 388M 3.4M 385M 1% /run
/dev/mmcblk0p4 3.7G 3.1G 594M 85% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 5.0M 8.0K 5.0M 1% /run/lock
tmpfs 388M 92K 388M 1% /run/user/1000
tmpfs 388M 24K 388M 1% /run/user/0
You can see that the device mounted in the current root partition /
directory is /dev/mmcblk0p4
Extend a partition using the fdisk command
Entering the fdisk
command will take you into the command-line interactive mode of fdisk
# fdisk /dev/mmcblk0
Enter the p
command to view the current partition information. You can see that the current capacity of the system partition /dev/mmcblk0p4
is 3.8G
Command (m for help): p
Disk /dev/mmcblk0: 29.12 GiB, 31267487744 bytes, 61069312 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 6ED69CD1-D57A-4373-B24B-924EE58DFAA1
Device Start End Sectors Size Type
/dev/mmcblk0p1 4096 8191 4096 2M HiFive BBL
/dev/mmcblk0p2 8192 16383 8192 4M HiFive FSBL
/dev/mmcblk0p3 16384 221183 204800 100M EFI System
/dev/mmcblk0p4 221184 8189918 7968735 3.8G Linux filesystem