Thursday, March 22, 2018

Thoughts on creating a large iso using dd

Let's see if I can avoid being long winded as usual:

So I wanted to create a .iso file that was going to be treated like a disk (more of that part in a future thread). Nothing better to do the deed but that old friend, dd:

raub@desktop:/export/scratch$ dd if=/dev/zero of=olddrive.iso bs=44G count=1
dd: memory exhausted by input buffer of size 47244640256 bytes (44 GiB)
raub@desktop:/export/scratch$

It so happens that dd is trying to create a 44G file by first allocating that in the RAM. And that will not work for me as I only have 32G total of memory.

The solution is rather obvious if you stop to think about it (which, I must admit, I did not): just don't use all the RAM! Instead, use smaller chunks and repeat that a lot. How about 1G chunks 44 times?

raub@desktop:/export/scratch$ dd if=/dev/zero of=olddrive.iso bs=1G count=44
44+0 records in
44+0 records out
47244640256 bytes (47 GB, 44 GiB) copied, 354.018 s, 133 MB/s
raub@desktop:/export/scratch$

Much better!

No comments: