Skip to content

Add Support for geom_uzip Compression (FreeBSD mkuzip) #1125

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

Closed
qkaiser opened this issue Feb 11, 2025 · 0 comments · Fixed by #1143
Closed

Add Support for geom_uzip Compression (FreeBSD mkuzip) #1125

qkaiser opened this issue Feb 11, 2025 · 0 comments · Fixed by #1143
Labels
format:archive format request Format support request by 3rd party. good first issue Good for newcomers

Comments

@qkaiser
Copy link
Contributor

qkaiser commented Feb 11, 2025

Description
geom_uzip is a FreeBSD feature for creating compressed disk images (usually containing UFS). The compression is done in blocks, and the resulting .uzip file can be mounted via the GEOM framework on FreeBSD.

References

How to Craft

  1. On a FreeBSD system, install or use the built-in mkuzip tool.
  2. Run:
    mkuzip -o compressed.uzip original.img
    This generates compressed.uzip from original.img.

Magic Value / Signature

  • Often starts with a shebang like
00000000  23 21 2f 62 69 6e 2f 73  68 0a 23 56 32 2e 30 20  |#!/bin/sh.#V2.0 |
00000010  46 6f 72 6d 61 74 0a 28  6b 6c 64 73 74 61 74 20  |Format.(kldstat |
00000020  2d 71 6d 20 67 5f 75 7a  69 70 7c 7c 6b 6c 64 6c  |-qm g_uzip||kldl|
00000030  6f 61 64 20 67 65 6f 6d  5f 75 7a 69 70 29 3e 26  |oad geom_uzip)>&|
00000040  2d 26 26 6d 6f 75 6e 74  5f 63 64 39 36 36 30 20  |-&&mount_cd9660 |
00000050  2f 64 65 76 2f 60 6d 64  63 6f 6e 66 69 67 20 2d  |/dev/`mdconfig -|
00000060  61 66 20 24 30 60 2e 75  7a 69 70 20 24 31 0a 65  |af $0`.uzip $1.e|
00000070  78 69 74 20 24 3f 0a 00  00 00 00 00 00 00 00 00  |xit $?..........|
00000080  00 00 40 00 00 00 03 7e  00 00 00 00 00 00 1c 80  |..@....~........|
00000090  00 00 00 00 00 00 1c 80  00 00 00 00 00 00 1c 80  |................|

How to Extract / Decompress

  • Tool: On FreeBSD, you can mount it as a block device:
    mdconfig -f compressed.uzip
    mount -t ufs /dev/md0 /mnt
  • Python Library: Likely no direct library. A custom parser or existing FreeBSD userland tool is required.

Determining End Offset

  • The mkuzip header includes a table with block counts and sizes.
  • By parsing each block entry, you can determine the total size of the compressed image.
  • unblob should parse the table, locate the last block, and compute the offset for the entire .uzip file.
@qkaiser qkaiser added format request Format support request by 3rd party. format:archive good first issue Good for newcomers labels Feb 11, 2025
@qkaiser qkaiser added this to the Internship 2025 milestone Feb 11, 2025
@qkaiser qkaiser linked a pull request Mar 3, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
format:archive format request Format support request by 3rd party. good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant