Hacker News new | past | comments | ask | show | jobs | submit login

Dd is the only tool I know to make sparse disk images.

Eg:

Dd if=/dev/zero of=image.img bs=1k count=1 seek=999999

Will give you a 1gb file of zeros that takes up 1kb of disk space until you start to write to it, at which point it will transparently “expand on write”.




There's probably a way to do that with fallocate, I see it has a -d option to make "the file sparse in-place, without using extra disk space".


    truncate -s 1g image.img
Or fallocate if you want it to complete instantly without disk writes but still allocate the space.


But you could use truncate to create the file.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: