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

gensquashfs: Allow to disable padding #113

Open
Gottox opened this issue Feb 28, 2023 · 2 comments
Open

gensquashfs: Allow to disable padding #113

Gottox opened this issue Feb 28, 2023 · 2 comments

Comments

@Gottox
Copy link
Contributor

Gottox commented Feb 28, 2023

I'm planning to use squashfs as an archive format, for that it would be cool to be able to disable padding completely. mksquashfs already supports that with the -nopad option. gensquashfs also has such a feature, but the lowest value that can be chosen is 1024 byte padding.

I couldn't find any pointers to that value in the reference, so I would guess, that kb alignment is the minimal value that makes it usable using kernel mount.

It would be awesome if I could disable padding completely.

@AgentD
Copy link
Owner

AgentD commented Mar 4, 2023

Hi,

yes, the padding is a requirement by the kernel module. It is referred to as "device block size" and the kernel config you can choose this to be either 1k or 4k. I chose 4k as default, because then it also happens to be 1k padding.

This is really just padding it with 0 bytes at the end to make the size a multiple. It does not entail any internal alignment.

So how big are your archives that this would actually matter? If you have a 100k archive, the padding makes up between 1% and 4% of that size at most. For an archive that's 1M in size the padding makes up less than 0.4% at most.

@Gottox
Copy link
Contributor Author

Gottox commented Mar 5, 2023

Ah, thanks for the pointer in the kernel config!

To explain my use case a bit more: My plan was to append structured data (a signature) at the end of the archive. Extracting it from the archive is pretty easy as I'm using libsqsh and does not involve any padding logic: Just read from the "bytes used" value in the superblock till the end of the file.

On creation time I rely on shell tools, so I can't read out the header. Instead I'm just doing something like that:

mksquashfs ... foobar.img ... -nopad
signify -S -m foobar.img ... 
cat foobar.img.sig >> foobar.img
# If I want it to be mountable: (TIL :D)
truncate --size '%4096' foobar.img

With gensquashfs I gain the ability to set xattrs on any filesystem, like tmpfs. That's one of the reasons why I'd like to switch to gensquashfs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants