Tag: Gentoo

fail-dhcpd-build

GenPi64のイメージ作成中、

下記のエラーが出る。 なぜかdhcpcdのビルドに失敗する(再現性もある)

aarch64-unknown-linux-gnu-gcc -march=armv8-a+crc -mtune=cortex-a72 -ftree-vectorize -O2 -pipe -march=native -O2 -pipe -std=c99 -DHAVE_CONFIG_H -DNDEBUG -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DINET -DARP -DARPING -DIPV4LL -DINET6 -DDHCP6 -DAUTH -DPLUGIN_DEV -I.. -I../src -I./crypt -c ../compat/strtou.c -o ../compat/strtou.o
make[1]: *** No rule to make target '/mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/scripts', needed by 'all'.  Stop.
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/var/tmp/portage/net-misc/dhcpcd-9.5.1/work/dhcpcd-9.5.1/src'
make: *** [Makefile:24: all] Error 2
 * ERROR: net-misc/dhcpcd-9.5.1::gentoo failed (compile phase):
 *   emake failed
 *
 * If you need support, post the output of `emerge --info '=net-misc/dhcpcd-9.5.1::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=net-misc/dhcpcd-9.5.1::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/net-misc/dhcpcd-9.5.1/temp/build.log.gz'.
 * The ebuild environment file is located at '/var/tmp/portage/net-misc/dhcpcd-9.5.1/temp/environment'.
 * Working directory: '/var/tmp/portage/net-misc/dhcpcd-9.5.1/work/dhcpcd-9.5.1'
 * S: '/var/tmp/portage/net-misc/dhcpcd-9.5.1/work/dhcpcd-9.5.1'

 * Messages for package sys-apps/systemd-253.3-r1:

 * Unable to find kernel sources at /usr/src/linux
 * Unable to calculate Linux Kernel version for build, attempting to use running version
 *   CONFIG_CHECKPOINT_RESTORE:  is not set when it should be.
 * Please check to make sure these options are set correctly.
 * Failure to do so may cause unexpected problems.

 * Messages for package sys-apps/portage-3.0.49-r1:

 * Unable to find kernel sources at /usr/src/linux
 * Unable to calculate Linux Kernel version for build, attempting to use running version

 * Messages for package net-wireless/wpa_supplicant-2.10-r1:

 * Unable to find kernel sources at /usr/src/linux
 * Unable to calculate Linux Kernel version for build, attempting to use running version

 * Messages for package sys-process/atop-2.8.1:

 * Unable to find kernel sources at /usr/src/linux
 * Unable to calculate Linux Kernel version for build, attempting to use running version

 * Messages for package acct-group/cron-0-r1:

 * Adding group cron

 * Messages for package media-fonts/liberation-fonts-2.1.5:

 * The following fontconfig configuration files have been installed:
 *
 *   60-liberation.conf
 *
 * Use `eselect fontconfig` to enable/disable them.

 * Messages for package acct-group/plugdev-0-r2:

 * Adding group plugdev

 * Messages for package acct-group/crontab-0-r1:

 * Adding group crontab

 * Messages for package acct-group/gpio-0-r1:

 * Adding group gpio

 * Messages for package acct-group/nullmail-0-r1:

 * Adding group nullmail

 * Messages for package acct-group/spi-0-r1:

 * Adding group spi

 * Messages for package acct-group/i2c-0-r1:

 * Adding group i2c

 * Messages for package acct-group/ntp-0-r2:

 * Adding group ntp

 * Messages for package acct-user/cron-0-r1:

 * Adding user cron

 * Messages for package acct-user/nullmail-0-r1:

 * Adding user nullmail

 * Messages for package acct-user/ntp-0-r2:

 * Adding user ntp

 * Messages for package sys-boot/raspberrypi-firmware-1.20230106:

 * Please configure your ram setup by editing /boot/config.txt
 *
 * (Note: Above message is only printed the first time package is
 * installed. Please look at /usr/share/doc/raspberrypi-firmware-1.20230106/README.gentoo*
 * for future reference)

 * Messages for package dev-libs/ell-0.56:

 * Unable to find kernel sources at /usr/src/linux
 * Unable to calculate Linux Kernel version for build, attempting to use running version
 *   CONFIG_KEY_DH_OPERATIONS:   is not set when it should be.
 * Please check to make sure these options are set correctly.
 * Failure to do so may cause unexpected problems.

 * Messages for package sys-libs/pam-1.5.3:

 * Some software with pre-loaded PAM libraries might experience
 * warnings or failures related to missing symbols and/or versions
 * after any update. While unfortunate this is a limit of the
 * implementation of PAM and the software, and it requires you to
 * restart the software manually after the update.
 *
 * You can get a list of such software running a command like
 *   lsof / | grep -E -i 'del.*libpam\.so'
 *
 * Alternatively, simply reboot your system.
 * Could not set caps on '/sbin/unix_chkpwd' due to missing filesystem support:
 * * enable XATTR support for 'nfs' in your kernel (if configurable)
 * * mount the fs with the user_xattr option (if not the default)
 * * enable the relevant FS_SECURITY option (if configurable)

 * Messages for package sys-apps/util-linux-2.38.1-r2:

 * The mesg/wall/write tools have been disabled due to USE=-tty-helpers.

 * Messages for package dev-python/jinja-3.1.2:

 * For i18n support, please emerge dev-python/Babel.

 * Messages for package dev-python/lxml-4.9.2-r1:

 * Install additional packages for optional runtime features:
 *   dev-python/beautifulsoup4 for Support for BeautifulSoup as a parser backend
 *   dev-python/cssselect for Translates CSS selectors to XPath 1.0 expressions

 * Messages for package sys-apps/rpi-onetime-startup-1.0-r5:

 * The rpi-onetime-startup service has been added to your default runlevel.
 * You are running with the systemd USE flag set!
 * However, this package does not yet formally support systemd, so
 * you are on your own to get things working ><

 * Messages for package sys-apps/portage-3.0.49-r1:

 * Unable to find kernel sources at /usr/src/linux
 * Unable to calculate Linux Kernel version for build, attempting to use running version

 * Messages for package app-portage/gentoolkit-0.6.1-r3:

 *
 * For further information on gentoolkit, please read the gentoolkit
 * guide: https://wiki.gentoo.org/wiki/Gentoolkit
 *
 * Another alternative to equery is app-portage/portage-utils
 *
 * Additional tools that may be of interest:
 *
 *     app-admin/eclean-kernel
 *     app-portage/diffmask
 *     app-portage/flaggie
 *     app-portage/portpeek
 *     app-portage/smart-live-rebuild

 * Messages for package media-libs/fontconfig-2.14.2-r2:

 * Please make fontconfig configuration changes using `eselect
 * fontconfig`. Any changes made to /etc/fonts/fonts.conf will be
 * overwritten. If you need to reset your configuration to upstream
 * defaults, delete the directory /etc/fonts/conf.d/ and re-emerge
 * fontconfig.
 *
 * (Note: Above message is only printed the first time package is
 * installed. Please look at /usr/share/doc/fontconfig-2.14.2-r2/README.gentoo*
 * for future reference)

 * Messages for package net-dialup/ppp-2.5.0-r3:

 * Unable to find kernel sources at /usr/src/linux
 * Unable to calculate Linux Kernel version for build, attempting to use running version

 * Messages for package net-misc/dhcpcd-9.5.1:

 * ERROR: net-misc/dhcpcd-9.5.1::gentoo failed (compile phase):
 *   emake failed
 *
 * If you need support, post the output of `emerge --info '=net-misc/dhcpcd-9.5.1::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=net-misc/dhcpcd-9.5.1::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/net-misc/dhcpcd-9.5.1/temp/build.log.gz'.
 * The ebuild environment file is located at '/var/tmp/portage/net-misc/dhcpcd-9.5.1/temp/environment'.
 * Working directory: '/var/tmp/portage/net-misc/dhcpcd-9.5.1/work/dhcpcd-9.5.1'
 * S: '/var/tmp/portage/net-misc/dhcpcd-9.5.1/work/dhcpcd-9.5.1'

 * Messages for package sys-apps/rpi-gpio-1.0.0-r1:

 * Adding all members of wheel to the gpio group

 * Messages for package sys-apps/rpi3-ondemand-cpufreq-1.1.1-r1:

 * Please run:
 *   rc-update add rpi3-ondemand sysinit
 * to enable on-demand CPU frequency scaling
 * You are running with the systemd USE flag set!
 * However, this package does not yet formally support systemd, so
 * you are on your own to get things working ><

 * Messages for package sys-process/iotop-0.6_p20230124:

 * Since Linux 5.14, sysctl kernel.task_delayacct should be enabled
 * This can be enabled by running: 'sysctl kernel.task_delayacct=1'
 * And can be made persistent by adding 'kernel.task_delayacct = 1' to /etc/sysctl.conf

 * Messages for package sys-block/zram-init-11.1:

 * To use zram-init, activate it in your kernel and add it to the default
 * runlevel:
 * rc-update add zram-init default
 * If you use systemd enable zram_swap, zram_tmp, and/or zram_var_tmp with
 * systemctl. You might need to modify the following file depending on the number
 * of devices that you want to create:
 * /etc/modprobe.d/zram.conf.
 * If you use the $TMPDIR as zram device with OpenRC, you should add zram-init to
 * the boot runlevel:
 * rc-update add zram-init boot
 * Still for the same case, you should add in the OpenRC configuration file for
 * the services using $TMPDIR the following line:
 * rc_need="zram-init"
 *
 * (Note: Above message is only printed the first time package is
 * installed. Please look at /usr/share/doc/zram-init-11.1/README.gentoo*
 * for future reference)

 * Messages for package sys-apps/rpi-spi-1.0.0-r2:

 * Adding all members of wheel to the spi group
 * To use the SPI interface, please ensure:
 *   dtparam=spi=on
 * is set in /boot/config.txt.

 * Messages for package sys-apps/rpi-i2c-1.0.0-r3:

 * Adding all members of wheel to the i2c group
 * The rpi-i2c service has been added to your boot runlevel.
 * To activate, and use the I2C interface, please set:
 *   dtparam=i2c_arm=on
 * in /boot/config.txt, and reboot.
 * You are running with the systemd USE flag set!
 * However, this package does not yet formally support systemd, so
 * you are on your own to get things working ><

 * Messages for package sys-apps/rpi3-init-scripts-2.0.0:

 * The first-boot root partition resizing service has been activated.
 * This service will run so long as the sentinel file /boot/dont_autoexpand_root
 * Does not exist.
 * To disable entirely, run:
 *   rc-update del autoexpand-root boot
 * You are running with the systemd USE flag set!
 * However, this package does not yet formally support systemd, so
 * you are on your own to get things working ><

 * Messages for package net-wireless/rpi3-wifi-regdom-1.1-r1:

 * The rpi3-wifi-regdom service has been added to your default runlevel.
 * Please check /etc/conf.d/rpi3-wifi-regdom, and set an
 * appropriate ISO / IEC 3166 alpha2 country code therein.
 * You are running with the systemd USE flag set!
 * However, this package does not yet formally support systemd, so
 * you are on your own to get things working ><

 * Messages for package app-portage/genup-1.0.29-r1:

 * emtee USE flag selected - patching script accordingly.
 * Ensuring eix syncs overlays and updates the metadata cache, and that
 * eix-update uses that cache, per:
 * https://wiki.gentoo.org/wiki/Overlay#eix_integration

 * Messages for package sys-process/htop-3.2.2:

 * Unable to find kernel sources at /usr/src/linux
 * Unable to calculate Linux Kernel version for build, attempting to use running version

 * Messages for package net-analyzer/mtr-0.95-r1:

 * Could not set caps on '/usr/sbin/mtr-packet' due to missing filesystem support:
 * * enable XATTR support for 'nfs' in your kernel (if configurable)
 * * mount the fs with the user_xattr option (if not the default)
 * * enable the relevant FS_SECURITY option (if configurable)

 * Messages for package net-misc/chrony-4.3-r5:

 * To enable seccomp in a stricter mode, please modify:
 * - /etc/conf.d/chronyd for OpenRC
 * - systemctl edit chronyd for systemd
 * to use -F 1 or -F -1 instead of -F 2 (see man chronyd)
 * By default, we now use -F 2 which is a baseline/minimal filter.

 * Messages for package app-misc/screen-4.9.0-r2:

 * Some dangerous key bindings have been removed or changed to more safe values.
 * We enable some xterm hacks in our default screenrc, which might break some
 * applications. Please check /etc/screenrc for information on these changes.
 * This revision changes the screen socket location to /tmp/screen

 * Messages for package app-admin/rsyslog-8.2304.0:

 * To create a default CA and certificates for your server and clients, run:
 *   emerge --config =rsyslog-8.2304.0
 * on your logging server. You can run it several times,
 * once for each logging client. The client certificates will be signed
 * using the CA certificate generated during the first run.
 * Please read
 *
 *   /usr/share/doc/rsyslog-8.2304.0/README.gentoo*
 *
 * for more details.

 * Regenerating GNU info directory index...
 * Processed 202 info files.

 * IMPORTANT: config file '/etc/profile' needs updating.
 * See the CONFIGURATION FILES and CONFIGURATION FILES UPDATE TOOLS
 * sections of the emerge man page to learn how to update config files.

 * IMPORTANT: 1 news items need reading for repository 'genpi64'.
 * IMPORTANT: 11 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.

 * After world updates, it is important to remove obsolete packages with
 * emerge --depclean. Refer to `man emerge` for more information.
+ finish
+ ret=1
+ rm -f /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist/build/GenPi64Systemd/chroot/em-32233
+ exit 1
FATAL: JOB emerge_new_profile FAILED with exit code 1
FATAL: JOB gentoo-base FAILED with exit code 1
run complete.
k3s-stg-agent-e /mnt/nfs/home/exampleuser/workspace/git/github.com/exampleuser/Build.Dist #

手動でchrootしてビルドできるかテスト

mountする必要があるのでrootで行う。

Read more...

package-management

いろいろ

コマンドやりたい事
qlist -IRvtパッケージ一覧がほしい
eix –worldworldの更新対象
equery b which vimコマンドを提供しているパッケージ名
euse -i XUSEフラグの使用方法
sudo equery uses gccパッケージの使うUSEフラグの説明と使用状況
qcheck vim-coreパッケージのベリファイ
Read more...

Gentoo × Raspberry Pi(brcmfmac)で Wi-Fi 接続に失敗したときの原因切り分けと解決メモ

本記事は、Gentoo + Raspberry Pi 5(brcmfmac) 環境で 5GHz Wi-Fi(OpenWrt AP)への接続に失敗した事象を、ログの読み解き → 原因候補の整理 → 最短の切り分け → 恒久対策の順でまとめたトラブルシュート記録です。 同様の環境・構成でハマった方の参考になれば幸いです。

TL;DR(最初に結論)

  • 症状は ASSOC-REJECT status_code=16 の連発。dmesg には brcmf_set_channel … reason -52 が多発。
  • 規制ドメイン(regdom)が global=JP でも phy=99(UNSET)のまま、かつ WPA3/SAE のビルド/設定相性が絡んで アソシエーション前段で失敗していた。
  • 改善に効いたもの:
    • AP の国コードを JP 固定、チャンネル 36–48(非DFS)(今回は 48)で固定。
    • クライアントは一時的に WPA2-PSK(AES)に限定(key_mgmt から SAE を外す、pairwise/group/proto を CCMP/RSN 固定)。
    • sae_pwe 未対応による設定パースエラーを除去。
    • 起動後に udev or systemd で iw reg set JP を強制(phy が 99 から動かない個体の保険)。
  • つながっている別サーバは、接続後に AP の Country IE(802.11d)で JP に寄っていた(=接続できれば後追いで JP になる)。今回の問題個体は 接続前に落ちるため、phy が 99 のままという見え方だった。

構成概要

  • クライアント:Gentoo Linux on Raspberry Pi 5
    • カーネル:brcmfmac(Broadcom FullMAC ドライバ)
    • ネットワーク:systemd-networkd + wpa_supplicant
    • MTU:1450(k3s/flannel 想定)
  • アクセスポイント:OpenWrt
    • SSID:OpenWrt5Ghz
    • 暗号:WPA2/WPA3 ミックス(PSK + SAE, CCMP)
    • チャンネル:48(5.240GHz, 非DFS)
    • Country:JP(固定) ← 対応後
    • Wifiアクセスポイント側の暗号化: mixed WPA2/WPA3 PSK, SAE (CCMP)
  • 目的:5GHz 接続の安定化(WPA3 も将来的に使いたい)

症状とログ

DHCPv6の設定ができていなかった

networkctl status wlan0 をした際に次のエラーがでた

Read more...

ラズパイ5、Gentoo周りのメモ

Gentooで使いたい。GenPi64のプロジェクトだと2024/03だと対応はまだの模様

2023/12 あたりに作成したGenPi64プロジェクトのイメージだとRaspberryPI5では起動しなかった。 この辺の機種ごとの際はラズベリーパイではよくあることではある。

ありがたいことに先人がおり起動したので、私が追加で設定したメモを残す。

手順はext4で起動するようになっている。 私が手順を一通り見て「既存のディスクイメージをベースにカーネルと必要なファイルを更新したら起動するのでは?」と思い試してみた。 が、カーネルが認識するファイルシステムがext4だった(カーネル再構築でbtrfsを認識させればよいような気もする) 私がGenPi64で作成したイメージはルートファイルシステムをbtrfsで構成したため起動しなかった。 素直にext4でルートファイルシステムを構成する。

基本的にこの手順で動作する

How to install Gentoo on Raspberry Pi 5 - Gentoo Wiki

私は作業用ディレクトリとして下記にした

WORK=/mnt/gentoo_work
DISK=/dev/sdc
DEST=/mnt/gentoo
mount ${DISK}3 $DEST && mount ${DISK}1 ${DEST}/boot

Gentooオフィシャルの説明

私が追加、変更して作業したこと

/lib/modules の git clone は時間がかかる

先にgitをインストールして/lib/modules用のレポジトリをダウンロードしておいた方が良い

–depth=1 で履歴を取らないようにしておくと早い

cd ${WORK}
git clone --depth=1 https://github.com/raspberrypi/firmware.git

openrcではなくsystemdを使いたかった

stage3のファイルをopenrcではなくsystgemdを利用した。 ダウンロードは下記のarm64の「systemd」を使った。

Downloads – Gentoo Linux

cd ${WORK}
tar xpf /mnt/gentoo_work/stage3-arm64-systemd-20250824T234925Z.tar.xz  --xattrs-include='*.*' --numeric-owner -C ${DEST}/

portage snapshot は jaistからダウンロードした http://ftp.jaist.ac.jp/pub/Linux/Gentoo/snapshots/ 昔からありがとう… 北陸先端科学技術大学院大学さん

Read more...

SDカードイメージを作成するテスト

背景

新しいバージョンを試したい。 調べてみると、 Build.Dist このツールを使うと自分でSDカードのイメージを作成できるらしい。 更に設定で自分好みのイメージが作れるらしい、凄い。

下記はエラーに対する試行錯誤、そのメモです。

ネットワークのトラブル、pingで疎通ができない。名前解決はできないのだがdigだと名前解決ができる

名前解決にdnssecを利用するようになった。

/etc/resolv.conf の内容

nameserver 127.0.0.53
options edns0 trust-ad
search .

edns0: EDNS(Extension mechanisms for DNS)のバージョン0を使用することを示す。 EDNSは、DNSプロトコルを拡張し、より大きなペイロード、改善されたセキュリティ(DNSSEC)、その他の機能をサポート。

trust-ad: DNSSECのAuthenticated Data(AD)フラグを信頼することを示す。 これは、DNSSECにより検証された応答を信頼し、使用することを意味。

DNSSECはサーバ側の時刻を利用する。 ラズパイを長いこと起動していなかったためか、あるいはchronyd, ntpdをインストールして設定が変わったからか、DNSSECが動作しなくなった。

ラズパイの時刻がずれていたので強制的に時刻を合わせる。

dig time.google.com で、googleのNTPサーバのIPアドレスを確認し、nptpdateで合わせる。

sudo systemctl stop ntpd
sudo ntpdate 216.239.35.4

今では systemd-timesyncd, chronydで時刻合わせを設定するようなので、知識をアップデートしたい。

scripts/binfmt.sh でエラーが出る

下記の箇所でエラーが出る。 qemuが必要。

if [ "${cpu}" != "arm" ] ; then
    if [[ ! -e /proc/sys/fs/binfmt_misc/arm ]]; then
        echo ":arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xf
f\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm:F" >> /proc/sys/fs/binfmt_misc/register
    fi
fi

下記のコマンドでqemuをインストールした。

Read more...

Build.distでビルドできなかったのでプルリクを作成した

背景

2023/06時点、ラズパイ上でのGentooが起動するGenPi64をゼロからイメージ作成するBuild.Distはイメージ作成に失敗する。

私が成功するまで3つ程、ハードルがあったのでプルリクを作成したい。 その時のメモ。

原因

parsers/rawcommand/rawcommand、シェルのヒアドキュメントの箇所で、本来、タブであるべき所が空白になってしまっている。

画面上は分かりにくいがgit pullすると確認できる。 また全てのシェルスクリプトがNGという訳ではなく、他のシェルスクリプトはタブになっていた。

この問題に起因すると思われるイシュー

issueで挙がってないか確認

過去の経緯を軽く確認

https://raw.githubusercontent.com/GenPi64/Build.Dist/master/parsers/rawcommand/rawcommand 空白かもしれない。タブの方が良い。

Read more...

Build.distのメモ

概要

RasberyPi用のGentooであるGenPi64というプロジェクトがある。

ただアップされているイメージが古い、様子。 新しいGentooを試したい。

GenPi64のイメージを作製するには GenPi64/Build.Dist: Build scripts for building GenPi64 images.を使う。

仕組みは非常に合理的というか良くできている、が、うまく動かなかったので仕組みを調べている。 これはそのメモ。

サイト内関連ページ

手順

事前準備

必要なパッケージ追加

sudo emerge --ask dev-python/lockfile dev-python/iniparse sys-fs/btrfs-progs sys-fs/dosfstools sys-block/parted
sudo QEMU_USER_TARGETS="aarch64 arm" QEMU_SOFTMMU_TARGETS="aarch64 arm" USE="static-libs" emerge --changed-use --ask  --newuse  --quiet app-emulation/qemu

以前は dev-python/pychroot も必要としていた。 が、pychrootが2023/12/22にアーカイブされてしまい、Gentooとしてもパッケージが存在しないようになってる。 GitHub - pkgcore/pychroot: a python library and cli tool that simplify chroot handling

この人も困ってそうではあるが User:Maffblaster/Todo - Gentoo Wiki

quick start

https://github.com/GenPi64/Build.Dist/ を git pull し、ディレクトリに移動

sudo -s
bash
export PROJECT="GenPi64Systemd"
. env.sh
sh build.sh

仕組み

sh build.sh を行った際の進み方

Read more...

Gentooでkubernetesのセットアップに失敗した

事前準備

  • 固定 IP 化
  • swap を無効化
  • docker のインストールと自動起動

cgroup で CPU とメモリーが有効になっている必要がある

Gentoo で OpenRC だと /etc/rc.conf で設定する。

Gentoo側は Cgroup v1 と v2 の設定が選べる(hybrit になるようだ)。 Kubernetes での Cgroup v2 サポートは Docker で Docker Engine 20.10 から実装された模様

2021/10/10 時点の 私の Gentoo の Docker のバージョンを確認した所、20.10.7 だった。 kubernetes は 1.22 から Cgroup v2 をサポートした模様 参考 Kubernetes 1.22 における新機能は?

なぜ失敗しているのか?

kubeletやkubeadmのコンパイルは上手くいく。そういう観点でパッケージメンテナの作業は成功している。 kubeletも起動している。kubeadm –dry-runも正常に終了する。が実際にkubeadmで構築する段階で失敗している。 ここまま検証するより、一度、正常に動作しているkubenetesと比較した方が検証が進みやすそうだったので、構築できたk3s.ioを用いて検証を続けている。

kubernetes をインストールする

gentoo は標準でパッケージが用意されていたので、それでどこまで行けるか確認してみる。

パッケージインストール

app-admin/helm がマスクされていたのでマスクを外す。

cat << EOF | sudo tee -a /etc/portage/package.accept_keywords
app-admin/helm **
EOF
cat /etc/portage/package.accept_keywords
sudo emerge --ask  --quiet --verbose --verbose-conflicts  app-admin/helm sys-cluster/kubeadm sys-cluster/kubectl sys-cluster/kubelet \
  app-emulation/flannel net-firewall/conntrack-tools sys-apps/ethtool net-firewall/ebtables net-misc/socat

kubeadm init を –dry-run で実行、エラーが起きない事を確認する

sudo kubeadm init --dry-run --pod-network-cidr=10.244.0.0/16
cgroup でエラーが起きた
CGROUPS_MEMORY: missing

memory と /proc/cgroup を確認すると memory の enabled を見ると 0 、off になっているようだ。 memory を有効にすることを考える。

Read more...

RaspberryPiでUSBブートを試みる

背景

SD カードが壊れた。最近のラズパイは HDD ブートに対応しているので HDD ブートで Gentoo を起動した。 作業としては通常の RaspberrypiOS で起動、(新しいラズパイなら不要だと思うが私は必要だった)ファームウェアのアップデートを行い、 Genpi64 のイメージをダウンロード、HDD に書き出し、起動した。ハマるポイントは無く、意外とスムーズに起動した。 2021/09/28 RaspberryPi 4B で確認した。 Raspberry Pi 2B、3A+、3B、3B+の場合、手順は異なるかもしれない。

手順

ファームウェアが古い場合はアップデート

HDD ブートはファームウェアが「2020-09-03」以降である必要がある。

参考 [SDカード不要? 「Raspberry Pi 4」をUSBブートさせる方法について https://gadgetrip.jp/2021/05/raspberry_pi4_usb_boot/ ラズパイ4を完全 USB Boot 化

コマンド効果
vcgencmd bootloader_version現在のブートローダーのバージョンを確認
rpi-eeprom-updateアップデートがあるか確認
sudo rpi-eeprom-update -aアップデート

ファームウェアのバージョンを確認するため rpi-imager をRaspberrypiOS のページからダウンロードして、SD カードに書き込み起動する。 ラズパイ4を完全 USB Boot 化を参考にさせていただきファームウェアのアップデートを行った。

私の /etc/default/rpi-eeprom-update は default だった。

pi@raspberrypi:~ $ cat /etc/default/rpi-eeprom-update
FIRMWARE_RELEASE_STATUS="default"
最近のラズパイ OS だと、初回起動時のアップデートを行うとファームが最新にアップデートされる模様

購入直後の状態で USB ストレージを刺してとりあえず起動するか確認したが、ファームが古くだめだった。 ラズパイ OS の SD から起動し、初回起動時に現れるアップデートでアップデートするとファームウェアが最新のものに変更された。

Read more...

Gentoo ラズパイ関連

gentoo-on-rpi-64bit 初期セットアップ

ココに書いてあるものをなぞった このページにラズパイで Gentoo を便利に稼働させる細かいノウハウがあるので一読した方が良い。これを作った sakaki- 氏すごい。 Gentoo 一般についてはGentoo Linux amd64 ハンドブック:Gentoo での作業にまとまっている。

条件

  • Linux マシン( Ubuntu 21.04 ) で行った。
  • 解凍に zstd が必要
  • Xfce, LibreOffice, VLC, Kodi, GIMP などを含むデスクトップ環境を選択した(ライトイメージもある)
  • ライトイメージの場合、解凍されたファイル名も異なるので読み替えが必要

手順

SD カードが刺さっているパスを確認する

SD カードを Linux マシンに刺した上で /var/log/syslog を確認するか lsblk で確認する。

sudo lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 223.6G  0 disk
├─sda1   8:1    0   300M  0 part /boot/efi
└─sda2   8:2    0 223.3G  0 part /
sdb      8:16   1  28.9G  0 disk
├─sdb1   8:17   1   255M  0 part
└─sdb2   8:18   1  28.6G  0 part

私の場合は /dev/sdb で認識されていた。

Read more...

GenPi64でrootパーティションの拡張

partedを起動

GenPi64 /home/demouser $ sudo parted
GNU Parted 3.6
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.

セクタ単位に表示を切り替え

(parted) unit s

空きスペース確認

(parted) print free
Model: SATA SSD  (scsi)
Disk /dev/sda: 468862128s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start     End         Size        Type     File system  Flags
        63s       2047s       1985s                Free Space
         1      2048s     524287s     522240s     primary  fat16        boot, lba
         2      524288s   9682946s    9158659s    primary  btrfs
         9682947s  468862127s  459179181s           Free Space

resizeは使えない

Read more...

Softether関連

ソースからインストール

環境

gentto raspi64に Softether をインストール

手順
git clone https://github.com/SoftEtherVPN/SoftEtherVPN_Stable.git
cd SoftEtherVPN_Stable
./configure && make -j5 && sudo make install
インストール後のファイル構成

/usr/{vpnbridge, vpnclient, vpncmd, vpnserver} ディレクトリが作成され、 例えば/usr/vpncmd配下には hamcore.se2, vpncmd など必要なファイルが設置される。

2021/08時点では設定ファイルもこのディレクトリ配下にいくつか置かれている。

この hamcore.se2のパーミッションは

-rw------- 1 root root 2009296  8月 18 12:33 hamcore.se2

なので、rootで実行する必要がある。

sudo vpncmd

rootで実行しないと下記のエラーがでた。

-- Alert: SoftEther VPN Kernel --
Fatal Error: The file "hamcore.se2" is missing or broken.
Please check hamcore.se2.

(First, reboot the computer. If this problem occurs again, please reinstall VPN software files.)

コマンドサーチパスの/usr/bin 配下に下記がインストールされる。

Read more...

Gentoo distccd Docker

背景

Gentoo の Docker イメージが作りたい。が、

  1. オフィシャルの gentoo/stage3-amd64 の更新頻度が低い( 2021/08/08 時点で以前のアップデートが 1 年前だった )
  2. portage 用のイメージ gentoo/portageがあり、こちらは毎日更新されている。
  3. コマンドや glibc などが置かれているビルド済みの領域は gentoo/stage3-amd64 に置かれているため、実際に使うときには emerge –update –deep –newuse @world とリビルドが必要
  4. リビルドするとイメージのサイズがかなり増える

が、できればコンパクトなイメージにしたい。

結論(2021/08/17 時点)

docker-slimを使ってイメージをコンパクトにする方法が一番コンパクトになった。

手法サイズ備考
ダウンサイジング前3.04GB
不要なディレクトリの削除1.8GBemerge が一時的に使うファイル郡
(上記ディレクトリ削除に加えて)不要なパッケージの削除983MBパッケージ一覧を見ながら不要そうなパッケージを削除
docker-slim39MB

Dockerfile サンプル

ここに公開した

手法の比較

不要なディレクトリ削除は emerge が一時的に使うファイル郡を削除するだけなので安全に使える。

不要なパッケージの削除だが、これはパッケージ名の変更やパッケージ同士の依存関係の変更があると 必須ではないが、都度 Dockerfile の修正が必要になり長期間の運用を考えると、運用コストが上がる。

docker-slim を使った方法が一番コンパクトになった。ただ docker-slim は必要なファイルを動的に解析して必要なファイルのみを残すので、解析できるように準備する必要がある。

portage 用のイメージ gentoo/portageを使った方が良いのか?

RUN emerge –sync でも同様な事はできるので… と思ったが、毎回 emerge –sync に時間が取られるのは無駄。 もし「Docker のキャッシュで古い状態でビルドされるのが嫌だ」という場合でも、キャッシュを使わないオプションで docker build すれば最新の状態でビルドできる。

Read more...

make.confのメモ

make.confの FEATURES のメモ

私が良く使う、あるいは検討したもの。man make.confでも確認できる。

distccのサーバ/クライアント設定

distcc サーバーを建てる

概要

ラズパイ Gentoo GenPi64 でのコンパイルに時間がかかるので、 amd64 のマシンの docker 上にクロスコンパイル環境を構築、 distcc デーモンを立てて、ラズパイがクライアント、amd64 が distcc サーバの構成でコンパイルを早くした。

手順

distcc が起動する docker コンテナを作る

distcc への接続確認

telnet コマンドでポート 3632 に接続。 切断は Ctrl + ] を押してから Ctrl + d

$ telnet localhost 3632
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
^]
telnet> Connection closed.

GenPi64 distcc クライアント側の設定

GenPi64 は distcc はインストール済みなので emerge は不要。ただし

  1. gcc のプロファイルを揃える
  2. distcc サーバーの IP アドレスの追加 は必要。

gcc のプロファイルを確認

Read more...

Gentoo Linuxで依存関係のあれこれを残す

依存関係のエラーをまとめる

私の短い経験と調査で得られたものを追加していく…

  1. @world の指定は大きすぎる場合がある。 @system で試すと必要なパッケージのアップデートはできるかもしれない。
  2. 個別のパッケージでアップデートを試みてみる。
  3. @preserved-rebuild と出たら emerge -1 @preserved-rebuild を行う
  4. dispatch-conf を行う
  5. マスクされている場合マスクされたパッケージをインストールする方法
  6. USE フラグの変更が必要

configure で失敗

2021/08/09 perl の gettext が必要との事

checking whether x86_64-pc-linux-gnu-gcc accepts -g... yes
checking for x86_64-pc-linux-gnu-gcc option to accept ISO C89... none needed
checking for library containing dlsym... -ldl
checking for library containing bindtextdomain... none required
configure: error: perl module Locale::gettext required

eix gettext で検索して必要そうなパッケージを追加した

RUN emerge sys-devel/gettext dev-perl/Locale-gettext

2023/06 ToDo

一旦、下記のmaskで自宅のラズパイ全部を最新にする

Read more...

Gentoo周りのメモ

/etc/portage/gnupg が無い、というエラーが出る

gpg: keyblock リソース'/etc/portage/
gnupg/pubring.kbx': そのようなファイルやディレクトリはありません\n
[GNUPG:] ERROR add_keyblock_resource 33587281\n
[GNUPG:] PLAINTEXT 740 \n
[GNUPG:] NEWSIG\ngpg: 2023年09月03日 07時32分03秒 JSTに施された署名\n
gpg:                RSA鍵534E4209AB49EEE1C19D96162C44695DB9F6043Dを使用\n
[GNUPG:] ERROR keydb_search 33554445\n
[GNUPG:] ERROR keydb_search 33554445\n
[GNUPG:] ERRSIG 2C44695DB9F6043D 1 10 01 1693693923 9 534E4209AB49EEE1C19D96162C44695DB9F6043D\n
[GNUPG:] NO_PUBKEY 2C44695DB9F6043D\ngpg: 署名を検査できません: 公開鍵がありません\n

私の場合は /etc/portage/make.conf に –getbinpkg を追加したからだった。

バイナリパッケージの OpenPGP 署名を検証する

Portage は可能であればいつでもバイナリパッケージの署名の検証を試みますが、
そのためにはまず、信頼されたローカル鍵を構成する必要があります。
app-portage/getuto は、ローカルのトラストアンカーをセットアップし、
/etc/portage/gnupg 内の鍵を更新するために使用することができます。
--getbinpkg または --getbinpkgonly を使用すると、Portage は自動的に getuto を呼び出します。

対応方法としては

  • getutoコマンドをインストール
  • getutoを実行
    • 1度実行すると /etc/portage/gnupg ディレクトリが作成され初期化される
    • この初期化が完了すればemergeも正常に進行する

パッケージの USE フラグ

/etc/portage/package.use/ 配下に置くようにした。

Read more...

emergeする際のテンポラリファイルの置き場所の変更

背景

GenPi64で/var/tmpがzramでマウントされていた。 これ自体は高速化されるので嬉しい。

ただメモリを使うzramの場合、メモリが小さいマシンでは/var/tmpが小さくなり、gccのビルドに失敗する。 このためローカルディスクを使うように変更した。

sudo mkdir /var/portage && sudo chmod 775 /var/portage && sudo chown portage:portage /var/portage
sudo vi /etc/portage/make.conf

下記を追記

PORTAGE_TMPDIR="/var/portage"
Read more...