How to Create a Test File of Any Size in Linux

Written By
T
TecMint
Jun 2, 2026

You need a 1GB test file to benchmark your disk, fill a partition to a specific threshold, or simulate a large log file, and the touch command gives you a zero-byte stub that’s useless for any of those jobs. The 2 tools that actually do this are dd and fallocate, and most people either don’t know both exist or don’t know which one to reach for.

They solve the same problem in completely different ways, and the difference matters depending on what you’re trying to do.

dd command writes actual data byte by byte, so the file is fully written to disk before you get your prompt back.
fallocate tells the filesystem to reserve the space without writing any data at all, which makes it near-instant even for files measured in gigabytes.

T

TecMint

Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.