How to generate a large file allocating space

Bruno Wolff III bruno at
Sun Oct 31 15:23:51 UTC 2010

On Sun, Oct 31, 2010 at 11:12:41 +0100,
  Alex Bligh <alex at> wrote:
> I want to generate or extend a large file in an ext4 filesystem allocating
> space (i.e. not creating a sparse file) but not actually writing any data.
> I realise that this will result in the file containing the contents of
> whatever was there on the disk before, which is a possible security problem
> in some circumstances, but it isn't a problem here.

There isn't going to be a way to do that through the file system, because
as you note it is a security problem.

What is the high level thing you are trying to accomplish here? Modifying
the filesystem offline seems risky and maybe there is a safer way to
accomplish your goals.
> Supplementary question: can I assume that if a non-sparse file is on disk
> and never opened, and never unlinked, then the sectors used to to store
> that file's data will never change irrespective of other operations on the
> ext4 filesystem? IE nothing is shuffling where ext4 files are stored.

I think SSDs will move stuff around at a very low level. They would look
like they are at the same place to stuff access the device like a disk,
but physically would be stored in a different hardware location.

With normal disks, you'd only see this if the device got a read error, but
was able to successfully read a marginal sector and remap it to a spare
sector. But again, stuff talking to the disk will see it at the same address.

More information about the Ext3-users mailing list