diff --git a/configs/images/raspberrypi3_raspbian_config b/configs/images/raspberrypi3_raspbian_config index 925611e..7f83bab 100644 --- a/configs/images/raspberrypi3_raspbian_config +++ b/configs/images/raspberrypi3_raspbian_config @@ -12,3 +12,37 @@ 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) diff --git a/mender-convert-modify b/mender-convert-modify index 42edc9d..43f454d 100755 --- a/mender-convert-modify +++ b/mender-convert-modify @@ -19,10 +19,12 @@ function platform_modify() { true } +PLATFORM_MODIFY_HOOKS=(platform_modify) function user_local_modify() { true } +USER_LOCAL_MODIFY_HOOKS=(user_local_modify) function trap_exit() { echo "mender-convert-modify has finished. Cleaning up..." @@ -233,10 +235,16 @@ ${MENDER_STORAGE_DEVICE_BASE}${MENDER_DATA_PART_NUMBER} /data auto EOF" log_info "Performing platform specific modifications (if any)" -platform_modify +for hook in "${PLATFORM_MODIFY_HOOKS[@]}"; do + log_info "Running hook: $hook" + eval $hook +done log_info "Performing user/local specific modifications (if any)" -user_local_modify +for hook in "${USER_LOCAL_MODIFY_HOOKS[@]}"; do + log_info "Running hook: $hook" + eval $hook +done for overlay in "${overlays[@]}"; do log_info "Applying rootfs overlay: ${overlay}" diff --git a/mender-convert-package b/mender-convert-package index 1f1bd28..c0ce619 100755 --- a/mender-convert-package +++ b/mender-convert-package @@ -19,6 +19,7 @@ function platform_package() { true } +PLATFORM_PACKAGE_HOOKS=(platform_package) function trap_exit() { echo "mender-convert-package has finished. Cleaning up..." @@ -244,7 +245,10 @@ disk_write_at_offset "${output_dir}/rootfs.img" "${img_path}" "${rootfsb_start}" disk_write_at_offset "${output_dir}/data.img" "${img_path}" "${data_start}" log_info "Performing platform specific package operations (if any)" -platform_package +for hook in "${PLATFORM_PACKAGE_HOOKS[@]}"; do + log_info "Running hook: $hook" + eval $hook +done # Create bmap index if [ "${MENDER_USE_BMAP}" == "y" ]; then