Reputation: 1647
I am trying to work more efficiant with sparse files. I have read about the SEEK_HOLE functionallity in newer Linux Kernels. According to other people, this should be in Kernel version 3.1 and later.
However, as seen bellow, there must be something else to it as well. I am on kernel 3.2+ and working with sparse files are still slow.
Doing a "cp" or "tar" on this (completely empty) sparse file should take less than 1 sec.
Any idea what I am missing? How can I check if SEEK_HOLE is supported/activated?
They discuss the same thing here, but for some reason I cannot post comments there that it does not work:
(root@r1)-(/nbd/test)# uname -a
Linux r1.exice.com 3.2.0-33-generic #52-Ubuntu SMP Thu Oct 18 16:29:15 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
(root@r1)-(/nbd/test)# dd if=/dev/zero of=10g.img seek=10G bs=1 count=1
1+0 records in
1+0 records out
1 byte (1 B) copied, 0.000271811 s, 3.7 kB/s
(root@r1)-(/nbd/test)# time cp 10g.img new.img
real 0m15.370s
user 0m1.544s
sys 0m13.405s
(root@r1)-(/nbd/test)# time bsdtar cvfz new.tar.gz 10g.img
a 10g.img
real 1m59.898s
user 1m43.938s
sys 0m15.769s
(root@r1)-(/nbd/test)# time tar cvfz new2.tar.gz 10g.img
10g.img
real 1m58.584s
user 1m51.275s
sys 0m30.382s
Upvotes: 1
Views: 842
Reputation: 1647
Make sure you are using a tool that supports SEEK_HOLE
.
bsdtar >=3.0.4
cp >=8.13
Also make sure you run a filesystem that supports it. Works fine with ext4. Does not work with reiserfs.
Upvotes: 2