On Thu, Nov 11, 2010 at 1:42 PM, Tha.Suresh <[email protected]> wrote:
> Create a file of a given size in linux
>
> $ truncate -s 10M file
>
> if the fs support sparse file,using truncate can create sparse file.
>
> more info:
>
> http://en.wikipedia.org/wiki/Sparse_file
>
> $ man truncate
>

It is very useful in virtualization?

qemu for instance.

$ qemu-img create filestore.bin 40G

I can only see truncate(2) in section 2 of the man page in OpenBSD.

Too bad.TRUNCATE(2)               OpenBSD Programmer's Manual
    TRUNCATE(2)

NAME
     truncate, ftruncate - truncate or extend a file to a specified length

SYNOPSIS
     #include <unistd.h>

     int
     truncate(const char *path, off_t length);

     int
     ftruncate(int fd, off_t length);

DESCRIPTION
     truncate() causes the file named by path or referenced by fd to be
     truncated or extended to length bytes in size.  If the file was larger
     than this size, the extra data is lost.  If the file was smaller than
     this size, it will be extended as if by writing bytes with the value
     zero.  With ftruncate(), the file must be open for writing.

-Girish
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to