public inbox for linux-newbie@vger.kernel.org
 help / color / mirror / Atom feed
* allocating disk space the fast way
@ 2006-08-05 17:43 Mensch
  2006-08-05 18:06 ` Mensch
  2006-10-14 17:35 ` Eric Bambach
  0 siblings, 2 replies; 3+ messages in thread
From: Mensch @ 2006-08-05 17:43 UTC (permalink / raw)
  To: linux-newbie list

hello list.
i want to allocate some space for a harddisk image file.
for now, i do it like
$ dd if=/dev/zero of=blub.img bs=1M count=2000
which takes some time. is there a faster way to create a huge file? it
don't have to be zeroed.
i've seen that e.g. azureus allocates filesize in no time. how does this
work?

thanks in advance,
josef gosch

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: allocating disk space the fast way
  2006-08-05 17:43 allocating disk space the fast way Mensch
@ 2006-08-05 18:06 ` Mensch
  2006-10-14 17:35 ` Eric Bambach
  1 sibling, 0 replies; 3+ messages in thread
From: Mensch @ 2006-08-05 18:06 UTC (permalink / raw)
  To: linux-newbie list

it's me again.
i'm sorry, but i found a way myself.

written in c:

/*** START OF filesize_alloc.c ***/

#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <linux/unistd.h>
#include <errno.h>

int main(int argc, char **argv) {
	FILE *newfile;
	char *filename = "blub.img";
	int size_in_bytes = 2000*(1024*1024); /* 2000 MB */

	 /* create a new file char *filename or overwrite it */
	newfile = fopen(filename, "w");
	 /* now jump to byte int size_in_bytes from start... */
	fseek(newfile, size_in_bytes, SEEK_SET);
	 /* ... and write a final zero at this position */
	fwrite("\0", 1, 1, newfile); 
	fclose(newfile);
}

/*** END OF filesize_alloc.c ***/

Am Samstag, den 05.08.2006, 17:43 +0000 schrieb Mensch:
> hello list.
> i want to allocate some space for a harddisk image file.
> for now, i do it like
> $ dd if=/dev/zero of=blub.img bs=1M count=2000
> which takes some time. is there a faster way to create a huge file? it
> don't have to be zeroed.
> i've seen that e.g. azureus allocates filesize in no time. how does this
> work?
> 
> thanks in advance,
> josef gosch

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: allocating disk space the fast way
  2006-08-05 17:43 allocating disk space the fast way Mensch
  2006-08-05 18:06 ` Mensch
@ 2006-10-14 17:35 ` Eric Bambach
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Bambach @ 2006-10-14 17:35 UTC (permalink / raw)
  To: Mensch; +Cc: linux-newbie list

On Saturday 05 August 2006 12:43, Mensch wrote:
> hello list.
> i want to allocate some space for a harddisk image file.
> for now, i do it like
> $ dd if=/dev/zero of=blub.img bs=1M count=2000
> which takes some time. is there a faster way to create a huge file? it
> don't have to be zeroed.
> i've seen that e.g. azureus allocates filesize in no time. how does this
> work?
>
> thanks in advance,
> josef gosch
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs

I know you already found an answer....but....

Make it sparse.

dd if=/dev/zero of=./my.image bs=1M seek=2048 count=1

-- 
Thanks,

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-10-14 17:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-05 17:43 allocating disk space the fast way Mensch
2006-08-05 18:06 ` Mensch
2006-10-14 17:35 ` Eric Bambach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox