Alpine-NAS のカーネルアプデはどうするの?

投稿者: | 2024年8月9日

Alpine Linux ベースのNASを作って職場のストレージに活用中でした。

# apk update
# apk upgrade

で一般パッケージはアプデができるけど、kernel はうまくいかない。どうすんの?って検索していたらそのままずばりの解説があった。

How-to install Alpine Linux in full ram with persistency によると、”The kernel can’t be upgraded using apk, you have to use the script update-kernel that will create a “modloop” file in the boot partition which contains the boot image. You can’t rollback this file.” だそうな。

ふーん

You will need a few gigabytes in your in-memory filesystem, or use a temporary build directory by affecting TMPDIR variable to a persistent storage.

By default, tmpfs on root is set to 1 GB, this can be increased given you have enough memory using the command: mount -o remount,size=6G /.

The script should have the boot directory as a parameter, so it should look like update-kernel /media/usb/boot in a default setup, if you use an external partition, this would look like env TMPDIR=/mnt/something/ update-kernel /media/usb/boot

っていうから、やってみた!

ionas:~# ls /media/usb
.alpine-release             apks/                       cache/                      ionas.apkovl.tar.gz        ldlinux.sys
System Volume Information/  boot/                       efi/                        ldlinux.c32

ionas:~# ls /media/usb/boot/
System.map-6.6.31-0-lts  dtbs-lts/                initramfs-lts            syslinux/
config-6.6.31-0-lts      grub/                    modloop-lts              vmlinuz-lts

ionas:~# env TMPDIR=/media/raid1/tmp/ update-kernel /media/usb/boot/
Parallel mksquashfs: Using 4 processors
Creating 4.0 filesystem on /media/raid1/tmp/update-kernel.ACfMnj/boot/modloop-lts, block size 131072.
[=============================================================\] 9426/9426 100%

Exportable Squashfs 4.0 filesystem, xz compressed, data block size 131072
        compressed data, compressed metadata, compressed fragments,
        compressed xattrs, compressed ids
        duplicates are removed
Filesystem size 158109.01 Kbytes (154.40 Mbytes)
        22.44% of uncompressed filesystem size (704479.26 Kbytes)
Inode table size 59470 bytes (58.08 Kbytes)
        25.78% of uncompressed inode table size (230638 bytes)
Directory table size 60582 bytes (59.16 Kbytes)
        39.89% of uncompressed directory table size (151857 bytes)
Number of duplicate files found 460
Number of inodes 6586
Number of files 5555
Number of fragments 1493
Number of symbolic links 0
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 1031
Number of hard-links 0
Number of ids (unique uids + gids) 1
Number of uids 1
        root (0)
Number of gids 1
        root (0)

再起動したら、アプデ成功していました。

って書いたけど、TMPDIRが fat32 ファイルシステムとかだとうまくいきません。シンボリックリンクの関係かな? なので ext4 のtemporary directory を用意してやる必要があります。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です