|
Home > Archive > Unix Programming > May 2007 > How to pre-grow disk file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to pre-grow disk file
|
|
| Andray Kaganovsky 2007-05-02, 7:20 pm |
| Hello,
I would appreciate any advice on the following problem.
I would like to pre-grow file to certain size (few MBytes). I'll
explain what I mean by "pre-grow" by concete example. Let's say
that I have a file that is currently 1 MByte in size, and occupies
250 disk blocks (assuming disk block is 4 KBytes). I would like
to increase the size of this file to 2 MBytes, and extend it by
allocating additional 250 disk blocks to it. I do NOT want to
actually fill these additional 250 disk blocks with any contents;
I simply want them to be allocated, and all file system metadata
updated accordingly.
If case if file system and OS are factors here, I would be using FAT
file system and one of more recent Linux 2.6.x kernels.
Would that actually be possible ?
Thanks in advance and regards,
Andray
| |
| Måns Rullgård 2007-05-02, 7:20 pm |
| Andray Kaganovsky <andrayk@upnorth.com> writes:
> Hello,
>
> I would appreciate any advice on the following problem.
>
> I would like to pre-grow file to certain size (few MBytes). I'll
> explain what I mean by "pre-grow" by concete example. Let's say
> that I have a file that is currently 1 MByte in size, and occupies
> 250 disk blocks (assuming disk block is 4 KBytes). I would like
> to increase the size of this file to 2 MBytes, and extend it by
> allocating additional 250 disk blocks to it. I do NOT want to
> actually fill these additional 250 disk blocks with any contents;
> I simply want them to be allocated, and all file system metadata
> updated accordingly.
>
> If case if file system and OS are factors here, I would be using FAT
> file system and one of more recent Linux 2.6.x kernels.
>
> Would that actually be possible ?
The only way to increase the size of a file on a FAT filesystem is to
write data to it. Some other filesystems, e.g. XFS, have special
operations to allocate blocks without actually writing them.
--
Måns Rullgård
mans@mansr.com
| |
| John W. Krahn 2007-05-02, 7:20 pm |
| Andray Kaganovsky wrote:
>
> I would appreciate any advice on the following problem.
>
> I would like to pre-grow file to certain size (few MBytes). I'll
> explain what I mean by "pre-grow" by concete example. Let's say
> that I have a file that is currently 1 MByte in size, and occupies
> 250 disk blocks (assuming disk block is 4 KBytes). I would like
> to increase the size of this file to 2 MBytes, and extend it by
> allocating additional 250 disk blocks to it. I do NOT want to
> actually fill these additional 250 disk blocks with any contents;
> I simply want them to be allocated, and all file system metadata
> updated accordingly.
>
> If case if file system and OS are factors here, I would be using FAT
> file system and one of more recent Linux 2.6.x kernels.
>
> Would that actually be possible ?
man 2 truncate
Don't know if it will work on a FAT file system or not.
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
| |
| Måns Rullgård 2007-05-02, 7:20 pm |
| "John W. Krahn" <someone@example.com> writes:
> Andray Kaganovsky wrote:
>
> man 2 truncate
>
> Don't know if it will work on a FAT file system or not.
It most likely will not. The truncate system call usually only works
on filesystems supporting sparse files, something FAT does not.
--
Måns Rullgård
mans@mansr.com
|
|
|
|
|