Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, everyone
As listed in the subject basically I want to create a large file in linux.
Currently I am using this command:
dd if=/dev/zero of=file.txt count=1024 bs=1024
to do that, it can create a file in some GBs like 7, 8 etc but I want to create a large file like 500GB or 1TB.
When I give a large number to the parameters "Count" and "bs"
I am having this error:
DD: Memory Exhausted by Input Buffer of Size Bytes (9Gib)
Can anyone please guide me in this regard. Or suggest me to use any other suitable way. I would be very thankful to you.
#include <stdio.h>
#include <string.h>
#define OUTPUT_SIZE_REQUEST 1000
#define OUTPUT_FILE_NAME cmd_line_arg[1]
int main(int nof_args, char **cmd_line_arg);
int main(int nof_args, char **cmd_line_arg)
{
FILE *text_out;
char *test_text = "This has been a test. \n "
"Had it been an actual alert you would not have received this message.\n";
long int msg_size, total_output = 0; puts(test_text);
if (2==nof_args) ; else { puts ("Supply output file name on command line"); return(1); }
text_out=fopen(OUTPUT_FILE_NAME,"w");
if (NULL==text_out)
{ printf("unable to open %s file for output\n", OUTPUT_FILE_NAME);
return(2); }
else printf("%s file opened for output\n", OUTPUT_FILE_NAME);
msg_size = strlen(test_text);
do { fputs(test_text,text_out);
total_output+=msg_size; }
while (total_output<OUTPUT_SIZE_REQUEST);
printf("%d output characters written\n", total_output);
fclose(text_out);
return(0);
}
Last edited by mike acker; 07-23-2019 at 06:12 AM.
#include <stdio.h>
#include <string.h>
#define OUTPUT_SIZE_REQUEST 1000
#define OUTPUT_FILE_NAME cmd_line_arg[1]
int main(int nof_args, char **cmd_line_arg); // not needed
int main(int nof_args, char **cmd_line_arg)
{
FILE *text_out;
char *test_text = "This has been a test. \n "
"Had it been an actual alert you would not have received this message.\n";
long int msg_size, total_output = 0; puts(test_text);
if (2==nof_args) ; else { puts ("Supply output file name on command line"); return(1); }
text_out=fopen(OUTPUT_FILE_NAME,"w");
if (NULL==text_out)
{ printf("unable to open %s file for output\n", OUTPUT_FILE_NAME);
return(2); }
else printf("%s file opened for output\n", OUTPUT_FILE_NAME);
msg_size = strlen(test_text);
do { fputs(test_text,text_out);
total_output+=msg_size; }
while (total_output<OUTPUT_SIZE_REQUEST);
printf("%d output characters written\n", total_output);
fclose(text_out);
return(0);
}
why did you defind main? that is the only function that I know that does not need to be defined, but has to be included or a program will not work.
which is used for swap files, and is not much different then dd to create the same. Just a crap file that then is assigned to be swap or whatever after being created.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.