Personal tools

Extending rootfs partition

From SomLabs Wiki

Revision as of 10:47, 1 November 2019 by KrzysztofChojnowski (talk | contribs) (Created page with "{{PageHeader|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 modu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.

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

root@visionsom:~# fdisk -l /dev/mmcblk1
Disk /dev/mmcblk1: 3.7 GiB, 3909091328 bytes, 7634944 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: 0xf3cda753

Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk1p1       8192 2568191 2560000  1.2G 83 Linux

The /dev/mmcblk1 is the storage device, while the /dev/mmcblk1p1 represents the partition. In this case the partition has only 1.2GB, leaving about 2.5GB free on the device.

Open the fdisk interactive terminal:

root@visionsom:~# fdisk /dev/mmcblk1

Welcome to fdisk (util-linux 2.33.1).
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 partition with the d command:

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Create a new primary partition number 1. The first sector number should be exactly the same as in the original partition which was 8192. 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 (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-7634943, default 2048): 8192
Last sector, +/-sectors or +/-size{K,M,G,T,P} (8192-7634943, default 7634943): 

Created a new partition 1 of type 'Linux' and of size 3.7 GiB.
Partition #1 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/mmcblk1: 3.7 GiB, 3909091328 bytes, 7634944 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: 0xf3cda753

Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk1p1       8192 7634943 7626752  3.7G 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:~# reboot

Resize the filesystem using the resize2fs tool:

root@visionsom:~# resize2fs /dev/mmcblk1p1 
resize2fs 1.44.5 (15-Dec-2018)
Filesystem at /dev/mmcblk1p1 is mEXT4-fs (mmcblk1p1): resizing filesystem from 1280000 to 3813376 blocks
ounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 15
EXT4-fs (mmcblk1p1): resized filesystem to 3813376
The filesystem on /dev/mmcblk1p1 is now 3813376 (1k) blocks long.

Verify the results using for example the df tool:

root@visionsom:~# df -lh
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       3.6G  1.1G  2.4G  31% /
devtmpfs         86M     0   86M   0% /dev
tmpfs           247M     0  247M   0% /dev/shm
tmpfs           247M  6.6M  240M   3% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           247M     0  247M   0% /sys/fs/cgroup
tmpfs            50M   12K   50M   1% /run/user/1000
tmpfs            50M     0   50M   0% /run/user/0
NXP Partner ST Partner