You are not logged in.
Hello,
I cannot generate the initramfs images using the linux preset anymore. I didn't touch those files at all.
I get the following error:
$ sudo mkinitcpio -p linux
[sudo] password for spiri:
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'default'
-> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img
Error: [-n]: Cannot open for reading
==> ERROR: invalid kernel specified: `/boot/vmlinuz-linux'
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'fallback'
-> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-fallback.img -S autodetect
Error: [-n]: Cannot open for reading
==> ERROR: invalid kernel specified: `/boot/vmlinuz-linux'
I solved the problem by mounting the system on a Live CD, doing arch-chroot and run mkinitcpio.
But when I boot to my system and doing mkinitcpio I get the same error. Like I had specified an invalid kernel but it isn't.
$ file /boot/vmlinuz-linux
/boot/vmlinuz-linux: Linux kernel x86 boot executable bzImage, version 5.4.14-arch1-1 (linux@archlinux) #1 SMP PREEMPT Thu, 23 Jan 2020 10:07:05 +0000, RO-rootFS, swap_dev 0x6, Normal VGA
$ ls /lib/modules
5.4.14-arch1-1
$ uname -r
5.4.14-arch1-1
linux.preset file:
# mkinitcpio preset file for the 'linux' package
ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-linux"
PRESETS=('default' 'fallback')
#default_config="/etc/mkinitcpio.conf"
default_image="/boot/initramfs-linux.img"
#default_options=""
#fallback_config="/etc/mkinitcpio.conf"
fallback_image="/boot/initramfs-linux-fallback.img"
fallback_options="-S autodetect"
How can I solve this problem?
I want to run mkinitcpio without errors live on my system.
/boot partition is ext2 using rw,relatime mount options in fstab.
Also, boot is properly mounted.
Last edited by spiri (2020-02-05 12:18:09)
Offline
==> ERROR: invalid kernel specified: `/boot/vmlinuz-linux'
Never seen that before... try reinstalling the kernel package which will recreate that file and then run that command. Any change?
As an aside, why are you using ext2 for anything?
Last edited by graysky (2020-01-26 10:33:16)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Never seen that before... try reinstalling the kernel package which will recreate that file and then run that command. Any change?
No.
As an aside, why are you using ext2 for anything?
I now use vfat for the boot partition.
TARGET SOURCE FSTYPE OPTIONS
/boot /dev/sda2 vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro
Offline
Remove option 'errors=remount-ro'. It was it some thread that it cause problems with boot partition.
Offline
This looks weird:
Error: [-n]: Cannot open for reading
bash #run a new bash instance (has to be bash, not zsh, fish, etc.)
source /usr/lib/initcpio/functions # source the mkinitcpio functions
type kver # should now be a script
set +x # make bash talk a lot
kver /boot/vmlinuz-linux # run the function that figures the kernel version
Online
Remove option 'errors=remount-ro'. It was it some thread that it cause problems with boot partition.
That problem was (probably) caused by corruption on the FAT-formatted partition, the remount-ro option just exposed it in a non-obvious way. As it is applied automatically if no options are explicitly specified then it's probably a good idea to leave it in, it should prevent further damage to the filesystem if there are any errors.
@OP: you only need to have a FAT-formatted /boot partition if you're using it as an EFI system partition.
Para todos todo, para nosotros nada
Offline
This looks weird:
Error: [-n]: Cannot open for reading
bash #run a new bash instance (has to be bash, not zsh, fish, etc.) source /usr/lib/initcpio/functions # source the mkinitcpio functions type kver # should now be a script set +x # make bash talk a lot kver /boot/vmlinuz-linux # run the function that figures the kernel version
Hello. I get the following output:
/usr/lib/initcpio/functions: line 811: syntax error near unexpected token `('
/usr/lib/initcpio/functions: line 811: ` rm "$moduledest"/modules.!(*.bin|devname|softdep)'
kver is a function
kver ()
{
local kver re='^[[:digit:]]+(\.[[:digit:]]+)+';
local offset=$(hexdump -s 526 -n 2 -e '"%0d"' "$1");
[[ $offset = +([0-9]) ]] || return 1;
read kver _ < <(dd if="$1" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null);
[[ $kver =~ $re ]] || return 1;
printf '%s' "$kver"
}
Error: [-n]: Cannot open for reading
I also tried to fix the script error. Same result.
Offline
Are there any filesystem problems?
# umount /boot
# fsck.fat /dev/sda2
# mount /boot
And where are the fifth & sixth fields in your fstab line? Did you crop them or are they missing?
Para todos todo, para nosotros nada
Offline
Are there any filesystem problems?
# umount /boot # fsck.fat /dev/sda2 # mount /boot
I think its clean
# fsck.fat /dev/sda2
fsck.fat 4.1 (2017-01-24)
/dev/sda2: 328 files, 19564/261628 clusters
And where are the fifth & sixth fields in your fstab line? Did you crop them or are they missing?
My fstab is okay. Everything is mounted properly.
Offline
Why would it throw a syntax error at this point?
Please run "bash --norc" and try again.
Online
Why would it throw a syntax error at this point?
Because of the parentheses in the line
rm "$moduledest"/modules.!(*.bin|devname|softdep)
Please run "bash --norc" and try again.
# bash --norc
bash-5.0# ./fix-initcpio.run
/usr/lib/initcpio/functions: line 811: syntax error near unexpected token `('
/usr/lib/initcpio/functions: line 811: ` rm "$moduledest"/modules.!(*.bin|devname|softdep)'
kver is a function
kver ()
{
local kver re='^[[:digit:]]+(\.[[:digit:]]+)+';
local offset=$(hexdump -s 526 -n 2 -e '"%0d"' "$1");
[[ $offset = +([0-9]) ]] || return 1;
read kver _ < <(dd if="$1" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null);
[[ $kver =~ $re ]] || return 1;
printf '%s' "$kver"
}
Error: [-n]: Cannot open for reading
Offline
Why would it throw a syntax error at this point?
Because of the parentheses in the line
rm "$moduledest"/modules.!(*.bin|devname|softdep)
Apparently, they are doing some regex operations although this is not legal in bash.
Please run "bash --norc" and try again.
# bash --norc
bash-5.0# ./fix-initcpio.run
/usr/lib/initcpio/functions: line 811: syntax error near unexpected token `('
/usr/lib/initcpio/functions: line 811: ` rm "$moduledest"/modules.!(*.bin|devname|softdep)'
kver is a function
kver ()
{
local kver re='^[[:digit:]]+(\.[[:digit:]]+)+';
local offset=$(hexdump -s 526 -n 2 -e '"%0d"' "$1");
[[ $offset = +([0-9]) ]] || return 1;
read kver _ < <(dd if="$1" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null);
[[ $kver =~ $re ]] || return 1;
printf '%s' "$kver"
}
Error: [-n]: Cannot open for reading
Sorry for double posting
Last edited by spiri (2020-01-27 18:34:50)
Offline
What is ./fix-initcpio.run ?
This will run a subshell and source the rcs.
Actually run "bash --norc" and then "source /usr/lib/initcpio/functions" - there's nothing wrong w/ the line as is in the file - the single quotes in your output looks weird, though.
localectl
locale
locale -a
Online
@seth,
# bash --norc
bash-5.0# source /usr/lib/initcpio/functions # source the mkinitcpio functions
bash: /usr/lib/initcpio/functions: line 811: syntax error near unexpected token `('
bash: /usr/lib/initcpio/functions: line 811: ` rm "$moduledest"/modules.!(*.bin|devname|softdep)'
bash-5.0# type kver # should now be a script
kver is a function
kver ()
{
local kver re='^[[:digit:]]+(\.[[:digit:]]+)+';
local offset=$(hexdump -s 526 -n 2 -e '"%0d"' "$1");
[[ $offset = +([0-9]) ]] || return 1;
read kver _ < <(dd if="$1" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null);
[[ $kver =~ $re ]] || return 1;
printf '%s' "$kver"
}
bash-5.0# set +x # make bash talk a lot
bash-5.0# kver /boot/vmlinuz-linux # run the function that figures the kernel version
Error: [-n]: Cannot open for reading
bash-5.0# localectl
System Locale: LANG=en_US.UTF-8
LANGUAGE=lb_LU:en
LC_CTYPE=lb_LU.UTF-8
LC_NUMERIC=lb_LU.UTF-8
LC_TIME=lb_LU.UTF-8
LC_COLLATE=lb_LU.UTF-8
LC_MONETARY=lb_LU.UTF-8
LC_MESSAGES=lb_LU.UTF-8
LC_PAPER=lb_LU.UTF-8
LC_NAME=lb_LU.UTF-8
LC_ADDRESS=lb_LU.UTF-8
LC_TELEPHONE=lb_LU.UTF-8
LC_MEASUREMENT=lb_LU.UTF-8
LC_IDENTIFICATION=lb_LU.UTF-8
VC Keymap: fr_CH
X11 Layout: ch
X11 Variant: fr
bash-5.0# locale
LANG=en_US.UTF-8
LC_CTYPE=lb_LU.UTF-8
LC_NUMERIC=lb_LU.UTF-8
LC_TIME=lb_LU.UTF-8
LC_COLLATE=lb_LU.UTF-8
LC_MONETARY=lb_LU.UTF-8
LC_MESSAGES=lb_LU.UTF-8
LC_PAPER=lb_LU.UTF-8
LC_NAME=lb_LU.UTF-8
LC_ADDRESS=lb_LU.UTF-8
LC_TELEPHONE=lb_LU.UTF-8
LC_MEASUREMENT=lb_LU.UTF-8
LC_IDENTIFICATION=lb_LU.UTF-8
LC_ALL=
bash-5.0# locale -a
C
en_US.utf8
lb_LU
lb_LU.utf8
POSIX
bash-5.0#
Offline
export LANG=C
export LC_ALL=C
bash --norc
source /usr/lib/initcpio/functions
Still an error?
Online
$ export LANG=C
$ export LC_ALL=C
$ bash --norc
bash-5.0$ source /usr/lib/initcpio/functions
bash: /usr/lib/initcpio/functions: line 811: syntax error near unexpected token `('
bash: /usr/lib/initcpio/functions: line 811: ` rm "$moduledest"/modules.!(*.bin|devname|softdep)'
bash-5.0$
Offline
GRUMPF!
I'm very sure this worked fine, but I've to admit that I get the very error on bash atm. (maybe I ran a sub-zsh instead? I'll look into that)
However, the kver() function works fine despite the error, so it's insignificant - sorry for wasting your time on this.
Online
What can I do now?
The system needs to do mkinitcpio sometimes.
Last edited by spiri (2020-01-27 19:59:24)
Offline
It still fails somewhere in the kver() call, we need to figure where exactly.
Continuing w/ my earlier fuck-ups, it's "set -x" to get bash debug output ("set +x" disables it) - apparently my brain was broken.
So run that, then "kver /boot/vmlinuz-linux" so we hopefully get a better idea where the read error appears.
Online
The error appears in hexdump.
kver is a function
kver ()
{
local kver re='^[[:digit:]]+(\.[[:digit:]]+)+';
local offset=$(hexdump -s 526 -n 2 -e '"%0d"' "$1");
[[ $offset = +([0-9]) ]] || return 1;
read kver _ < <(dd if="$1" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null);
[[ $kver =~ $re ]] || return 1;
printf '%s' "$kver"
}
+ kver /boot/vmlinuz-linux
+ local kver 're=^[[:digit:]]+(\.[[:digit:]]+)+'
++ hexdump -s 526 -n 2 -e '"%0d"' /boot/vmlinuz-linux
Error: [-n]: Cannot open for reading
+ local offset=
+ [[ '' = +([0-9]) ]]
+ return 1
Offline
type hexdump
pacman -Qo `which hexdump`
pacman -Qikk util-linux
This kind of stuff…
Online
# type hexdump
hexdump is hashed (/usr/local/bin/hexdump)
# pacman -Qo `which hexdump`
error: No package owns /usr/local/bin/hexdump
# pacman -Qikk util-linux
Name : util-linux
Version : 2.35-1
Description : Miscellaneous system utilities for Linux
Architecture : x86_64
URL : https://github.com/karelzak/util-linux
Licenses : GPL2
Groups : None
Provides : rfkill
Depends On : pam shadow coreutils systemd-libs libcap-ng libutil-linux
Optional Deps : python: python bindings to libmount [installed]
words: default dictionary for look
Required By : apr arch-install-scripts base fakeroot gupnp mkinitcpio ntfs-3g ostree rasqal systemd tracker zeromq
Optional For : None
Conflicts With : rfkill
Replaces : rfkill
Installed Size : 12,97 MiB
Packager : Christian Hesse <arch@eworm.de>
Build Date : Dë 21. Jan 2020 14:11:38
Install Date : So 26. Jan 2020 10:10:53
Install Reason : Installed as a dependency for another package
Install Script : No
Validated By : Signature
warning: util-linux: /usr (UID mismatch)
warning: util-linux: /usr (GID mismatch)
warning: util-linux: /usr/bin (UID mismatch)
warning: util-linux: /usr/bin (GID mismatch)
warning: util-linux: /usr/share (UID mismatch)
warning: util-linux: /usr/share (GID mismatch)
util-linux: 500 total files, 3 altered files
Offline
hexdump is hashed (/usr/local/bin/hexdump)
Well. There's your problem.
pacman -Qo /usr/local/bin/hexdump
file /usr/local/bin/hexdump
Online
Oh yes, thank you!
Offline
seth wrote:Why would it throw a syntax error at this point?
Because of the parentheses in the line
rm "$moduledest"/modules.!(*.bin|devname|softdep)
Apparently, they are doing some regex operations although this is not legal in bash.
GRUMPF!
I'm very sure this worked fine, but I've to admit that I get the very error on bash atm. (maybe I ran a sub-zsh instead? I'll look into that)
However, the kver() function works fine despite the error, so it's insignificant - sorry for wasting your time on this.
Actually this is a perfectly legal bash extglob, but extglobs are disabled by default and must be enabled by running "shopt -s extglob", which in fact /usr/bin/mkinitcpio does ( but /usr/lib/initcpio/functions does not, since it relies on the calling script to do so).
Also, spiri, since I assume your problem is solved now that you removed your nonstandard custom hexdump executable, please edit the first post of the thread and add "[Solved]" to the beginning of the thread title.
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline