diff --git a/convert-stage-3.sh b/convert-stage-3.sh index e657395..fa6328f 100755 --- a/convert-stage-3.sh +++ b/convert-stage-3.sh @@ -7,7 +7,7 @@ build_log=$output_dir/build.log [ ! -f ${output_dir}/rootfs.img ] && \ { log "Error: extracted rootfs partition not found. Aborting."; exit 1; } -sudo dd if=${output_dir}/rootfs.img of=/dev/mapper/${rootfs_mapping} bs=8M >> "$build_log" 2>&1 +sudo dd if=${output_dir}/rootfs.img of=/dev/mapper/${rootfs_mapping} bs=8M conv=sparse >> "$build_log" 2>&1 sync # Check Linux ext4 file system just in case. sudo fsck.ext4 -fp /dev/mapper/${rootfs_mapping} >> "$build_log" 2>&1 diff --git a/mender-convert b/mender-convert index 79595f9..36d3c84 100755 --- a/mender-convert +++ b/mender-convert @@ -297,7 +297,7 @@ do_raw_disk_image_create_partitions() { calculate_mender_disk_size $sector_size ${partition_alignment} \ mender_disk_sizes mender_disk_image_size - log "\tCreating Mender disk image:\ + log "\tCreating blank Mender disk image:\ \n\t\timage size: ${mender_disk_image_size} bytes\ \n\t\tboot partition size: $((${mender_disk_sizes[pboot_size]} * $sector_size)) bytes\ \n\t\troot filesystem size: $((${mender_disk_sizes[prootfs_size]} * $sector_size)) bytes\ diff --git a/mender-convert-functions.sh b/mender-convert-functions.sh index b663f7f..9d225ae 100755 --- a/mender-convert-functions.sh +++ b/mender-convert-functions.sh @@ -396,10 +396,9 @@ unmount_partitions() { create_mender_disk() { local lfile=$1 local lsize=$2 - local bs=$(( 1024*1024 )) - local count=$(( ${lsize} / ${bs} )) - dd if=/dev/zero of=${lfile} bs=${bs} count=${count}>> "$build_log" 2>&1 + # Generates a sparse image + dd if=/dev/zero of=${lfile} seek=${lsize} bs=1 count=0 >> "$build_log" 2>&1 } # Takes following arguments: @@ -738,7 +737,7 @@ set_fstab() { extract_file_from_image() { log "\tStoring data in $4." - local cmd="dd if=$1 of=${output_dir}/$4 skip=$2 bs=512 count=$3" + local cmd="dd if=$1 of=${output_dir}/$4 skip=$2 bs=512 count=$3 conv=sparse" $(${cmd}>> "$build_log" 2>&1) } diff --git a/qemux86_64-convert-stage-2.sh b/qemux86_64-convert-stage-2.sh index ffad07f..8f94d0e 100755 --- a/qemux86_64-convert-stage-2.sh +++ b/qemux86_64-convert-stage-2.sh @@ -14,7 +14,7 @@ sed -i 's/\b[ ]root=[^ ]*/ root=\/dev\/hda2/' ${output_dir}/grub.cfg # Update Linux kernel command arguments with our custom configuration mcopy -o -i ${output_dir}/boot.vfat -s ${output_dir}/grub.cfg ::EFI/BOOT/grub.cfg -sudo dd if=${output_dir}/boot.vfat of=/dev/mapper/${boot_mapping} bs=1M >> "$build_log" 2>&1 +sudo dd if=${output_dir}/boot.vfat of=/dev/mapper/${boot_mapping} bs=1M conv=sparse >> "$build_log" 2>&1 log "\tDone." diff --git a/rpi-convert-stage-2.sh b/rpi-convert-stage-2.sh index 57f5f4f..4dcb160 100755 --- a/rpi-convert-stage-2.sh +++ b/rpi-convert-stage-2.sh @@ -18,7 +18,7 @@ mcopy -on -i ${output_dir}/boot.vfat -s ::config.txt ${output_dir}/config.txt echo -e '\nenable_uart=1\n' >> ${output_dir}/config.txt mcopy -o -i ${output_dir}/boot.vfat -s ${output_dir}/config.txt ::config.txt -sudo dd if=${output_dir}/boot.vfat of=/dev/mapper/${boot_mapping} bs=1M >> "$build_log" 2>&1 +sudo dd if=${output_dir}/boot.vfat of=/dev/mapper/${boot_mapping} bs=1M conv=sparse >> "$build_log" 2>&1 log "\tDone."