classes: use dd's option fsync instead of sync
PATCH 1/1 classes: use dd's option fsync instead of sync
The shell command sync flushes all filesystem buffers in the system. On a bigger multiuser system there are multiple gigs of data sometimes in the buffer which then are written out to disk at once. It's better to only flush the specific file with dd's option 'fsync'.
---
Hi,
I'm curious why the bbclass image_types_fsl.bbclass uses a double 'sync' to burn the sdcard image. Is there a specific reason, why a single sync is not sufficient to write the data to disk?
Furthermore calling sync will flush all filesystem buffers on the system. It maybe a performance bottleneck because this may fill up the disk controller capacity quickly.
Kind regards,
Stefan
--- classes/image_types_fsl.bbclass | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
classes/image_types_fsl.bbclass +3 -3
@@ -178,8 +178,8 @@ generate_imx_sdcard () { fi # Burn Partition - dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync - dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync + dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) + dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) } #
@@ -293,7 +293,7 @@ generate_mxs_sdcard () { parted ${SDCARD} print - dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync + dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) } IMAGE_CMD_sdcard () {
Signature · 1 line
1.9.1
Quoted 40 lines · Stefan Christ
The shell command sync flushes all filesystem buffers in the system. On a bigger multiuser system there are multiple gigs of data sometimes in the buffer which then are written out to disk at once. It's better to only flush the specific file with dd's option 'fsync'.
Signed-off-by Stefan Christ <[email protected]>---
Hi,I'm curious why the bbclass image_types_fsl.bbclass uses a double 'sync' to burn the sdcard image. Is there a specific reason, why a single sync is not sufficient to write the data to disk?
Furthermore calling sync will flush all filesystem buffers on the system. It maybe a performance bottleneck because this may fill up the disk controller capacity quickly.
Kind regards,
Stefan--- classes/image_types_fsl.bbclass | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)classes/image_types_fsl.bbclass +2
-2@@ -178,8 +178,8 @@ generate_imx_sdcard () { fi # Burn Partition - dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync - dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync + dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) + dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) } #
classes/image_types_fsl.bbclass generate_mxs_sdcard () { · line 299
Quoted 8 lines
classes/image_types_fsl.bbclass +1
-1@@ -293,7 +293,7 @@ generate_mxs_sdcard () { parted ${SDCARD} print - dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync + dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) } IMAGE_CMD_sdcard () {