Skip to contentSkip to conversation

package/mke2img: always create sparse files

PATCH New Yann E. MORIN 4 participants 4 messages Dec 8, 2014 – Dec 28, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/mke2img: always create sparse files

When the user specifies a number of blocks (and we do not auto-compute them), the generated filesystem can be quite large with large zones with only zeroes in them.

Thus, always create the filesystem as a sparse file.

Sparse files behave the same as normal files, except those long runs of zeroes do not actually use space on the (host) filesystem. Also, this should not break current behaviour, as neither cp nor dd nor cat preserve sparseness by default. So users relying on the zeroed parts to actually be written won;t see a change. Users that were expressly using cp or dd to copy files to a sparse destination will however see a little bit of improvements, as the zeroed out parts won't even be read from disk.

Cc Thomas Petazzoni <[email protected]>
---
 package/mke2img/mke2img | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/mke2img/mke2img +1 -1
index 9c56bc2..b186290 100755
@@ -98,7 +98,7 @@ main() {
     fi
 
     # Generate the filesystem
-    genext2fs_opts=( -b ${nb_blocks} -N ${nb_inodes} -d "${root_dir}" )
+    genext2fs_opts=( -z -b ${nb_blocks} -N ${nb_inodes} -d "${root_dir}" )
     if [ -n "${nb_res_blocks}" ]; then
         genext2fs_opts+=( -m ${nb_res_blocks} )
     fi
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 package/mke2img: always create sparse files

Quoted 14 lines · Yann E. MORIN

When the user specifies a number of blocks (and we do not auto-compute them), the generated filesystem can be quite large with large zones with only zeroes in them.

Thus, always create the filesystem as a sparse file.

Sparse files behave the same as normal files, except those long runs of zeroes do not actually use space on the (host) filesystem. Also, this should not break current behaviour, as neither cp nor dd nor cat preserve sparseness by default. So users relying on the zeroed parts to actually be written won;t see a change. Users that were expressly using cp or dd to copy files to a sparse destination will however see a little bit of improvements, as the zeroed out parts won't even be read from disk.

Quoted 2 lines
Cc Thomas Petazzoni <[email protected]>
Quoted 24 lines
---
 package/mke2img/mke2img | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/mke2img/mke2img +1 -2
index 9c56bc2..b186290 100755
@@ -98,7 +98,7 @@ main() {
     fi
 
     # Generate the filesystem
-    genext2fs_opts=( -b ${nb_blocks} -N ${nb_inodes} -d "${root_dir}" )
+    genext2fs_opts=( -z -b ${nb_blocks} -N ${nb_inodes} -d "${root_dir}" )
     if [ -n "${nb_res_blocks}" ]; then
         genext2fs_opts+=( -m ${nb_res_blocks} )
     fi
--

1.9.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 1 line
Samuel
#2 lore raw

PATCH 1/1 package/mke2img: always create sparse files

Hi Yann, Thomas, Samuel, list,

Quoted 7 lines · Samuel Martin
Quoted 2 lines · Yann E. MORIN
Cc Thomas Petazzoni <[email protected]>

Tested with the same configs as the previous 3 (except w/ kernel 3.18), successfully built different rootfs.ext images and booted them. Tested with master branch, x86_64 arch in QEMU, internal toolchain GCC 4.9.2 w/ uclibc, Linux 3.18.

Regards,
Karoly
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20141209/8698db16/attachment.html>

#3 lore raw

PATCH 1/1 package/mke2img: always create sparse files

In reply to Yann E. MORIN

Dear Yann E. MORIN,

Quoted 14 lines · Yann E. MORIN

When the user specifies a number of blocks (and we do not auto-compute them), the generated filesystem can be quite large with large zones with only zeroes in them.

Thus, always create the filesystem as a sparse file.

Sparse files behave the same as normal files, except those long runs of zeroes do not actually use space on the (host) filesystem. Also, this should not break current behaviour, as neither cp nor dd nor cat preserve sparseness by default. So users relying on the zeroed parts to actually be written won;t see a change. Users that were expressly using cp or dd to copy files to a sparse destination will however see a little bit of improvements, as the zeroed out parts won't even be read from disk.

Quoted 5 lines
Cc Thomas Petazzoni <[email protected]>
---
 package/mke2img/mke2img | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com