Hard disk images are simple in Unix. Just use the dd command.
dd if=/dev/sda of=./sda.img
However, if you are going to transport the image, either downloading or something, it is good to make it as small as possible. xz, pbzip2, bzip2 or even the old standby, gzip, work well for this.
However, to make the image as small as possible, it is good to overwrite unused space on the image with zeros. If the file system is mounted (and can be filled up with no issues), simply create a file full of zeros until you run out of space, then delete the file.
dd if=/dev/zero of=/opt/deleteme ; rm /opt/deleteme
When dd is done, it will error out after not being able to write any more, then you just delete the file you created, leaving a disk full of empty space with 0's written in it. Nothing magical about 0's, you could use 1's. As long as they are the same.
get partition offset fdisk -lu image.file Calculate offset to partition as sector_size*Start losetup -o size_from_above /dev/loop0 image.file e2fsck -f /dev/loop0 mount /dev/loop0 /mnt dd if=/dev/zero of=/mnt/deleteme rm /mnt/deleteme umount /mnt losetup -d /dev/loop0 xz -v image.file