1830340 Members
2348 Online
110001 Solutions
New Discussion

testing largefiles

 
SOLVED
Go to solution
Jim Smith
Advisor

testing largefiles

Hi,

is there a way to easily create a massive file so I can test out that largefiles is working on my new lvols ?
5 REPLIES 5
Carol Garrett
Trusted Contributor

Re: testing largefiles


Use the prealloc command. eg. to create a 2.5Gb file to test out if largefiles is on; prealloc testfile 2500000000

If prealloc returns the error; file too large you know you havent got largefiles on.
Stefan Farrelly
Honored Contributor

Re: testing largefiles


Prealloc is the command to use. See man page on it. If will take some time to create such a large file though so be patient.
Im from Palmerston North, New Zealand, but somehow ended up in London...
federico_3
Honored Contributor
Solution

Re: testing largefiles

you can use the prealloc command that preallocates at laeast size bites of disk space for a file.

If the option largefiles is set your system will be able to use files greater than 2GBs and so you should test this fact typing:

prealloc file-test 2100000000

Federico
Jim Smith
Advisor

Re: testing largefiles


Thanks for the fast replies everyone!
Neal Krawetz
New Member

Re: testing largefiles

Hello all,

My problem with prealloc is that it only writes nulls.
Not very good if you're testing compression, encryption, or file transfer stuff.

Here's a program I wrote that generates big files with lots of random characters.
NOTE: It writes to stdout. Be sure to redirect
stdout into a file, otherwise it could screw up
your terminal window. (Lots of random garbage
has a habbit of doing that.)

To compile:
/opt/ansic/bin/cc bigfile.c -o bigfile
or
gcc bigfile.c -o bigfile

To run:
./bigfile 21 M R > /tmp/21meg_file_of_random
./bigfile 21 M > /tmp/21meg_file_of_sequential

===== cut here =====
#include
#include
#define MAXBUF 400000

Usage(Filename)
char *Filename;
{
fprintf(stderr,"Script to write a file of random characters.\n");
fprintf(stderr,"Usage: %s filesize [B|K|M|G] [R]\n",Filename);
fprintf(stderr,"Specify R on the end for random, rather than sequential.\n");
fprintf(stderr,"Example: %s 15 K\n",Filename);
exit(-1);
}

int main(argc,argv)
int argc; char *argv[];
{
long FileSize;
char Scale;
long ScaleNum;
char Buf[MAXBUF];
int BufLen;
int RandomFlag=0;

if (argc < 2) Usage(argv[0]);
if (argc > 4) Usage(argv[0]);
if (argc == 2) Scale='K';
else
{
Scale=argv[2][0];
if (islower(Scale)) Scale=toupper(Scale);
}
FileSize = atol(argv[1]);
if (argv[argc-1][0]=='R') RandomFlag=1;

switch(Scale)
{
case 'K': ScaleNum=1024; break;
case 'M': ScaleNum=1024*1024; break;
case 'G': ScaleNum=1024*1024*1024; break;
default:
Scale='B';
case 'B': ScaleNum=1; break;
}

fprintf(stderr,"Generating file size %ld%c ",FileSize,Scale);
FileSize *= ScaleNum;
fprintf(stderr,"(%ld bytes)\n",FileSize);

/* dump the data */
srand(time(NULL));
BufLen=0;
while(FileSize)
{
if (RandomFlag)
{
fputc(rand()%256,stdout);
Buf[BufLen] = (rand()%256);
}
else
{
Buf[BufLen] = (BufLen%256);
BufLen++;
if (BufLen >= MAXBUF)
{
write(1,Buf,BufLen);
BufLen=0;
}
}
FileSize--;
}

if (BufLen > 0) write(1,Buf,BufLen);
return(0);
}
If you can't say something nice, say what you're thinking nicely.