Failure mender-convert on dd step

Hi
I am trying to convert a ubuntu server 22 minimised image as golden image. After a bit of work to get a mountable golden-image I have tried the convert script in the docker container, via

$ MENDER_ARTIFACT_NAME="release-1" ./docker-mender-convert --disk-image input/golden-image-1.img 

The golden image is ubuntu server 2022 minimised with two partitions a boot fat32 and / ext4 of 1G and 6G respectively.
stdout:

using log file at: /home/peter-laptop/mender-drive/mender-convert/logs/convert.log.1679886704-880354
Running mender-convert --disk-image input/golden-image-1.img
Running mender-convert-extract: --config ./work/override_compression_config --disk-image input/golden-image-1.img
2023-03-27 03:11:44 [INFO] [mender-convert-extract] Using configuration file: configs/mender_convert_config
2023-03-27 03:11:44 [INFO] [mender-convert-extract] Using configuration file: ./work/override_compression_config
2023-03-27 03:11:44 [INFO] [mender-convert-extract] Validating disk image
2023-03-27 03:11:44 [INFO] [mender-convert-extract] Disk parsed successfully
2023-03-27 03:11:44 [INFO] [mender-convert-extract] NUMBER OF PARTS: 2 TYPE: gpt
2023-03-27 03:11:44 [INFO] [mender-convert-extract] PART 1: SIZE: 1.1G TYPE: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
2023-03-27 03:11:44 [INFO] [mender-convert-extract] PART 1: extracting to work/part-1.fs
2023-03-27 03:11:47 [INFO] [mender-convert-extract] PART 2: SIZE: 6G TYPE: 0fc63daf-8483-4772-8e79-3d69d8477de4
2023-03-27 03:11:47 [INFO] [mender-convert-extract] PART 2: extracting to work/part-2.fs
2023-03-27 03:12:18 [INFO] [mender-convert-extract] Extracting boot gap to work/boot-gap.bin
mender-convert-extract has finished. Cleaning up...
Running mender-convert-modify: --config ./work/override_compression_config --disk-image input/golden-image-1.img
2023-03-27 03:12:18 [INFO] [mender-convert-modify] Using configuration file: configs/mender_convert_config
2023-03-27 03:12:18 [INFO] [mender-convert-modify] Using configuration file: ./work/override_compression_config
mount: /mender-convert/work/rootfs: wrong fs type, bad option, bad superblock on /dev/loop20, missing codepage or helper program, or other error.
mender-convert-modify has finished. Cleaning up...
umount: work/rootfs: not mounted.
2023-03-27 03:12:18 [ERROR] [mender-convert] mender-convert failed
2023-03-27 03:12:18 [DEBUG] [mender-convert-extract] When running: (modules/disk.sh:63): run_and_log_cmd():  

	dd if=input/golden-image-1.img of=work/boot-gap.bin skip=1 bs=512 count=2047 conv=sparse status=none
2023-03-27 03:12:18 [INFO] [mender-convert-modify] Using configuration file: configs/mender_convert_config
2023-03-27 03:12:18 [INFO] [mender-convert-modify] Using configuration file: ./work/override_compression_config
2023-03-27 03:12:18 [ERROR] [mender-convert] mender-convert failed
2023-03-27 03:12:18 [ERROR] [mender-convert] mender-convert exit code: 32
Log file available at: /home/peter-laptop/mender-drive/mender-convert/logs/convert.log.1679886704-880354

The log file records some failure when building the boot-gap.bin:

2023-03-27 02:01:59 [INFO] [mender-convert-extract] Using configuration file: configs/mender_convert_config
2023-03-27 02:01:59 [INFO] [mender-convert-extract] Using configuration file: ./work/override_compression_config
2023-03-27 02:01:59 [INFO] [mender-convert-extract] Validating disk image
2023-03-27 02:01:59 [INFO] [mender-convert-extract] Disk parsed successfully
2023-03-27 02:01:59 [INFO] [mender-convert-extract] NUMBER OF PARTS: 2 TYPE: gpt
2023-03-27 02:01:59 [INFO] [mender-convert-extract] PART 1: SIZE: 1.1G TYPE: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
2023-03-27 02:01:59 [INFO] [mender-convert-extract] PART 1: extracting to work/part-1.fs
2023-03-27 02:02:02 [DEBUG] [mender-convert-extract] Running: (modules/disk.sh:63): run_and_log_cmd():  

	dd if=input/golden-image-1.img of=work/part-1.fs skip=2048 bs=512 count=2201600 conv=sparse status=none
2023-03-27 02:02:02 [INFO] [mender-convert-extract] PART 2: SIZE: 6G TYPE: 0fc63daf-8483-4772-8e79-3d69d8477de4
2023-03-27 02:02:02 [INFO] [mender-convert-extract] PART 2: extracting to work/part-2.fs
2023-03-27 02:02:31 [DEBUG] [mender-convert-extract] Running: (modules/disk.sh:63): run_and_log_cmd():  

	dd if=input/golden-image-1.img of=work/part-2.fs skip=2203648 bs=512 count=12582879 conv=sparse status=none
2023-03-27 02:02:31 [INFO] [mender-convert-extract] Extracting boot gap to work/boot-gap.bin
2023-03-27 02:02:31 [DEBUG] [mender-convert-extract] Running: (modules/disk.sh:63): run_and_log_cmd():  

	dd if=input/golden-image-1.img of=work/boot-gap.bin skip=1 bs=512 count=2047 conv=sparse status=none
2023-03-27 02:02:31 [INFO] [mender-convert-modify] Using configuration file: configs/mender_convert_config
2023-03-27 02:02:31 [INFO] [mender-convert-modify] Using configuration file: ./work/override_compression_config
2023-03-27 02:02:31 [ERROR] [mender-convert] mender-convert failed
2023-03-27 02:02:31 [ERROR] [mender-convert] mender-convert exit code: 32

Any suggestions on what is wrong?

So it seems my rootfs partition cannot be mounted. It also cannot be mounted when I replicate the same commands.
I have been able to mount the partition using the

losetup -o 1128267776 /dev/loop20 golden-image-1.img
sudo mount /dev/loop20 mnt
# Can now access the rootfs
sudo umount mnt
sudo losetup -d /dev/loop20

My golden image was built on a 500GB nvme drive with only the 1G /boot and 6G / partitions. I had to use gdisk to rebuild the partition table after I copied it off using dd with conv=fdatasync,sparse to remove size errors from the golden image.

I reinstalled ubuntu-server onto a 8GB usb stick, then copied it off. This image which allowed dd to run over the entire length of the block device works as expected. Not sure if there is a fix if using a target device which is much larger than the partitions.

1 Like