How to resize the rootfs.sdcard.bz2 on IMX8mm Yoct Linux

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to resize the rootfs.sdcard.bz2 on IMX8mm Yoct Linux

5,401 Views
13614278
Contributor III

We have IMX8mini with 2G RAM and 8G emmc. 

But after we build the yocto linux, the whole rootfs file size is the same as the rootfs.sdcard.bz2, which is 1.3G,

How to build a 7G,or 8G rootfs?

0 Kudos
18 Replies

5,202 Views
Rita_Wang
NXP TechSupport
NXP TechSupport

Could you tell us which version of BSP are you using?

0 Kudos

5,202 Views
13614278
Contributor III

Hi Rita,

It's Linux BSP 4.14.98. I don't want use the solution such as IMAGE_ROOTFS_EXTRA_SPACE=" xxxxxx" in Yocto, as it would forcely expand the rootfs to a useless large size. e.g, for my 8GB emmc case, above solution would cause my rootfs.sdcard file to 8GB as well, while my real data is only 800MB, it use ZERO-padding to force the whole file to 8GB.

I felt it's really a bad and dull design, as this useless large size is really a waste of time for both my flashing time and my hard disk storeage.

I'm wondering if there is any way to let it behavior as Android's way. You know, Android's system image is the real user data size, e.g, only 800MB size, after flashing it to EVK, the whole system storeage is 8GB instead of 800MB, that's really comfortable for me. But for Yocto, this is really bad for me, and I am really feel confused about the behavior on Yocto.

Thanks a lot.

0 Kudos

5,202 Views
Rita_Wang
NXP TechSupport
NXP TechSupport

The Yocto Project build creates an SD card image that can be flashed directly. This is the simplest way to load everything needed onto the card with one command. This is convenient to use.
An .sdcard image contains all four images properly configured for an SD card. The release contains a pre-built .sdcard image that is built specifically for the one board configuration.

The rootfs on the default .sdcard image is limited to a bit less than 4 GB, but re-partitioning and re-loading the rootfs can increase that to the size of the card. The rootfs can also be changed to specify the graphical backend that is used.

0 Kudos

4,929 Views
Chayma
Contributor III

Hello,

Is there a way to boot from eMMC and extend the Rootfs size without using the variable in local.conf ?

Thank you in advance.

Best regards,

0 Kudos

4,913 Views
BiyongSUN
NXP Employee
NXP Employee

When finish building, you have everything. 

Is there anything can not achieve by the Yocto build output files/images? 

Like imx-image-multimedia-imx8mmevk.rootfs.ext4.gz partition mirror is provided linke android system.img. 

"a bad and dull design"?  Yocto just use the images to make a sdcard mirror. Android just not use the mirror to make the sdcard mirror.  what's the different? 

Android also can make a entire sdcard mirror.

 

i.MX Create Android SDCard Mirror
https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/i-MX-Create-Android-SDCard-Mirror/ta-p/1...

 

 

If you have time, you can read  Image Assembling of  SWUpdate OTA i.MX8MM EVK_rev3.pdf page 73.

It uses the Yocto building and assemble double copy demo sample.

 


SWUpdate OTA i.MX8MM EVK / i.MX8QXP MEK
https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/SWUpdate-OTA-i-MX8MM-EVK-i-MX8QXP-MEK/ta...

 

 

0 Kudos

4,920 Views
BiyongSUN
NXP Employee
NXP Employee

It is pure linux skills. 

X84/X64 linux is exaclty the same thing. 

resize sdcard mirror:

sudo parted imx-image-multimedia-imx8mmevk.wic unit MiB print

Number Start End Size Type File system Flags
1 8.00MiB 91.2MiB 83.2MiB primary fat16 boot, lba
2 96.0MiB 2499MiB 2403MiB primary ext4


truncate -s 3499M imx-image-multimedia-imx8mmevk.wic

sudo parted imx-image-multimedia-imx8mmevk.wic unit MiB resizepart 2 3403

 

Number Start End Size Type File system Flags
1 8.00MiB 91.2MiB 83.2MiB primary fat16 boot, lba
2 96.0MiB 3403MiB 3307MiB primary ext4

sudo kpartx -av imx-image-multimedia-imx8mmevk.wic

sudo e2fsck -f /dev/mapper/loop0p2

sudo resize2fs /dev/mapper/loop0p2

sudo kpartx -dv imx-image-multimedia-imx8mmevk.wic

 

0 Kudos

4,905 Views
Chayma
Contributor III

@BiyongSUN 

hello,

Is there a way to resize the rootfs during the system runtime (Image is running in the HW) ?

thank you.

0 Kudos

4,902 Views
BiyongSUN
NXP Employee
NXP Employee

rootfs resize is very dangerous. even in the X86/X64 system. 

It depends on the system design. like ubuntu. it runs ramdisk first then chroot to the system root.

If resize the system root, it need to switch back to the ramdisk and stop every service and umount the system root. 

strictly, if it is a real rootfs. it could not resize at runtime. 

could not see any case to resize a real root partition.

see the data partition resize close to 100% to root partition.  

 

could not see that kind of case in embedded system.

 

If you can make sure every service is stopped and no anything touches the root. You can do it. 

4,891 Views
talel_hajsalem
Contributor III

Great reply,

 

Is it possible for embedded systems without ramdisk?

Because if we have 16 Go eMMC flash and the initial rootfs is 1Go

What's the use of the remaining 15Go if the resizing is risky?

This is case-dependent and needs testing according to the project needs.

 

0 Kudos

4,874 Views
BiyongSUN
NXP Employee
NXP Employee

13614278 says don't want to use Yocto IMAGE_ROOTFS_EXTRA_SPACE to to that. 

That is why I show the manual method. 

And it is pure linux knowledge. no any related to imx.  

0 Kudos

4,881 Views
BiyongSUN
NXP Employee
NXP Employee

You can use the 10G(for example) for rootfs build from Yocto.

Or you can resize the sdcard mirror as I have shown you before burn to emmc. 

 

I have already shown you. 

 

resize sdcard mirror:

sudo parted imx-image-multimedia-imx8mmevk.wic unit MiB print

Number Start End Size Type File system Flags
1 8.00MiB 91.2MiB 83.2MiB primary fat16 boot, lba
2 96.0MiB 2499MiB 2403MiB primary ext4


truncate -s 3499M imx-image-multimedia-imx8mmevk.wic

sudo parted imx-image-multimedia-imx8mmevk.wic unit MiB resizepart 2 3403

 

Number Start End Size Type File system Flags
1 8.00MiB 91.2MiB 83.2MiB primary fat16 boot, lba
2 96.0MiB 3403MiB 3307MiB primary ext4

sudo kpartx -av imx-image-multimedia-imx8mmevk.wic

sudo e2fsck -f /dev/mapper/loop0p2

sudo resize2fs /dev/mapper/loop0p2

sudo kpartx -dv imx-image-multimedia-imx8mmevk.wic

 

 

Or the remaining disk space can be another partition.  all it can be done in Yocto or manually. 

0 Kudos

4,878 Views
talel_hajsalem
Contributor III

Yes, thanks for the advice.

The only solution I'm aiming for is to resize at run time, because I don't want to carry a 10Go image file around.

 

The only good solution I'm thinking of is :

If I have 16Go eMMC flash and my initial rootfs size is 1Go

At first boot I create a new partition with >= 10Go for data usage.

0 Kudos

4,868 Views
BiyongSUN
NXP Employee
NXP Employee

yes. If you flash image by linux, which is the example_kernel_emmc.uuu. 

You can flash the partition mirror and resize it at run time. 

4,872 Views
BiyongSUN
NXP Employee
NXP Employee

If you are using MBR, no don't have to use the whole size for the miror. 

For example, all the files in rootfs is 1G. you just use 1G mirror, with the MBR 10G.

For the gpt, it is the same, just need a gpt partiton files. 

 

The first boot, the linux will check for you. 

 

4,869 Views
talel_hajsalem
Contributor III

Sounds like a good solution,

I'll take a look and check for details.

If you have any example or use-case (specially with Yocto) it would be so helpful.

Thanks for the support,

Talel

0 Kudos

4,852 Views
BiyongSUN
NXP Employee
NXP Employee

agree with you. it can save time for mass production. 

Here is one solution. 

1. At the beginning, use the original mirror image to flash the emmc.

2. get into linux and finish the resize. 

HW: i.MX8MM EVK

SW: LF_v5.10.35_2.0.0 binary demo image 

Script: uuc_kernel_emm_resize.uuu(uuc_kernel_emm_resize.uuu..zip)

           e2fsprogs.arm.static.tar(e2fsck, resize2fs --- e2fsprogs.arm.static.tar.zip)

   1. put the uuc_kernel_emm_resize.uuu and  e2fsprogs.arm.static.tar   

       into binary demo release directory. 

   2.   uuu uuc_kernel_emm_resize.uuu

   3. dd if=/dev/zero of=/test.bin bs=1G count=6 to check if we really have more space 

 

result:

uuu shell output. 

    uuu -s uuc_kernel_emm_resize.uuu

Disk /dev/mmcblk2: 14.68 GiB, 15758000128 bytes, 30777344 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: 0x8e5bd78c

Old situation:

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

/dev/mmcblk2p2:
New situation:
Disklabel type: dos
Disk identifier: 0x8e5bd78c

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

 

boot and test:

 

 


New situation:
Disklabel type: dos
Disk identifier: 0x8e5bd78c

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

 

board boot and test if we really have more space

yes, we have. 

Untitled.png

 

 

 

 

3,139 Views
khang_letruong
Senior Contributor III

Hi @BiyongSUN,

Can I use same scripts (uuc_kernel_emm_resize.uuu..zip, e2fsprogs.arm.static.tar.zip) for BSP-L5.10.72-2.2.0, please ?

Best regards,

Khang

0 Kudos

4,894 Views
Chayma
Contributor III

@BiyongSUN 

Thank you for your response.

0 Kudos