Created
January 6, 2024 20:58
-
-
Save omer-biz/e428c021ac68a783583e6eb5411f7d13 to your computer and use it in GitHub Desktop.
Fill your disk with random files with random contents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import getopt | |
def usage(): | |
pass | |
# commandline arguments except the file name | |
argv = sys.argv[1:] | |
try: | |
opts, args = getopt.getopt(argv, 's:b:n:p:', ['file size', 'byte frequency', 'number of files', 'file path']) | |
except getopt.GetoptError: | |
usage() | |
# size of each generated file | |
size_file = 1024 * 1024 * 1024 | |
# how many bytes are read at a time | |
byte_count = 1024 | |
# number of files to generate | |
numb_file = 2 # number of files also the size | |
# where to the save the generated files | |
file_path = "./" | |
# the source of the randome bytes | |
source = open('/dev/urandom', 'rb') | |
for i in range(0, numb_file): | |
with open(file_path + 'file' + str(i) + '.txt', 'wb') as _file: | |
for i in range(0, size_file // byte_count): | |
_file.write(source.read(byte_count)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment