Extending rootfs partition: Difference between revisions
From SomLabs Wiki
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 |
||
(3 intermediate revisions by 2 users not shown) | |||
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 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: | Boot the system and login as root. Print the storage information using the ''fdisk'' tool: | ||
<pre>root@visionsom:~# fdisk -l /dev/ | <pre> | ||
Disk /dev/ | 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: | Disk identifier: 0x879591b6 | ||
Device Boot Start End Sectors Size Id Type | Device Boot Start End Sectors Size Id Type | ||
/dev/ | /dev/mmcblk2p1 * 16384 186775 170392 83.2M c W95 FAT32 (LBA) | ||
/dev/mmcblk2p2 196608 4273325 4076718 2G 83 Linux | |||
</pre> | |||
The /dev/ | 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/ | <pre> | ||
root@visionsom-8mm-cb-std:~# fdisk /dev/mmcblk2 | |||
Welcome to fdisk (util-linux 2. | 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: | |||
<pre> | |||
Command (m for help): d | |||
Partition number (1,2, default 2): 2 | |||
Partition 2 has been deleted. | |||
</pre> | |||
Partition | |||
Create a new primary partition number | 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 ( | 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 ( | Partition number (2-4, default 2): 2 | ||
First sector (2048- | First sector (2048-30277631, default 2048): 196608 | ||
Last sector, +/-sectors or +/-size{K,M,G,T,P} ( | Last sector, +/-sectors or +/-size{K,M,G,T,P} (196608-30277631, default 30277631): | ||
Created a new partition | Created a new partition 2 of type 'Linux' and of size 14.4 GiB. | ||
Partition # | 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/ | 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: | Disk identifier: 0x879591b6 | ||
Device Boot Start | Device Boot Start End Sectors Size Id Type | ||
/dev/ | /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/ | <pre> | ||
resize2fs 1. | root@visionsom-8mm-cb-std:~# resize2fs /dev/mmcblk2p2 | ||
Filesystem at /dev/ | resize2fs 1.45.3 (14-Jul-2019) | ||
Filesystem at /dev/mmcblk2p2 is mounted on /; on-line resizing required | |||
old_desc_blocks = | old_desc_blocks = 1, new_desc_blocks = 2 | ||
The filesystem on /dev/mmcblk2p2 is now 3760128 (4k) blocks long. | |||
The filesystem on /dev/ | </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 | /dev/root 14G 1.7G 12G 13% / | ||
</pre> | |||
Latest revision as of 06:25, 16 September 2021
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% /