How to quickly and easily simulate a low disk space scenario

It turns out that the built in fsutil OS utility can quickly create an empty file of any size.  For example: fsutil file createnew test.txt 1300000000 Will create a file 100 billion bytes in size.

For my scenario I needed to create a low disk space situation on an Always On Availability Group secondary replica.  I created a couple of files that reduced the free space to a few hundred megabytes and then ran a simple query on the primary to do a bunch of large row inserts.  Once the disk space was exhausted and the data file could no longer autogrow, AlwaysOn suspended data movement as expected.  Several alerts were raised including:

C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\CreditLog.ldf: Operating system error 112(There is not enough space on the disk.) encountered.

I corrected the low disk space scenario by deleting the newly-created file.  I then manually resumed data movement.


This entry was posted in Performance, SQL Server and tagged , , . Bookmark the permalink.

Leave a Reply