Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quickly create large file on a Windows system

People also ask

How do I make a large file on Windows?

Open up Windows Task Manager, find the biggest process you have running right click, and click on Create dump file . This will create a file relative to the size of the process in memory in your temporary folder. You can easily create a file sized in gigabytes.

How do I make a large dummy file?

There are two commands you can enter in the Command Prompt to create a dummy file: fsutil file createnew filename size. fsutil file createnew pathfilename size.

How do you create a file?

How do I create a file on a computer? Right click anywhere on your desktop or inside an Explorer window, then highlight New. Select the new file type you want, and click it. If you want to create a new file of a type not included in this list, you'll have to create it from within the program you're using.


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.


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.


I was searching for a way to generate large files with data, not just sparse file. Came across the below technique:

If you want to create a file with real data then you can use the below command line script.

echo "This is just a sample line appended to create a big file.. " > dummy.txt
for /L %i in (1,1,14) do type dummy.txt >> dummy.txt

(Run the above two commands one after another or you can add them to a batch file.)

The above commands create a 1 MB file dummy.txt within few seconds...


Check out RDFC http://www.bertel.de/software/rdfc/index-en.html

RDFC is probably not the fastest, but it does allocate data blocks. The absolutely fastest would have to use lower level API to just obtain cluster chains and put them into MFT without writing data.

Beware that there's no silver bullet here - if "creation" returns instantly that means you got a sparse file which just fakes a large file, but you won't get data blocks/chains till you write into it. If you just read is you'd get very fast zeros which could make you believe that your drive all of the sudden got blazingly fast :-)


Check the Windows Server 2003 Resource Kit Tools. There is a utility called Creatfil.

 CREATFIL.EXE
 -? : This message
 -FileName -- name of the new file
 -FileSize -- size of file in KBytes, default is 1024 KBytes

It is the similar to mkfile on Solaris.


I needed a regular 10 GB file for testing, so I couldn't use fsutil because it creates sparse files (thanks @ZXX).

@echo off

:: Create file with 2 bytes
echo.>file-big.txt

:: Expand to 1 KB
for /L %%i in (1, 1, 9) do type file-big.txt>>file-big.txt

:: Expand to 1 MB
for /L %%i in (1, 1, 10) do type file-big.txt>>file-big.txt

:: Expand to 1 GB
for /L %%i in (1, 1, 10) do type file-big.txt>>file-big.txt

:: Expand to 4 GB
del file-4gb.txt
for /L %%i in (1, 1, 4) do type file-big.txt>>file-4gb.txt

del file-big.txt

I wanted to create a 10 GB file, but for some reason it only showed up as 4 GB, so I wanted to be safe and stopped at 4 GB. If you really want to be sure your file will be handled properly by the operating system and other applications, stop expanding it at 1 GB.