You are not logged in.

#1 2022-03-20 12:58:44

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 1,975
Website

[SOLVED] Rebuild initramfs for ALARM from Arch Linux

I want to rebuild an Arch Linux ARM initramfs image from my running Arch Linux (x86_64) workstation.
Obviously, I cannot just chroot into the mounted root directory of the target system and run mkinitcpio in the chroot, since the binary there is compiled for ARM.
I had a look at mkinitcpio -h and found several options to change build dirs, hook dirs and similar stuff.
I started fiddling with some of these options to no avail so far:

$ LANG=C mkinitcpio --config etc/mkinitcpio.conf --generatedir boot/ --hookdir usr/share/libalpm/hooks
ln: failed to create symbolic link 'boot//lib/lib': File exists
ln: failed to create symbolic link 'boot//usr/local/lib/lib': File exists
ln: failed to create symbolic link 'boot//usr/sbin/bin': File exists
ln: failed to create symbolic link 'boot//bin/bin': File exists
ln: failed to create symbolic link 'boot//sbin/bin': File exists
ln: failed to create symbolic link 'boot//usr/local/bin/bin': File exists
ln: failed to create symbolic link 'boot//usr/local/sbin/bin': File exists
ln: failed to create symbolic link 'boot//var/run/run': File exists
ln: failed to create symbolic link 'boot//usr/lib64/lib': File exists
ln: failed to create symbolic link 'boot//lib64/lib': File exists
ln: failed to create symbolic link 'boot//etc/mtab': File exists
==> Starting build: 5.16.15-arch1-1
==> ERROR: Hook 'base' cannot be found
==> ERROR: Hook 'systemd' cannot be found
==> ERROR: Hook 'keyboard' cannot be found
==> ERROR: Hook 'keymap' cannot be found
==> ERROR: Hook 'autodetect' cannot be found
==> ERROR: Hook 'modconf' cannot be found
==> ERROR: Hook 'block' cannot be found
==> ERROR: Hook 'filesystems' cannot be found
==> ERROR: Hook 'keyboard' cannot be found
==> ERROR: Hook 'fsck' cannot be found
zstd: boot//lib/modules/5.16.15-arch1-1/kernel/f2fs.ko already exists; not overwritten  
zstd: boot//lib/modules/5.16.15-arch1-1/kernel/crc32-pclmul.ko already exists; not overwritten  
zstd: boot//lib/modules/5.16.15-arch1-1/kernel/fat.ko already exists; not overwritten  
zstd: boot//lib/modules/5.16.15-arch1-1/kernel/lz4hc_compress.ko already exists; not overwritten  
zstd: boot//lib/modules/5.16.15-arch1-1/kernel/crc32_generic.ko already exists; not overwritten  
==> Generating module dependencies
==> Build complete.

Since I don't know the details of what mkinitcpio does under the hood, I wonder whether it is even possible to do what I intend and whether somebody may already successfully has done this.

Solution
I cannot reproduce what I did wrong before, but after some more fiddling around, *arch-chroot* seems to be able to transparently chroot into different architectures:
My other system was missing qemu-arm-static-bin which was required by chroot to chroot into an ARM system.

0 ✓ thinkpad ~ $ uname -a
Linux thinkpad 5.16.15-zen1-1-zen #1 ZEN SMP PREEMPT Thu, 17 Mar 2022 00:30:11 +0000 x86_64 GNU/Linux
0 ✓ thinkpad ~ $ arch-chroot alarm mkinitcpio -P
==> WARNING: alarm is not a mountpoint. This may have undesirable side effects.
==> Building image from preset: /etc/mkinitcpio.d/linux-rpi.preset: 'default'
  -> -k 5.15.27-1-rpi-ARCH -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img
==> Starting build: 5.15.27-1-rpi-ARCH
  -> Running build hook: [base]
  -> Running build hook: [systemd]
  -> Running build hook: [keyboard]
  -> Running build hook: [keymap]
loadkeys: Unable to open file: de: No such file or directory
  -> Running build hook: [autodetect]
==> ERROR: failed to detect root filesystem
findmnt: can't read (null): No such file or directory
  -> Running build hook: [modconf]
  -> Running build hook: [block]
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux.img
==> Image generation successful
0 ✓ thinkpad ~ $ 

The root file system error is not an issue, since I added the appropriate drivers explicitly via MODULES.

Last edited by schard (2022-03-21 16:03:22)


macro_rules! yolo { { $($tokens:tt)* } => { unsafe { $($tokens)* } }; }

Offline

Board footer

Powered by FluxBB