Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partitioning: back to classic dd /dev/zero to prepare $SDCARD.raw #4857

Closed

Conversation

rpardini
Copy link
Member

partitioning: back to classic dd /dev/zero to prepare $SDCARD.raw

  • maybe (?) fixes problems with double-sparse when truncate is used on a zfs under Docker

reported by @adeepn -- on Docker using zfs

draft: no idea if this fixes it at all, just a guess

…; maybe (?) fixes problems with double-sparse when `truncate` is used on a `zfs` under Docker
@rpardini rpardini added the Work in progress Unfinished / work in progress label Feb 23, 2023
@adeepn
Copy link
Member

adeepn commented Feb 26, 2023

seems truncate return success.

[🐳|🌱] Preparing image file for rootfs [ jethubj100 jammy ]
[🐳|🐛] calculated rootpart [ rootpart: 1 ]
[🐳|🌱] Current rootfs size [ 1177 MiB ]
[🐳|🌱] Creating blank image for rootfs [ truncate: 1696 MiB ]
[🐳|🐛] wait_for_disk_sync: after truncate SDCARD.raw [ sync start, timeout_seconds:30 ]
[🐳|🐛] wait_for_disk_sync: after truncate SDCARD.raw [ sync done worked: 1 sync_timeout: 0 ]

...

[🐳|🦋]  [ </prepare_partitions> in 0s ]
[🐳|🦋]  [ <create_image_from_sdcard_rootfs> ]
[🐳|🌿] Copying files via rsync to [ / (MOUNT root) ]
[🐳|🔨]   rsync: [receiver] write failed on "/armbian/.tmp/mount-b15eefaa-e641-41f2-b57e-9a3def204909/usr/share/perl/5.34.0/TAP/Parser/Scheduler/Job.pm": No space left on device (28)
[🐳|🔨]   rsync error: error in file IO (code 11) at receiver.c(378) [receiver=3.2.3]
[🐳|🔨]   rsync: [sender] write error: Broken pipe (32)
[🐳|💥] Error 11 occurred in main shell [ at /armbian/lib/functions/logging/runners.sh:190
    run_host_command_logged_raw() --> lib/functions/logging/runners.sh:190
        run_host_command_logged() --> lib/functions/logging/runners.sh:172
   create_image_from_sdcard_rootfs() --> lib/functions/image/rootfs-to-image.sh:22
                do_with_logging() --> lib/functions/logging/section-logging.sh:72
         build_rootfs_and_image() --> lib/functions/main/rootfs-image.sh:61
   full_build_packages_rootfs_and_image() --> lib/functions/main/default-build.sh:10
          do_with_default_build() --> lib/functions/main/default-build.sh:17
         cli_standard_build_run() --> lib/functions/cli/cli-build.sh:17
        armbian_cli_run_command() --> lib/functions/cli/utils-cli.sh:126
                 cli_entrypoint() --> lib/functions/cli/entrypoint.sh:164
                           main() --> compile.sh:52
 ]
[🐳|💥] Cleaning up [ please wait for cleanups to finish ]

@rpardini
Copy link
Member Author

Yes -- truncate returns success, produces a sparse file (on a sparse zfs pool) which then later fails when mounted loop.
This patch changes to use dd with /dev/zero instead of truncate -- possibly not-hitting the double-sparse bug...
Can you test with the patch?

@adeepn
Copy link
Member

adeepn commented Feb 27, 2023

Yes -- truncate returns success, produces a sparse file (on a sparse zfs pool) which then later fails when mounted loop. This patch changes to use dd with /dev/zero instead of truncate -- possibly not-hitting the double-sparse bug... Can you test with the patch?

This is the result of the test of this patch :)
Once again, the patch conditions the truncate call to be successful. And it is always successful, even on zfs. The problem comes later, when trying to copy the files to a mounted image.

P.S. with fallocate same result. we need to go deeper in debug :)
P.P.S. ooh. i skipped FAST_CREATE_IMAGE ) with dd all ok. so i can use FAST_CREATE_IMAGE=no and this patch ok.

@adeepn
Copy link
Member

adeepn commented Feb 27, 2023

And we need to update config/sources/common.conf:

export FAST_CREATE_IMAGE='yes'

to

[[ -z $FAST_CREATE_IMAGE ]] && export FAST_CREATE_IMAGE='yes'

@adeepn
Copy link
Member

adeepn commented Feb 27, 2023

Ok. this does not help.

[🐳|🌱] Current rootfs size [ 1154 MiB ]
[🐳|🌱] Creating blank image for rootfs [ truncate: 1668 MiB ]
[ .... ] dd: 1.63GiB [ 151MiB/s] [==========================================================================================================================================================================>] 100%
[🐳|🐛] wait_for_disk_sync: after truncate SDCARD.raw [ sync start, timeout_seconds:30 ]
[🐳|🐛] wait_for_disk_sync: after truncate SDCARD.raw [ sync done worked: 1 sync_timeout: 0 ]
[🐳|🌱] Creating partitions [ root: ext4 ]

...

[🐳|🦋]  [ <create_image_from_sdcard_rootfs> ]
[🐳|🌿] Copying files via rsync to [ / (MOUNT root) ]
[🐳|🔨]   rsync: [receiver] write failed on "/armbian/.tmp/mount-f5aa0ad8-6950-486f-859f-deaa74ea6d90/usr/share/perl/5.34.0/IO/Uncompress/Bunzip2.pm": No space left on device (28)
[🐳|🔨]   rsync error: error in file IO (code 11) at receiver.c(378) [receiver=3.2.3]
[🐳|🔨]   rsync: [sender] write error: Broken pipe (32)
[🐳|💥] Error 11 occurred in main shell [ at /armbian/lib/functions/logging/runners.sh:190
    run_host_command_logged_raw() --> lib/functions/logging/runners.sh:190
        run_host_command_logged() --> lib/functions/logging/runners.sh:172
   create_image_from_sdcard_rootfs() --> lib/functions/image/rootfs-to-image.sh:22
                do_with_logging() --> lib/functions/logging/section-logging.sh:72
         build_rootfs_and_image() --> lib/functions/main/rootfs-image.sh:61
   full_build_packages_rootfs_and_image() --> lib/functions/main/default-build.sh:10
          do_with_default_build() --> lib/functions/main/default-build.sh:17
         cli_standard_build_run() --> lib/functions/cli/cli-build.sh:17
        armbian_cli_run_command() --> lib/functions/cli/utils-cli.sh:126
                 cli_entrypoint() --> lib/functions/cli/entrypoint.sh:164
                           main() --> compile.sh:52
 ]
[🐳|💥] Cleaning up [ please wait for cleanups to finish ]

On next build i insert du:
Size:
1.8G /armbian/.tmp/rootfs-00a8ff22-5e67-4d91-9da2-eda52092dbf0
but it create image with size 2.2Gb. I did't know what's different between builds

@rpardini
Copy link
Member Author

This is... very puzzling. I am trying to obtain a zfs + docker-with-zfs machine so I can reproduce and not pester you for tests...

@adeepn
Copy link
Member

adeepn commented Feb 27, 2023

This is... very puzzling. I am trying to obtain a zfs + docker-with-zfs machine so I can reproduce and not pester you for tests...

ok. i found.

turn off tmpfs and got:

1.2G	/armbian/.tmp/rootfs-ea0c2fab-2150-45fa-9f76-f027dd397e39
1.2G	total

Filesystem                                                                                                Size  Used Avail Use% Mounted on
...
tmpfs                                                                                                      31G  3.0M   31G   1% /armbian/.tmp/logs-ea0c2fab-2150-45fa-9f76-f027dd397e39
tmpfs                                                                                                      31G  1.4M   31G   1% /armbian/.tmp/work-ea0c2fab-2150-45fa-9f76-f027dd397e39
/dev/loop0p1                                                                                              1.5G   24K  1.5G   1% /armbian/.tmp/mount-ea0c2fab-2150-45fa-9f76-f027dd397e39 

[🐳|🔨]   rsync: [receiver] write failed on "/armbian/.tmp/mount-ea0c2fab-2150-45fa-9f76-f027dd397e39/usr/share/perl/5.34.0/IO/Uncompress/Bunzip2.pm": No space left on device (28)

with tmpfs on:

1.8G	/armbian/.tmp/rootfs-291c451b-0180-481e-b460-78b78548a031
1.8G	total

/dev/loop0p1                                                                                              2.2G   24K  2.2G   1% /armbian/.tmp/mount-291c451b-0180-481e-b460-78b78548a031 
[🐳|🔨]   
[🐳|🔨]   sent 1.73G bytes  received 829.60K bytes  494.04M bytes/sec
[🐳|🔨]   total size is 1.73G  speedup is 1.00
[🐳|🌿] Copying files to [ /boot (MOUNT /boot) ]
[🐳|🔨]   
[🐳|🔨]   sent 36.13M bytes  received 1.77K bytes  72.27M bytes/sec
[🐳|🔨]   total size is 36.12M  speedup is 1.00

@rpardini
Copy link
Member Author

Not sure I follow. tmpfs should only be used as backing for $SDCARD ("rootfs-" mount point), and for the logs & work dir -- but should not be involved in either the .raw file or the $MOUNT... what am I missing?

@adeepn
Copy link
Member

adeepn commented Feb 27, 2023

Not sure I follow. tmpfs should only be used as backing for $SDCARD ("rootfs-" mount point), and for the logs & work dir -- but should not be involved in either the .raw file or the $MOUNT... what am I missing?

sparse files. du did't count it as used space. but rsync allocate full size files on result image.

@rpardini
Copy link
Member Author

Actually fixed (correctly) in #4880 -- thanks @adeepn for all the work

@rpardini rpardini closed this Feb 27, 2023
@rpardini rpardini deleted the pr/use-dd-zeros-instead-of-truncate branch May 9, 2023 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Work in progress Unfinished / work in progress
Development

Successfully merging this pull request may close these issues.

2 participants