You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

48 lines
1.7 KiB

# Real life SD cards typically have less than they advertise. First off, they
# often use a base of 1000 instead of 1024, and even then they are often smaller
# than advertised. The number below is based on a conservative target of 7.9GB
# (that's mathematical GB, base 1000), converted to MiB, rounding down.
MENDER_STORAGE_TOTAL_SIZE_MB=7534
# Use all there is, which gets us almost, but not quite, to 500MiB free space
# (about 480MiB at the time of writing).
IMAGE_ROOTFS_SIZE=-1
IMAGE_ROOTFS_EXTRA_SPACE=0
IMAGE_OVERHEAD_FACTOR=1.0
# Best compression there is!
MENDER_COMPRESS_DISK_IMAGE=lzma
#
# Resize the data partition to fill the remaining space, using parted, with systemd
#
function grow_data_partition() {
log_info "Adding systemd init script to run parted and resize the data partition on boot"
log_info "to fill all the available space on the storage media"
run_and_log_cmd "sudo mkdir -p work/rpi/etc/systemd/system/"
run_and_log_cmd "sudo mkdir -p work/rootfs/etc/systemd/system/data.mount.wants/"
cat <<-EOF > work/rpi/etc/systemd/system/mender-grow-data.service
[Unit]
Description=Mender service to grow data partition size
DefaultDependencies=no
Before=data.mount
Before=systemd-growfs@data.service
[Service]
Type=oneshot
User=root
Group=root
ExecStart=/sbin/parted --script /dev/mmcblk0 resizepart ${MENDER_DATA_PART_NUMBER} 100%
[Install]
WantedBy=data.mount
EOF
# Install
run_and_log_cmd "cp work/rpi/etc/systemd/system/mender-grow-data.service \
work/rootfs/etc/systemd/system/"
run_and_log_cmd "ln -sf work/rootfs/etc/systemd/system/mender-grow-data.service \
work/rootfs/etc/systemd/system/data.mount.wants/"
}
PLATFORM_MODIFY_HOOKS+=(grow_data_partition)