0

I want to create a file, and write endless data to it until the disk is full.

how can i do it from the command line?

thought about something like:

copy con somefile.dat
dir/s (or somthing else, endless) | somefile.dat

(windows powershell commands are also welcomed)

yossi
  • 283

2 Answers2

2

Open Powershell and enter the following cmdlets and commands:

### Get C drive remaining free space
[uint64]$a = Get-Volume | Where DriveLetter -eq "C" | Select -ExpandProperty SizeRemaining
# Create a new file with its size equals to the free space
fsutil file createnew test.txt $a

This assumes that you are creating the file on C drive. Change it to another drive letter if necessary.

1

Echoing to a file in an infinite loop will (in the end) fill the disk completely.

@echo off
:loop
echo 1 >> c:\file
goto loop

This does in theory answer your question, but it has no real world use cases as it will probably take days to fill an average disk with it. The Powershell script proposed by Reddy Lutonadio is instant and therefore better.

I made this script just to demonstrate that it is possible by just using batch.

Shifty
  • 399