Skip to main content

How to make a file of an size fast - fsutil file createnew test 1048576

https://stackoverflow.com/questions/982659/quickly-create-large-file-on-a-windows-system

http://technet.microsoft.com/en-us/sysinternals/bb897428.aspx


Asked 
Modified 10 months ago
Viewed 395k times
300

In the same vein as Quickly create a large file on a Linux system, I'd like to quickly create a large file on a Windows system. By large I'm thinking 5 GB. The content doesn't matter. A built-in command or short batch file would be preferable, but I'll accept an application if there are no other easy ways.

24 Answers

487
fsutil file createnew <filename> <length>

where <length> is in bytes.

For example, to create a 1MB (Windows MB or MiB) file named 'test', this code can be used.

fsutil file createnew test 1048576

fsutil requires administrative privileges though.

  • 6
    @ZXX +1 For my purposes I merely needed the file system to see the space as unavailable, but your information is helpful if someone else needs this.  Dec 22, 2010 at 13:50
  • 24
    fsutil file createnew does not create a sparse file.  Jun 30, 2013 at 17:58
  • 10
    "fsutil sparse setflag temp.txt" sets the sparse flag, making it a sparse file. "fsutil sparse setrange temp.txt 0 1024" sets the range of sparseness :)  May 10, 2014 at 21:53
  • 3
    @ZXX fsutil file createnew does NOT create sparse files: c:\>fsutil file createnew test.txt 0x100000 File c:\test.txt is created c:\>fsutil sparse queryflag test.txt This file is NOT set as sparse  Oct 20, 2017 at 6:29 
  • 4
    This might not technically be a sparse file, but creating a 500GB file takes less than a second (even on a somewhat faulty hard disk). If you want to actually trigger 500GB of disk IO (like I do), this command isn't it.  Oct 5, 2018 at 7:43 
39

You can use the Sysinternals Contig tool. It has a -n switch which creates a new file of a given size. Unlike fsutil, it doesn't require administrative privileges.

Comments

Popular posts from this blog

Clearing DNS cache on vCenter Server Appliance

How to step by step in detail install ssh on cachyos