A sparse file is a file where only the non-zero data are stored in data blocks and all zero-data are generated by the filesystem when the file is read. As such, the sparse file uses disk space efficiently by storing only metadata about the zeros, rather than storing the zeros physically on storage. When the sparse file is later read, the filesystem generates the zeros dynamically.
Questions tagged [sparse-file]
62 questions
3
votes
2 answers
Parse Server - How to delete image file from the server using cloud code
How can I delete an image's file from the server using Parse Cloud Code. I am using back4app.com
After Deleting Image Row
I am getting the images urls, then calling a function to delete the image using its url
Parse.Cloud.afterDelete("Image",…

Hatim
- 1,516
- 1
- 18
- 30
3
votes
1 answer
Get the actual file size vs apparent size in GO
"fs.sys.Size" (fs being fileStat in the os package) returns the apparent size of a file. This isn't ideal when dealing with sparse files.
Is there a way to get the actual file size in GO? Or all applications are bound to get the converted metadata…

Amir Keibi
- 1,991
- 28
- 45
3
votes
1 answer
Can "sparse zero" be set to the value other than (BYTE)0x00, really?
If I understood the text correctly, Platform SDK contains an innuendo what it can:
The default data value of a sparse file is zero; however, it can be
set to other values.
However, combing thru related text gave me absolutely no signs of…

OnTheFly
- 2,059
- 5
- 26
- 61
2
votes
1 answer
android - pre-allocate space for a file before downloading it
how can i create a pre-allocated file on android? something like a sparse file ?
i need to make an applicaton that will download a large file , and i want to avoid having an out-of-space error while the download is commencing . my solution needs to…

android developer
- 114,585
- 152
- 739
- 1,270
2
votes
0 answers
Is it possible to create a >8 EiB sparse file anywhere?
Background: as part of trying to ensure complete coverage in my unit tests, I'm stress-testing some overflow checks.
So, I tried to create a 16 EiB sparse file.
However, on Linux/Btrfs this seems to fail at 8 EiB (2^63 bytes) rather than 16 EiB…

o11c
- 15,265
- 4
- 50
- 75
2
votes
1 answer
Why and how does Linux kernel create a sparse file for the coredump?
Currently I'm working on Linux 4.0.6. After a coredump activation, I observe that the generated corefiles is created as sparse files.
For example, the ls command shows the size of my corefile is 42 MB. However, the du command shows that it…

ywiyogo
- 738
- 2
- 7
- 21
2
votes
2 answers
numpy.memmap: bogus memory allocation
I have a python3 script that operates with numpy.memmap arrays. It writes an array to newly generated temporary file that is located in /tmp:
import numpy, tempfile
size = 2 ** 37 * 10
tmp = tempfile.NamedTemporaryFile('w+')
array =…

Roman
- 2,225
- 5
- 26
- 55
2
votes
1 answer
Why would a program want/prefer to use a sparse file?
I know what sparse file is but I can't figure out how or why a program such as lastlog would prefer such a file over a normal file.
I know sparse files can be used for loop back filesystems to save space but that is obviously not efficient for a…

Adam Gent
- 47,843
- 23
- 153
- 203
2
votes
3 answers
Is there a Java equivalent of GetCompressedFileSize?
I am looking to get accurate (i.e. the real size on disk and not the normal size that includes all the 0's) measurements of sparse files in Java.
In C++ on Windows one would use GetCompressedFileSize. I have yet to come across how one would go about…

J C
- 73
- 10
1
vote
1 answer
Avoid fragmentation while writing on a sparse file by allocating space upfront
I've an application which writes a single file of size 1 TB on a NTFS volume. The writes to this are not done sequentially. There are multiple threads which writes to different offset of the file. It is guaranteed that all the regions in file will…

Kanak
- 13
- 2
1
vote
1 answer
What is the equivalent of `posix_fallocate()` on Windows?
NTFS does support sparse files, but I want to make sure the files I have to write to (which might have been created, set as sparse, and partially filled by another application) are fully allocated, so that I won't get an error due to lack of space…

lvella
- 12,754
- 11
- 54
- 106
1
vote
0 answers
How do I upload qcow2 images to libvirt storage using the API and keep compression?
Using the libvirt-python module, I tried creating the volume with XML using the information provided from the output of qemu-img info. Then I upload using a stream. This works and the disk is functional, but libvirt allocates the physical size equal…

dcode
- 33
- 7
1
vote
1 answer
Build bigsparser::SFBM matrix iteratively
I wish to build a matrix with 10^7 columns and 2500 rows. Since this is too large for my computer, I thought I could create the matrix iteratively. I would like to use the bigsparser package for storing the matrix on disk.
Here is how I create the…

Karsten W.
- 17,826
- 11
- 69
- 103
1
vote
1 answer
How to delete content in sparse files?
I'm writing a program, which write some contents in a sparse file.
Say, I create the file by
fd = open(filepath, O_RDWR | O_CREAT | O_EXCL, 0644);
assert(fd != -1);
int s = ftruncate(fd, len);
len is very large, but the actual content may only…

AetX
- 193
- 6
1
vote
1 answer
Does DeviceIoControl(FSCTL_QUERY_ALLOCATED_RANGES) guarantees order and (no intersection) of returned ranges?
I am looking at the code copying a sparse file (to another sparse file), it uses DeviceIoControl(... FSCTL_QUERY_ALLOCATED_RANGES ...) to get a list of ranges containing actual data.
Is it guaranteed that result contains ranges that:
don't…

C.M.
- 3,071
- 1
- 14
- 33