How to use mksparse to preserve partitions

Hi,

I have a jetson disk image ( usb-image.img ) with is 64GiB but actual data it contains is only 24Gib and it has 14 partitions(APP, kernel etc.) which allows a user to boot from USB.
If I use dd to write this image, it takes lot of time copying all 64Gib bytes of data, although what I really want is to copy just 24GiB data excluding unused data.

sudo dd if=usb-image.img of=/dev/$usb_device bs=512K conv=sparse status=progress

To make the disk-image.img sparse, I used ./mksparse tool to create a sparse image out of raw image. However, when I flashed the spare-image.img to usb device, the partitions are not preserved.

sudo dd if=sparse-image.img of=/dev/$usb_device bs=512K status=progress

How can I preseve these partitions or which is the right tool to do this ? I just want to have a disk image of size of data which is in use and copy only that amount of data to the USB.

Thanks !

Hi,
We have the method in developer guide:

https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3274/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/flashing.html#wwpID0E0HO0HA

Please refer to it and give it a try.

Hi,

In this method you mentioned, the USB needs to be attached to the host PC. This may not be possible in my use case. I want to generate a disk image (.img or .iso) for the USB which can be directly flashed to the USB simply by downloading.
I want to make the .img sparse, so that the unused space is not present in the final sparse image and it can accomodate within a 32GB USB stick as my content size is below that.

I want to add that mksparse only applies to ext4 filesystem partitions. Only the rootfs can use this. An image which includes other partitions cannot use this (binary partitions more or less don’t have empty space; if they have something empty, then it is intentional padding for size requirements).

Also, for an ext4 filesystem, then you’d use a NULL filler byte. I’m not sure if the dd version of mksparse works the same as the Jetson version, at least prior to L4T R36.x.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.