Personal tools

Extending rootfs partition: Difference between revisions

From SomLabs Wiki

Jump to: navigation, search
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..."
 
No edit summary
Line 2: Line 2:


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.
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 thake 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:
Boot the system and login as root. Print the storage information using the ''fdisk'' tool:


<pre>root@visionsom:~# fdisk -l /dev/mmcblk1
<pre>
Disk /dev/mmcblk1: 3.7 GiB, 3909091328 bytes, 7634944 sectors
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
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disklabel type: dos
Disk identifier: 0xf3cda753
Disk identifier: 0x879591b6


Device        Boot Start    End Sectors  Size Id Type
Device        Boot Start    End Sectors  Size Id Type
/dev/mmcblk1p1      8192 2568191 2560000 1.2G 83 Linux</pre>
/dev/mmcblk2p1 *    16384 186775  170392 83.2M  c W95 FAT32 (LBA)
/dev/mmcblk2p2      196608 4273325 4076718    2G 83 Linux
</pre>


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.
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:
Open the fdisk interactive terminal:


<pre>root@visionsom:~# fdisk /dev/mmcblk1
<pre>
root@visionsom-8mm-cb-std:~# fdisk /dev/mmcblk2


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




Command (m for help):</pre>
Command (m for help):
</pre>
 
Delete the existing /dev/mmcblk2p2 system partition with the ''d'' command:


Delete the existing partition with the ''d'' command:
<pre>
Command (m for help): d
Partition number (1,2, default 2): 2


<pre>Command (m for help): d
Partition 2 has been deleted.
Selected partition 1
</pre>
Partition 1 has been deleted.</pre>


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.
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.


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


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


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


Verify the new partition configuration with the ''p'' command:
Verify the new partition configuration with the ''p'' command:


<pre>Command (m for help): p
<pre>
Command (m for help): p


Disk /dev/mmcblk1: 3.7 GiB, 3909091328 bytes, 7634944 sectors
Disk /dev/mmcblk2: 14.45 GiB, 15502147584 bytes, 30277632 sectors
Units: sectors of 1 * 512 = 512 bytes
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disklabel type: dos
Disk identifier: 0xf3cda753
Disk identifier: 0x879591b6


Device        Boot Start     End Sectors  Size Id Type
Device        Boot Start     End Sectors  Size Id Type
/dev/mmcblk1p1      8192 7634943 7626752 3.7G 83 Linux</pre>
/dev/mmcblk2p1 *    16384  186775  170392 83.2M c W95 FAT32 (LBA)
/dev/mmcblk2p2      196608 30277631 30081024 14.4G 83 Linux
</pre>


The changes need to be written using the ''w'' command:
The changes need to be written using the ''w'' command:


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


Reboot the device to load the new partition configuration:
Reboot the device to load the new partition configuration:


<pre>root@visionsom:~# reboot</pre>
<pre>root@visionsom-8mm-cb-std:~# reboot</pre>


Resize the filesystem using the ''resize2fs'' tool:
Resize the filesystem using the ''resize2fs'' tool:


<pre>root@visionsom:~# resize2fs /dev/mmcblk1p1
<pre>
resize2fs 1.44.5 (15-Dec-2018)
resize2fs 1.45.3 (14-Jul-2019)
Filesystem at /dev/mmcblk1p1 is mEXT4-fs (mmcblk1p1): resizing filesystem from 1280000 to 3813376 blocks
Filesystem at /dev/mmcblk2p2 is mounted on /; on-line resizing required
ounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
old_desc_blocks = 5, new_desc_blocks = 15
The filesystem on /dev/mmcblk2p2 is now 3760128 (4k) blocks long.
EXT4-fs (mmcblk1p1): resized filesystem to 3813376
</pre>
The filesystem on /dev/mmcblk1p1 is now 3813376 (1k) blocks long.</pre>


Verify the results using for example the ''df'' tool:
Verify the results using for example the ''df'' tool:


<pre>root@visionsom:~# df -lh
<pre>
root@visionsom-8mm-cb-std:~# df -lh
Filesystem      Size  Used Avail Use% Mounted on
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       3.6G 1.1G  2.4G  31% /
/dev/root       14G 1.7G   12G 13% /
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</pre>

Revision as of 13:20, 21 August 2020

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 thake 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:

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% /