r/AlpineLinux • • Nov 25 '24

Minimal Alpine with UEFI and UKI

3 Upvotes

I'm trying to build a minimal Alpine image with support for UEFI and UKI (no secureboot), bootstrapped via apt-tools. Let me show you guy the build script, the I'll explain the issue:

set -eux

readonly PATH=/bin:/sbin:/usr/bin:/usr/sbin
readonly DEFAULT_DISK_SIZE="2G"
readonly IMAGE="alpine.img"
readonly MIRROR=https://dl-cdn.alpinelinux.org/alpine
readonly REL=3.21
readonly ARCH=$(uname -m)
readonly APKV=2.14.4-r4
readonly REPO="${MIRROR}"/v"${REL}"/main
readonly HOST="satellite"

wait_until_settled() {
udevadm settle
blockdev --flushbufs --rereadpt "${1}"
until test -e "${1}p2"; do
echo "${1}p2 doesn't exist yet..."
sleep 1
done
}

cleanup() {
set +o errexit

if [ -n "${LOOPDEV:-}" ]; then
losetup -d "${LOOPDEV}"
fi
if [ -n "${MOUNT:-}" ] && mountpoint -q "${MOUNT}"; then
umount --recursive "${MOUNT}" || exit 1
fi
if [ -n "${TMPDIR:-}" ]; then
rm -rf "${TMPDIR}"
fi
}
trap cleanup EXIT

init() {
readonly ORIG_PWD="${PWD}"
readonly OUTPUT="${PWD}/out"
tmpdir="$(mktemp --dry-run --directory --tmpdir="${PWD}/tmp")"
readonly TMPDIR="${tmpdir}"
mkdir -p "${OUTPUT}" "${TMPDIR}"
if [ -n "${SUDO_UID:-}" ] && [ -n "${SUDO_GID:-}" ]; then
chown "${SUDO_UID}:${SUDO_GID}" "${OUTPUT}" "${TMPDIR}"
fi
cd "${TMPDIR}"

readonly MOUNT="${PWD}/mount"
mkdir "${MOUNT}"
}

setup_disk() {
truncate -s "${DEFAULT_DISK_SIZE}" "${IMAGE}"
sgdisk --align-end \
--clear \
--new 0:0:+1G --typecode=0:ef00 --change-name=0:'EFI' \
--new 0:0:0 --typecode=0:8304 --change-name=0:'alpine' \
"${IMAGE}"

LOOPDEV=$(losetup --find --partscan --show "${IMAGE}")
wait_until_settled "${LOOPDEV}"

mkfs.vfat -F 32 -n EFI "${LOOPDEV}p1"
mkfs.ext4 -L alpine -q "${LOOPDEV}p2"
mount "${LOOPDEV}p2" "${MOUNT}"
mount --mkdir "${LOOPDEV}p1" "${MOUNT}/boot/efi"
}

bootstrap() {
curl -s "${MIRROR}"/v"${REL}"/main/"${ARCH}"/apk-tools-static-${APKV}.apk |
tar xz

./sbin/apk.static --repository "${REPO}" \
--update-cache \
--allow-untrusted \
--root "${MOUNT}" \
--initdb add alpine-base


cat <<EOF >"${MOUNT}"/etc/fstab
LABEL=alpine / ext4 defaults 0 0
LABEL=EFI /boot/efi vfat defaults 0 2
EOF

echo "nameserver 1.1.1.1" > "${MOUNT}"/etc/resolv.conf
echo "${REPO}" >"${MOUNT}"/etc/apk/repositories

cat <<EOF >"${MOUNT}"/etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
EOF

for a in dev dev/pts proc sys run; do mount -o bind /$a "${MOUNT}"/$a; done

chroot "${MOUNT}" /bin/sh -x <<CHROOT
mkdir -p /etc/kernel-hooks.d/
mkdir -p /etc/mkinitfs/
mkdir -p /boot/efi/EFI/Linux/

echo "cmdline=root=LABEL=alpine modules=ext4" >
/etc/kernel-hooks.d/secureboot.conf
echo "signing_disabled=yes" >> /etc/kernel-hooks.d/secureboot.conf
echo "output_dir="/boot/efi/EFI/Linux/"" >>
/etc/kernel-hooks.d/secureboot.conf
echo "output_name="bootx64.efi"" >> /etc/kernel-hooks.d/secureboot.conf
echo "disable_trigger=yes" >> /etc/mkinitfs/mkinitfs.conf

apk update
apk add linux-lts \
linux-firmware-none \
mkinitfs \
secureboot-hook \
gummiboot-efistub \

setup-hostname -n "${HOST}"

rc-update -q add devfs sysinit
rc-update -q add dmesg sysinit
rc-update -q add mdev sysinit
rc-update -q add hwdrivers sysinit

rc-update -q add hwclock boot
rc-update -q add modules boot
rc-update -q add hostname boot
rc-update -q add bootmisc boot
rc-update -q add networking boot

rc-update -q add mount-ro shutdown
rc-update -q add killprocs shutdown
rc-update -q add savecache shutdown

rc-update -q add crond default

mkdir -p /boot/efi/loader/entries

cat > /boot/efi/loader/entries/alpine.conf <<EOF
title Alpine Linux
linux /EFI/Linux/bootx64.efi
EOF

ls -la /boot/efi/EFI/Linux/
CHROOT

cp "${IMAGE}" "${OUTPUT}/"
}

main() {
if [ "$(id -u)" -ne 0 ]; then
echo "root is required"
exit 1
fi

init
setup_disk
bootstrap
}

I tried couple of variations on the above but regardless of what I try, the UEFI partition of the final image is always empty. Now, the UKI seems to be generated alright - I sandwiched a ls -la /boot/efi/EFI/Linux/ toward the end of the script and output does show it being there:

>+ ls -la /boot/efi/EFI/Linux/
>total 11416
>drwxr-xr-x 2 root root 4096 Nov 23 13:20 .
>drwxr-xr-x 3 root root 4096 Nov 23 13:20 ..
>-rwxr-xr-x 1 root root 11680190 Nov 23 13:20 bootx64.efi

The full output of the build can be seen here: https://0x0.st/X56h.txt

But then I get an unbootable image, as the EFI partition is empty. I'm a little bit at loss here and would appreciate any advice as to how I could debug the issue.


r/AlpineLinux • • Nov 20 '24

When are packages added/updated on a diskless install?

3 Upvotes

Coming back to Alpine after some years of neglect. Trying to refresh my understanding of things, also some processes have changed in the meantime.

Say I have a diskless install, and on a USB key have an approval file and a apkcache. Say in the /etc/apk/world in my overlay file, I specify packages foo and bar. Say that foo is present in my boot media, but that a newer version is available in my apkcache. Bar is not present on the boot media, but is in the apkcache.

My questions are: does any part of the init process automatically update foo and install bar? If so where is this implemented? Or do I instead have do it manually with some combination of apk add --upgrade, apk fix --upgrade, apk update?


r/AlpineLinux • • Nov 18 '24

Raspberry Pi Touch Display 2 working on Alpine/PmOS

5 Upvotes

Hi all,

A couple of weeks ago, the Raspberry Pi Foundation released a new version of their 7 inch touch display. Because of the new kernel module required, at this point it only works on Raspbian automatically.

Last night, I finally made it work with alpine. All that is needed is to add the following to the cmdline.txt: “video=DSI-1:1280x720M@60”

Additionally, you need to change the kernel modules loaded in usrconfig.txt: From “vc4-fkms-v3d” to “vc4-kms-v3d” And add “dtoverlay=vc4-kms-dsi-ili9881-7inch” below it.

This should work on other distros but I’m not sure. Just a tip for anyone else in this unique situation!

Edit: this was all done using a pmbootstrap generated Edge image for Raspberry Pi 4 with a DSI display using Phosh


r/AlpineLinux • • Nov 18 '24

armhf vs armv7

2 Upvotes

Hi I'm getting a Raspberry Pi zero 2w, and these are capable of running both armhf and armv7 instruction sets. (Also aarch64, but I'm going to stay 32 bit with this device.) The Alpine install downloads for Raspberry Pis include both an armhf and a armv7 option.

Some information I'm seeing suggests that between these, I should prefer armhf, as it'd give me better floating point performance. And that binaries compiled for armv7 alone would (sometimes? always?) do floating point operations in software, bypassing the fp hardware.

Other information I'm seeing says that Alpine's armhf images are based on the v6 instruction set, so if I have a Raspberry Pi device capable of running the armv7 kernel/libs/binaries, I should use that instead. (Or aarch64.) But I'm not sure if this claim about the Alpine armhf images is up-to-date.

Anyone in a position to clarify?


r/AlpineLinux • • Nov 17 '24

Alpine linux testing

Post image
36 Upvotes

r/AlpineLinux • • Nov 17 '24

How to install Alpine Linux?

0 Upvotes

I had an installer, but it asks for a password... Idk, I'm in tty and it's asks for a password


r/AlpineLinux • • Nov 17 '24

Cannot run LXQt components under wayland

1 Upvotes

Hello, I have tried to install and run LXQt under Labwc and Hyprland, but every time I try to run any components of it or even lxqt-session I get this error:

Error relocating /usr/lib/libLayerShellQtInterface.so.6: _ZN15QtWaylandClient14QWaylandWindow9wlSurfaceEv: symbol not found

I also have compiled lxqt-wayland-session since it isn't in the testing repo yet, and I only have issues with just the components. I also get the 'Panel/notificationd/desktop crashed too many times. Its autorestart has been disabled.' message because of the error.


r/AlpineLinux • • Nov 14 '24

OpenWrt, a Linux distro for embedded routers, recently switched its package manager to APK from Alpine Linux (in developer snapshots, not yet stable releases).

Thumbnail git.openwrt.org
34 Upvotes

r/AlpineLinux • • Nov 12 '24

Anyone know why Alpine is insistent on downloading packages when the local package cache is enabled?

1 Upvotes

So I'm building a netboot server to boot a quite a few bare metal machines I have laying around.

While I have a machine booting from an lbu backup using apkovl=somewhere in the kernel commandline and it does get picked up, it appears that Alpine's Init script is a bit insistent in downloading packages from a repository when the machine boots to build the actual system root (It appears that Alpine always will pull packages from the mirror instead of using the cached packages that are in the apkovl even when the repo is disabled in the /etc/apk/repositories unless I have a misunderstanding on how apk works).

Any ideas as to fix this short of standing up a local repository? Thanks!


r/AlpineLinux • • Nov 11 '24

Anyone tried Cosmic DE alpha on Alpine?

5 Upvotes

Has anyone tried Cosmic DE on Alpine? What are your thoughts?


r/AlpineLinux • • Nov 07 '24

Intel a310 GPU

0 Upvotes

Hi, all.

Do we have sorry for Intel's a310 GPU, please?


r/AlpineLinux • • Nov 06 '24

Hyprland launch issue - ideas?

Thumbnail imgur.com
1 Upvotes

r/AlpineLinux • • Nov 05 '24

ParquetSharp.LogicalTypeFactory library missing

1 Upvotes

Hi All,

I am trying to spin up .NET 8 docker image in Alpine linux and while I successfully tried using the MS .NET Alpine linux tags:

mcr.microsoft.com/dotnet/sdk:8.0-alpine3.20 for build  & 

mcr.microsoft.com/dotnet/aspnet:8.0-alpine3.20 for runtime

I keep getting the below error message:

fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]


      An unhandled exception has occurred while executing the request.


      System.TypeInitializationException: The type initializer for 'ParquetSharp.LogicalTypeFactory' threw an exception.


       ---> System.DllNotFoundException: Unable to load shared library 'ParquetSharpNative' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:


      Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /publish/runtimes/linux-x64/native/ParquetSharpNative.so)


      Error loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.10/ParquetSharpNative.so: No such file or directory


      Error loading shared library /publish/ParquetSharpNative.so: No such file or directory


      Error loading shared library ParquetSharpNative.so: No such file or directory


      Error loading shared library /publish/runtimes/linux-x64/native/libParquetSharpNative.so: No such file or directory


      Error loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.10/libParquetSharpNative.so: No such file or directory


      Error loading shared library /publish/libParquetSharpNative.so: No such file or directory


      Error loading shared library libParquetSharpNative.so: No such file or directory


      Error loading shared library /publish/runtimes/linux-x64/native/ParquetSharpNative: No such file or directory


      Error loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.10/ParquetSharpNative: No such file or directory


      Error loading shared library /publish/ParquetSharpNative: No such file or directory


      Error loading shared library ParquetSharpNative: No such file or directory


      Error loading shared library /publish/runtimes/linux-x64/native/libParquetSharpNative: No such file or directory


      Error loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.10/libParquetSharpNative: No such file or directory


      Error loading shared library /publish/libParquetSharpNative: No such file or directory


      Error loading shared library libParquetSharpNative: No such file or directory




         at ParquetSharp.LogicalType.LogicalType_None(IntPtr& logicalType)


         at ParquetSharp.ExceptionInfo.Return[TValue](GetAction`1 getter)


         at ParquetSharp.LogicalType.None()


         at ParquetSharp.LogicalTypeFactory..cctor()

Does anyone have any idea on why this is happening? And if there is any workaround for this?

TIA


r/AlpineLinux • • Nov 04 '24

http/3.0 nginx

2 Upvotes

Nginx officialy support http/3.0 since 1.25, or on v3.20.x and on edge as well we have 1.26 without http3_mod! I need to compile and build it… Is there any issues, concernes on this support in Alpine?


r/AlpineLinux • • Nov 04 '24

Alpine Linux can’t see my partitions in the install script

1 Upvotes

I’m dual booting with Windows and Debian at the moment and have been for about a year now (on the same drive), but I wanted to create a small install of Alpine Linux. I created a 5GB partition using MiniTool Partition Wizard specifically for it.

However, the install script on the Live USB doesn’t see any of my partitions, only the entire drive. Running blkid shows them all, but Alpine still can’t see any of them.

Does anyone know why this is happening or what I can do to fix it? I'd really like to be able to install it on it's own partition, then choose it in GRUB when I boot. Thank you


r/AlpineLinux • • Nov 02 '24

Xorg not working

3 Upvotes

I installed icewm on alpine then run setup-xorg-base after that I launched Xorg and see xf86OpenConsole: Cannot open virtual console 1(Permission denied)


r/AlpineLinux • • Oct 31 '24

Help needed - Diskless mode documentation in wiki

4 Upvotes

I'm trying to consolidate information related to Diskless mode in Alpine Linux wiki to a single start page with improved navigation to other related pages. The draft currently resides here. Since i have only tested Diskless mode to understand how it works, i'm a bit unsure if my understanding is correct. So, i want feedback from experts here who have deployed and using diskless mode in production.

If you've account in wiki, please correct the mistakes in the draft directly or in Discussion page. Alternately, please leave your feedback here in reddit itself.

Also please take this opportunity to leave your feedback on the "data mode" documentation too i.e what needs to be fixed or added. The current wiki page for both data and diskless mode is here..


r/AlpineLinux • • Oct 29 '24

Openconnect-sso possible?

1 Upvotes

Hello,

Trying to install to connect to work:

https://pypi.org/project/openconnect-sso/

other distros are ok, alpine is eluding me. Anyone know if it's possible?

Cheers!


r/AlpineLinux • • Oct 28 '24

Qemu on alpine

1 Upvotes

Tried to install qemu on alpine with apk add qemu qemu-img qemu-system-x86_64 but i get error saying no such package for all 3 packages


r/AlpineLinux • • Oct 27 '24

Encrypted btrfs raid can't be mounted

1 Upvotes

I'm trying to set up automatic mapping and mounting 2 luks filesystems, 2nd one is btrfs raid on 2 encrypted volumes. Mapping is successful, but raid can't be mounted, and ash says "no such file or directory". Dmesg tells one of disks is missing, but 'btrfs filesystem show` says everything is fine. I tested on another system(arch Linux) nd raid successfully mounted. Where could be a problem? Thx


r/AlpineLinux • • Oct 25 '24

podman issues and alpine on ram

2 Upvotes

Hi guys, I'll put below some doubts and questions I have. Sorry if they are already been asked, I've done a quick search and I've not found much.

Bit of preamble: I'm currently running a tiny home server with docker on debian, so I'm not completely newbie.

I fell in love with Alpine and its way to make things minimal, quick and effective, therefore I decided to move all my containers to Alpine and switch to podman instead of docker.

Here comes the questions:

  1. I'd like to run podman and my containers on Alpine which ideally will run completely on RAM. I tried and I'm not completely sure how this works. The containers are vaultwarden and nextcloud, which both need to write and read data. can I mount an external disk for that and keep Alpine on RAM?
  2. I also tested to install Alpine on system (sys) and podman works just fine, however keeps giving me an alert about / not being shared. I've read the wiki and I've added "shared" on my fstab, however this warning message keeps coming back.
  3. on debian (therefore with systemd) I'd have a service called "podman-restart.sh" which will allow any container to re-start automatically at any reboot of the machine. how can I achieve this with Alpine and openrc?

That's all for now. Hope someone can help, thank you a lot!


r/AlpineLinux • • Oct 25 '24

How do I install things not in the Apk repositories

1 Upvotes

Hello, I am relatively still a beginner at linux and installed alpine on an ol chromebook I got. I then went to install a couple things but apk does not have them. So I tried pipx but pipx is also not working. I am trying to install sherlock and gpt4all. Also any tips would be appreciated. Im more used to apt but I guess it's a bad idea to have that with apk. Anyway thanks :)


r/AlpineLinux • • Oct 24 '24

APKBUILD packages essentially analogous to Arch PKGBUILD?

4 Upvotes

OK, so I know the two distros are different, and Alpine came from a Gentoo ebuild originally, but am I the only one who, through parallel convergence, mutual admiration, or some other phenomenon, thinks that APKBUILDs and PKGBUILDs are essentially the same thing at this point?

Other than having a different package system (are .apks compressed with gzip instead of zstd?), Alpine using musl instead of glib, and openRC instead of systemd, aren't they essentially the same thing?

Another stunning similarity along the same lines is the community build recipe repositories, with Arch having AUR, and Alpine having aports, and the build systems, with Arch having Arch Build Scripts (ABS), and Alpine with apkbuild.

Am I mad?


r/AlpineLinux • • Oct 24 '24

proper way to install to R-Pi Zero W SD card (noob alert)

2 Upvotes

Good morning, Long time Debian user, first try with Alpine. I've copied the image (alpine-rpi-3.20.3-armhf.img.gz) to an SD card and it boots and runs fine. I ran the setup setup-alpine and skipped the part where it asks to choose media to install to. Following this everything seemed to work fine. Eventually I ran into a 'No space left on device' and saw that /dev/mmcblk0p1 was at 99%. I repeated the install and this time in setup I chose mmcblk0 as the installation target. That trundled along for a bit until the system encounterd an Internal error: Oops: 5 [#1] ARM which can be viewed at https://photos.app.goo.gl/KS3D7v1AsiWe7XyGA.

Is this the desired installation strategy or do I need to install to media other than what the Pi Zero booted from?

Is there a current guide for installing to an SD card on an R-Pi Zero W?

Thanks!