In order to use a read-only partition for the filesystem, i want to implement an overlay feature. To do so, the system has to be already partitioned with a working boot-loader and two partitions, the first one bootable. see the following link: Read-only root with overlayfs
However, our Image isn’t partitioned and only have a rootfs partition, that we couldn’t split and resize, without compromising the whole disk.
The idea was to apply the modifications before building the OS Image thanks to Fenix.
In the build-rootfs file, we modified part of the code related to disk partitioning to limit the size of the rootfs and to create another partition with the same size that we need for implementing the overlay:
if [ "$GENERIC_IMAGE_PARTITION_TABLE" != "gpt" ]; then
fdisk "${BUILD_IMAGES}/${IMAGE_FILE_NAME}" <<-EOF
o
n
p
1
32768
524287
a
t
b
n
p
2
524288
33540096
n
p
3
33540097
67106815
p
w
EOF
else
parted -s ${BUILD_IMAGES}/${IMAGE_FILE_NAME} mklabel gpt
parted -s ${BUILD_IMAGES}/${IMAGE_FILE_NAME} unit s mkpart boot 32768 524287
parted -s ${BUILD_IMAGES}/${IMAGE_FILE_NAME} unit s mkpart rootfs 524288 33540096
#parted -s ${BUILD_IMAGES}/${IMAGE_FILE_NAME} unit s mkpart data 33540097 67106815
#parted -s ${BUILD_IMAGES}/${IMAGE_FILE_NAME} set 1 boot on
fi
You’ll find below the fdisk command that are used. The numbers are the values of the sector where the partition start and where it ends.
I also added this line in the config/config file:
#IMAGE PARTITION TABLE TYPE
GENERIC_IMAGE_PARTITION_TABLE="gpt"
Here is the result:
Our disk is still not splited even after modifing the files before building the image.
Do you have any tips to go further ? thank you so much for your help