I'm trying to save disk space with drive images, but all of the examples that I could find involve filling empty space with zeros and compressing the resulting image. Not all programs will work with compressed images, so I'm wondering if I can use the following method to save space with drives that aren't completely used up (due to copying from ISOs or cloning from smaller drives or something).
I have the following drive:
Disk test: 5 MiB, 5242880 bytes, 10240 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x397f74b3
Device Boot Start End Sectors Size ID Type
test1 2048 4095 2048 1M 83 Linux
test2 4096 8191 4096 2M 83 Linux
Can I just dd
the first 8191 * 512 = 4193792 bytes to a file and have a raw image that works the same as the drive?
In general can I just copy the highest ("end sector" * logical sector size) and end up with an equivalent raw image (assuming no hidden data is stored past the partitions)?