0
0
0
s2sdefault

I have recently had an opportunity to work on a very strang issue... My customer was able to transfer small files through a VPN connection, but not large ones. One of the challenges we faced in this was how to get files of a specific file size, to test the limits of that connection. In the end, while a simple command, it took me a little while to figure it out, but I eventually settled on a few variations of a command to get my file sizes.

So we'll be using the dd command to create these "NULL Data" files. In the end, All I needed was a file of 'x' size... I didn't really need any "legitimate" data like a backup, or document or anything like that. So let's see the command, and break it down so we can change it up to suite our needs.

Here's the command to create a file named "500MFile" which would be 500MB in size:

dd if=/dev/zero count=1 bs=500M of=500MFile

Now, let's break it down...

dd - This is the command itself. Typically, it is used to image entire Hard Drives, or Flash Drives... But with some crafty alterations, we can actually use it to create a "NULL Data" file.

if=/dev/zero - 'if' is the "In File" for dd, this is where we are getting the "data" from. Though we want a "NULL" Data file, we can't actually "pull" any data from /dev/null, as that is truly "NULL", so we need to pull data from SOMEWHERE, so we take it from /dev/zero.

count=1 - This is how many times we want it to pull data from 'if'

bs=500M - Here is where we set the file size. We can use G,M,K for file sizes (GB, MB, KB).

of=500MFile - This is the filename we want to create. Since we needed to create several files of varying sizes, I decided to name my files simply what size they were.

Using this command, I have been able to create a file as small as 1KB, all the way up to 10GB. Theoretically, you could as small as 1Byte, and as large as your HDD can hold (Terabytes, Petabytes), I do not think dd itself has an upper limit. The upper limit would be based on the filesystem and hard drive capacity.

 

Add comment


Security code
Refresh

0
0
0
s2sdefault