1

I use dd for creating an image of my filesystem . I use Debian 8(Jessie) on ARM 32 bit system.

Command I run is :

dd if=/dev/mmcblk0 bs=1M | gzip -c > /mnt/usb/<image_name.gz>

For some reason while my File System took 1.3 GB a file I got is 1.9 GB search on net for answer and the answer that I get agree with it was that dd take all blocks if they didn't filled. How I get to this conclusion I make some experiment : I run these commands :

$ cat /dev/zero > /root/zero.file
$ sync
$ rm /root/zero.file

After these commands I check my system again ( df -h) and saw that now my filesystem took actually 1.9 GB. What is actually dd create for me.

How can I get a file size of my image with 'dd' as close as possible to original size of source code.

  • confused Shouldn't the image be smaller, since you're compressing with gzip? And are you trying to image a live, read-write filesystem? – derobert Nov 3 '17 at 10:22
  • I believe the response to that is: Yes, of course the image should be smaller; that’s why the OP is asking why it is larger. – G-Man Nov 3 '17 at 11:07
  • Sparse files, anybody? df -h is not the best tool to get the size of a file... – Satō Katsura Nov 3 '17 at 11:58
0

Check what your block device is. For simpler filesystems, it may present a true size, but a filesystem can also present to you a virtual "effective" space available for the files, but the raw device itself stores more than that - a journal, checksums, and who knows what else. A device is a raw block, over which your filesystem can do anything it wants - it can do deduplication, encryption, compression, and in these cases, the reported filesystem size is nonsense.

Also, gzip may make the file bigger, if you are compressing something that was already compressed (or if it's filled with truly random data). However, that overhead would be typically smaller than what you see.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.