Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I simulate a disk full error in a Windows environment?

I have to write a bat script for a test scenario where the software that we are testing fails to write to file due to a disk full error. The test script must be automated, so that we can run it on overnight tests, for example. The test script must also work at different computers, so installing a software like a virtual machine wouldn't be the best solution in this case.

How can I simulate that error in a Windows environment?

like image 845
Alceu Costa Avatar asked Feb 09 '09 15:02

Alceu Costa


People also ask

Why is C drive full in Windows 10?

Press Windows key+R together, type %temp%, select all and delete them. Then go to C drive, right click->properties->general->disk cleanup->clean up system files->select temporary files and delete them. Lastly, open settings->system->storage->configure storage sense->clean now. That should do the trick.


2 Answers

You could try writing to a full floppy disk.

Edit:

In light of your edited question, you could set up a network share with no disk space quota and write to that. The error will then be produced regardless of the logged on user or machine.

like image 167
Patrick McDonald Avatar answered Sep 21 '22 06:09

Patrick McDonald


For Windows XP or later:

This command can get the amount of free space for the c:\ drive:

for /f "usebackq tokens=1-5" %%A in (`dir c:\ ^| find "bytes free"`) do (
    set FREE_SPACE=%%C
)

Replace c:\ with your drive, as needed.

You can then take some space away from this value so you have a little room to work with:

set /a FREE_SPACE=FREE_SPACE-1024

or however much space you want to keep free.

You can use the fsutil command to create a file to fill up the free space on the disk:

fsutil file createnew c:\spacehog.dat %FREE_SPACE%

Run your test, writing to the drive. After you write 1024 bytes or so you should run out of space.

like image 25
Patrick Cuff Avatar answered Sep 22 '22 06:09

Patrick Cuff