I am working on development of device working on embedded linux. When working with new hardware versions of it, when I mess up, I have an image that I can copy using dd to SD card, boot from it, and dd it it to internal eMMC storage.
As the image for old HW is lost, I'm trying to create a new backup image and I would like it to be as small as possible, but as dd is doing it block-by-block and it doesn't matter if there is anything or not on the block it will copy it anyway, so I need full device copied. Internal storage is about 4GB (ext4) and the files are less then 200MB...
I know I can use dd if=/dev/source-device of=image | tar ... but I would prefer to make rather something like dd if=/dev/source-device of=image bs=1M count=300 but to do this I have to make sure my data is in first 300MB.
This brings me two questions:
1) How to check if data is in first 300MB of disk?
2) if data is not there how to make it move to beginning of disk?