Partitioning SD cards


Andy Pont
 

Hello,

I am working on a custom platform where U-Boot will be programmed into an SPI NOR flash device and the ext4 file systems will be in a removable microSD card.  The Linux kernel itself will be stored in the /boot directory of the root file system.

The customer wants the (16GB) microSD card formatted as 1GB to mount at / and the remaining 15GB mounted as /home.

In the recipe for my image I have defined the following to try to create a suitable image for writing to the microSD card:

IMAGE_FSTYPES_append = " wic"
IMAGE_ROOTFS_SIZE = “1048576”

The image file that is being created is bigger than 1GB even though the root file system is only a little over 450MB.  Looking at the contents of what gets written to the microSD card this looks as though it is, in part, because it also includes the ~20MB “boot” partition containing the boot files.

A couple of questions…

How do I stop the wic generation process including the FAT formatted “boot” partition?

What is the best strategy for partitioning / formatting / mounting the second partition as /home?  Should it be part of the image build process or a one-time task run at first boot?

-Andy.



Maciej Pijanowski
 


On 14.10.2019 14:13, Andy Pont wrote:
Hello,

I am working on a custom platform where U-Boot will be programmed into an SPI NOR flash device and the ext4 file systems will be in a removable microSD card.  The Linux kernel itself will be stored in the /boot directory of the root file system.

The customer wants the (16GB) microSD card formatted as 1GB to mount at / and the remaining 15GB mounted as /home.

In the recipe for my image I have defined the following to try to create a suitable image for writing to the microSD card:

IMAGE_FSTYPES_append = " wic"
IMAGE_ROOTFS_SIZE = “1048576”

The image file that is being created is bigger than 1GB even though the root file system is only a little over 450MB.  Looking at the contents of what gets written to the microSD card this looks as though it is, in part, because it also includes the ~20MB “boot” partition containing the boot files.

A couple of questions…

How do I stop the wic generation process including the FAT formatted “boot” partition?
This depends on the wic (.wks) file you are using.

What is the best strategy for partitioning / formatting / mounting the second partition as /home?  Should it be part of the image build process or a one-time task run at first boot?
Use --exclude-path and --rootfs-dir flags in the .wks file.
You can look at my example, where I extract one subdir from rootfs (/storage in this case) on a separate partition.
https://github.com/3mdeb/meta-rte/blob/master/wic/sunxi-mmc-spl.wks

The rootfs parts should be named somewhere, like in distro config: https://github.com/3mdeb/meta-rte/blob/master/conf/distro/rte.conf#L50

-Andy.



-- 
Maciej Pijanowski
Embedded Systems Engineer
GPG: F1401D2E1CCB19EF
https://3mdeb.com | @3mdeb_com


Andy Pont
 

Maciej wrote...

How do I stop the wic generation process including the FAT formatted “boot” partition?
This depends on the wic (.wks) file you are using.
I have been using the default one (sdimage-bootpart.wks)?

What is the best strategy for partitioning / formatting / mounting the second partition as /home?  Should it be part of the image build process or a one-time task run at first boot?
Use --exclude-path and --rootfs-dir flags in the .wks file.
You can look at my example, where I extract one subdir from rootfs (/storage in this case) on a separate partition.
https://github.com/3mdeb/meta-rte/blob/master/wic/sunxi-mmc-spl.wks
I have created a “wic” directory in my custom layer and copied sdimage-bootpart.wks into it as sdimage-project.wks without making any changes but “wic list image” throws an error with the new .wks file:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 37: invalid start byte

-Andy.


Andy Pont
 

I wrote...

I have created a “wic” directory in my custom layer and copied sdimage-bootpart.wks into it as sdimage-project.wks without making any changes but “wic list image” throws an error with the new .wks file:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 37: invalid start byte
Ignore that, I deleted the directory and tried again and it is OK now!

-Andy.