Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Sep 2017 09:31:58 +0200
From:      Ben RUBSON <ben.rubson@gmail.com>
To:        Freebsd fs <freebsd-fs@freebsd.org>
Subject:   Re: How to create holes in files ?
Message-ID:  <7E8BB109-C72C-4B5D-A2EF-630C6B34D8E6@gmail.com>
In-Reply-To: <20170929080823.175d6abc@raksha.tavi.co.uk>
References:  <12ed413d-00d1-4182-bdd5-0e5230d46f01@email.android.com> <4D304428-E4AF-45D4-AB2E-D4B73A7FEE87@gmail.com> <1506664468.7204.37.camel@inparadise.se> <454261D6-0061-4DB9-8184-BDD7061870FB@gmail.com> <20170929080823.175d6abc@raksha.tavi.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help

> On 29 Sep 2017, at 09:08, Bob Eager <rde@tavi.co.uk> wrote:
> 
> On Fri, 29 Sep 2017 08:26:13 +0200
> Ben RUBSON <ben.rubson@gmail.com> wrote:
> 
>> Unfortunately here storage blocks will be set/written to 0,
>> they will not be freed/recovered, a file hole will not be created.
> 
> You need to add:  conv=sparse    to the dd command to turn zero blocks
> into unallocated blocks.

You're right Bob it works :

# dd if=/dev/random of=f bs=1M count=4
4+0 records out

# zfs userspace home
POSIX User  root  4.04M   none

# dd if=/dev/zero of=f bs=1M count=2 seek=2 conv=sparse
2+0 records out


# zfs userspace home
POSIX User  root  2.04M   none

# ls -lh f
-rw-------  1 root  wheel   4.0M 29 Sep 09:25 f


Unfortunately, using "conv=notrunc,sparse" to make a hole in the middle
of a file does not seem to work, file is truncated :

# rm f

# dd if=/dev/random of=f bs=1M count=4
4+0 records out

# dd if=/dev/zero of=f bs=1M count=1 seek=2 conv=notrunc,sparse
1+0 records out

# ls -lh f
-rw-------  1 root  wheel   3.0M 29 Sep 09:26 f

# zfs userspace home
POSIX User  root  3.04M   none


Anyway thank you for this tip, this is something to analyse !

Ben




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7E8BB109-C72C-4B5D-A2EF-630C6B34D8E6>