Personal tools

Extending rootfs partition

From SomLabs Wiki

Jump to: navigation, search

Extending rootfs partition


The default system image has the file system with the minimal size. It can be resized after booting the system on the VisionSOM modules with SD-card or eMMC storage memories.

NOTE! please take a closer look at the partition names on your system since they may differ from the ones in this example!


Boot the system and login as root. Print the storage information using the fdisk tool:

root@visionsom-8mm-cb-std:~# fdisk -l /dev/mmcblk2
Disk /dev/mmcblk2: 14.45 GiB, 15502147584 bytes, 30277632 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: dos
Disk identifier: 0x879591b6

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk2p1 *     16384  186775  170392 83.2M  c W95 FAT32 (LBA)
/dev/mmcblk2p2      196608 4273325 4076718    2G 83 Linux

The /dev/mmcblk2 is the storage device, while the /dev/mmcblk2p1 and /dev/mmcblk2p2 represent the partitions (boot and rootfs). In this case the system partition has only 2GB, leaving about 12.5GB free on the device.

Open the fdisk interactive terminal:

root@visionsom-8mm-cb-std:~# fdisk /dev/mmcblk2

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help):

Delete the existing /dev/mmcblk2p2 system partition with the d command:

Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Create a new primary partition number 2. The first sector number should be exactly the same as in the original partition which was 196608 in this example (take a close look on previous fdisk logs). For the last sector, the default number is the last sector. By selecting it, the new partition will fill the entire device.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-30277631, default 2048): 196608                                                                                                                                          
Last sector, +/-sectors or +/-size{K,M,G,T,P} (196608-30277631, default 30277631): 

Created a new partition 2 of type 'Linux' and of size 14.4 GiB.
Partition #2 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: N

Verify the new partition configuration with the p command:

Command (m for help): p

Disk /dev/mmcblk2: 14.45 GiB, 15502147584 bytes, 30277632 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: dos
Disk identifier: 0x879591b6

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk2p1 *     16384   186775   170392 83.2M  c W95 FAT32 (LBA)
/dev/mmcblk2p2      196608 30277631 30081024 14.4G 83 Linux

The changes need to be written using the w command:

Command (m for help): w
The partition table has been altered.
Syncing disks.

Reboot the device to load the new partition configuration:

root@visionsom-8mm-cb-std:~# reboot

Resize the filesystem using the resize2fs tool:

root@visionsom-8mm-cb-std:~# resize2fs /dev/mmcblk2p2
resize2fs 1.45.3 (14-Jul-2019)
Filesystem at /dev/mmcblk2p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mmcblk2p2 is now 3760128 (4k) blocks long.

Verify the results using for example the df tool:

root@visionsom-8mm-cb-std:~# df -lh
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        14G  1.7G   12G  13% /
NXP Partner ST Partner Renesas Partner