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

Add support for 32k page size (ARM?) to avoid ELF load command address/offset not page-aligned #2078

Open
DJManas opened this issue Oct 3, 2023 · 9 comments

Comments

@DJManas
Copy link

DJManas commented Oct 3, 2023

Hello,

recently QNAP container station switched to 32k page size from 4k and since then I am having problem with update (last working image, that I had tried is NextCloud 26.0.1, tried to update to 26.0.7 and since then I am having problem starting the container up (no matter if its apache, fpm, etc.). I am getting messages like:

/bin/sh: error while loading shared libraries: libc.so.6: ELF load command address/offset not page-aligned

And the container is still restarting. I had searched the internet and it seems that its related to change to 32k page size. I am not sure if i am able to change it back to 4k though (official QNAP support help is... I don't want to be rude).

Is it possible to make images compatible to 32k, maybee backwards compatible, since I want to upgrade from 26.0.1 to latest release (which is I gues to 26.0.7 and then do 27.0.0 and then to latest).

Thanks,
Regards,
Petr Sourek

@joshtrichards
Copy link
Member

joshtrichards commented Oct 3, 2023

https://www.qnap.com/da-dk/how-to/faq/article/why-do-the-installed-third-party-containers-not-run-successfully-on-specific-32-bit-arm-devices

This will likely need to be fixed upstream (either the official community PHP Docker image or the Debian one or Alpine), but I'm honestly not sure. Someone needs to do the leg work to research this matter more, including not only a possible fix for this situation, but a path that makes sure it doesn't break things for others.

I think it's ARM specific.

@joshtrichards joshtrichards changed the title [FR] Please add support for 32k page size [FR] Please add support for 32k page size (ARM?) Oct 3, 2023
@joshtrichards joshtrichards changed the title [FR] Please add support for 32k page size (ARM?) Add support for 32k page size (ARM?) Oct 22, 2023
@joshtrichards joshtrichards changed the title Add support for 32k page size (ARM?) Add support for 32k page size (ARM?) to avoid ELF load command address/offset not page-aligned Nov 5, 2023
@joshtrichards
Copy link
Member

I was looking to see how other Official Docker Library images have dealt with this and I found:

Though from general searches (i.e. outside Docker Library images) I'm surprised this hasn't come up a bit more often with the Official ones. 🤔

@Wetzel402
Copy link

Wetzel402 commented Nov 29, 2023

Some related posts...

https://gitlab.alpinelinux.org/alpine/aports/-/issues/15167

home-assistant/core#86589

@magicse
Copy link

magicse commented Apr 6, 2024

Also i try experiment in emulation on x86 like this.
And get different strange things
Alpine Linux 3.18.0 under emulation page size 32k work but give me page size 4K

getconf PAGESIZE
4096

Alpine Linux 3.17.0 under emulation page size 32k give me "bin/sh: getconf: Bad address"
on any commands.

And backward on QNAP with pagesize 32K container
Alpine Linux 3.17.0 work without problem and Alpine Linux 3.18.0 didnt work at all.

sudo apt-get install qemu binfmt-support qemu-user-static
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
for 32K PAGE SIZE
docker run -e "QEMU_CPU=cortex-a15" -e "QEMU_PAGESIZE=32768" --rm --platform linux/arm/v7 -it alpine:3.17.0 /bin/sh
docker run -e "QEMU_CPU=cortex-a15" -e "QEMU_PAGESIZE=32768" --rm --platform linux/arm/v7 -it alpine:3.18.0 /bin/sh

for 4K PAGE SIZE
docker run -e "QEMU_CPU=cortex-a15" -e "QEMU_PAGESIZE=4096" --rm --platform linux/arm/v7 -it alpine:3.17.0 /bin/sh
docker run -e "QEMU_CPU=cortex-a15" -e "QEMU_PAGESIZE=4096" --rm --platform linux/arm/v7 -it alpine:3.18.0 /bin/sh

@joshtrichards
Copy link
Member

NextCloud 26.0.1, tried to update to 26.0.7 and since then I am having problem starting the container up

You may be able to workaround this by changing the source image in the Dockerfile and building the image locally - e.g.

FROM php:8.2-fpm-bookworm

Changing from bookworm to bullseye (the Debian version it was previously derived from).

FROM php:8.2-fpm-alpine3.20

Changing 3.20 to 3.17.

Caveat: Obviously it's a non-standard build at that point.

@DJManas
Copy link
Author

DJManas commented Jul 1, 2024

@joshtrichards Thanks I was busy from the bug creation, but now I got to it and ended with the same error on .0.13 so I was about to think of doing what you have written. Well not exactly, firstly I had to search, how to do docker files, etc. And then your comment came. Thanks for that! I have really good starting point. I will try it and will write here how I had ended. Thanks!

@jagko
Copy link

jagko commented Sep 9, 2024

Hello,
Time flies...
Now it is near one year since I get this failure. Is there a change to get it fixed.
Or shall i sell my Arm Qnap TS-231P2?

@Wetzel402
Copy link

Hello, Time flies... Now it is near one year since I get this failure. Is there a change to get it fixed. Or shall i sell my Arm Qnap TS-231P2?

This bug has been tracked down to an issue with binutils and a bug report has been opened. With that said, I'm not sure if/when it will get fixed. If fixed, it will also take time to roll out to projects that depend on it.

I needed more space so when I upgraded to an 8 bay QNAP I made sure it was an x86 based unit...

@pawan1485
Copy link

So I went down this rabbit hole and I wanted to share my finding.

I don't have a fix for the 32K pagesize but have successfully updated nextcloud to version 29 on my QNAP. (current stable version)
I am also not a Linux master, just learning as I go. Please reply if you see any errors.

So the nextcloud dockers are based off the php:8.2-fpm-bookworm which is based off the docker debian:bookworm-slim which is broken as it has 4K pagesize. Until debian:bookworm is fixed the nextcloud dockers will stay broken for us.

Luckily for us that debian:bullseye docker is currently a stable and up to date version (for a few more years) so changing the Line 2 like @joshtrichards suggested should work for other apps as well, not just the nextcloud docker.

I tried to compile debian:bookworm on the QNAP but couldn't get it to work. If any of you guys have step by step instructions on that let me know.

Now the following is how to upgrade nextcloud to the latest version if you have a 32bit arm QNAP:
As you need to step through nextcloud version to upgrade.

Version 25
Latest version works by default.

Version 26.
Use docker version 26.0.3

Version 27
Use docker version 27.0.0

For the rest of the versions we will need to compile the docker.

Currently downloading the master version of the nextcloud docker will get you version 28, 29 and 30.
https://github.com/nextcloud/docker

This link is for the future when they remove version 28 from the master build
https://github.com/nextcloud/docker/blob/178f8b65d34f49f649aa729de148c24a4d79db84/

Download and extract the file on the QNAP.

Version 28:
Use the QNAP NAS website to edit the text file. Its just easier than vi on command line.

Lets start with version 28, so open the folder named '28' with File Station and edit the file 'Dockerfile' with Text Editor. If you don't have the Text Editor app download it in the app center.

Here are the changes you need to make to each docker file in the version folders:

FROM php:8.2-apache-bookworm

Change bookworm to bullseye on line 2
FROM php:8.2-apache-bullseye

You also need to delete the lines 48 and 54

docker-php-ext-configure ftp --with-openssl-dir=/usr; \

Lines 48 and 54 cause a compile error and the nextcloud docker works fine without them (*for now).

Now SSH into QNAP and navigate to the folder 28.

We need to set entrypoint.sh as executable otherwise the docker will not run and cause a permissions error.
So run the command:
chmod +x entrypoint.sh

Now we need to compile the docker.
The following command, names the docker and sets a version, so it will be custom to you. The dot at the end of the command is important so don't forget it.
docker build --tag [username]/nextcloud:28.0.11 .

You can look up the version on line 153 of the Dockerfile

curl -fsSL -o nextcloud.tar.bz2 "https://download.nextcloud.com/server/releases/nextcloud-28.0.11.tar.bz2"; \

It will take a long time to compile.
You should see the image in container station once it is done along with a lot of other containers and images. Some of the extra containers and images I could only get rid of by selecting prune instead of delete. (delete after you make sure the compiled nextcloud docker works)

Test the image as a standalone nextcloud docker before you recreate your production nextcloud docker.

Version 29
Should be the same as version 28. Just use the same steps on folder 29.

Version 30
If you are feeling brave you can do the same steps to upgrade to version 30

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

No branches or pull requests

6 participants