You are not logged in.

#1 2022-01-31 08:06:52

climbTheStairs
Member
From: North America
Registered: 2021-09-22
Posts: 12

[SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

Today, after I turned on my computer, it failed to boot.  I was greeted with the message:

Loading Linux linux ...
Loading initial ramdisk ...
error: file '/initramfs-linux.img' not found

Press any key to continue...

Pressing any key did nothing, and the screen wouldn't change.

I booted with a live system and arch-chrooted in to look around, and I came to believe that the cause of the problem is the similar errors that occur whenever I try to update or install the packages linux and linux-firmware.

Using pacstrap yielded the same errors.

Running pacman -S linux or pacstrap /mnt linux:

==> ERROR: Unable to write to path: `/boot/initramfs-linux.img'
==> ERROR: Unable to write to path: `/boot/initramfs-linux-fallback.img'

Running pacman -S linux-firmware or pacstrap /mnt linux-firmware:

Failed to open file "/sys/devices/system/cpu/microcode/reload": Read-only file system

From my live system, I tried reformatting my boot partition and reinstalling GRUB:

mkfs.ext4 /dev/sda1
mount /dev/sda1 /mnt/boot
arch-chroot /mnt

pacman -Rns grub
pacman -S grub
grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

No errors occurred during this process, but it didn't solve anything.

Upon rebooting, I receive now see the screen frozen with the message:

Loading Linux linux ...

If I increase the verbosity in GRUB, I end up with a Kernel panic:

https://i.imgur.com/TOTVktj.jpeg

I've looked for hours to no avail, and I have no idea how to fix this.

----

Here is the full output of pacstrap /mnt linux...

stdout:

==> Creating install root at /mnt
==> Installing packages to /mnt
:: Synchronizing package databases...
core downloading...
extra downloading...
community downloading...
resolving dependencies...
looking for conflicting packages...

Packages (1) linux-5.16.4.arch1-1

Total Installed Size:  161.08 MiB
Net Upgrade Size:        0.00 MiB

:: Proceed with installation? [Y/n] 
checking keyring...
checking package integrity...
loading package files...
checking for file conflicts...
checking available disk space...
:: Processing package changes...
reinstalling linux...
:: Running post-transaction hooks...
(1/3) Arming ConditionNeedsUpdate...
(2/3) Updating module dependencies...
(3/3) Updating linux initcpios...
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'default'
-> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img
readlink: realpath /boot/initramfs-linux.img: No such file or directory
==> ERROR: Unable to write to path: `/boot/initramfs-linux.img'
==> 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
readlink: realpath /boot/initramfs-linux-fallback.img: No such file or directory
==> ERROR: Unable to write to path: `/boot/initramfs-linux-fallback.img'

stderr:

warning: linux-5.16.4.arch1-1 is up to date -- reinstalling
error: command failed to execute correctly

...and pacstrap /mnt linux-firmware...

stdout:

==> Creating install root at /mnt
==> Installing packages to /mnt
:: Synchronizing package databases...
core downloading...
extra downloading...
community downloading...
resolving dependencies...
looking for conflicting packages...

Packages (1) linux-firmware-20220119.0c6a7b3-2

Total Installed Size:  149.48 MiB
Net Upgrade Size:        0.00 MiB

:: Proceed with installation? [Y/n] 
checking keyring...
checking package integrity...
loading package files...
checking for file conflicts...
checking available disk space...
:: Processing package changes...
reinstalling linux-firmware...
:: Running post-transaction hooks...
(1/2) Creating temporary files...
Failed to open file "/sys/devices/system/cpu/microcode/reload": Read-only file system
(2/2) Arming ConditionNeedsUpdate...

stderr:

warning: linux-firmware-20220119.0c6a7b3-2 is up to date -- reinstalling
error: command failed to execute correctly

Last edited by climbTheStairs (2022-02-04 17:46:28)

Offline

#2 2022-01-31 08:43:57

seth
Member
Registered: 2012-09-03
Posts: 51,179

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

The kernel error says the root FS can't be mounted…

lsblk -f

and your grub config (/boot/grub/grub.cfg)
You can paste them into ix.io

lsblk -f | curl -F 'f:1=<-' ix.io
cat /boot/grub/grub.cfg | curl -F 'f:1=<-' ix.io

Last edited by seth (2022-01-31 08:44:19)

Online

#3 2022-01-31 09:18:27

climbTheStairs
Member
From: North America
Registered: 2021-09-22
Posts: 12

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

After manually mounting my partitions as they usually would be (because I can't boot at all):

Offline

#4 2022-01-31 11:50:23

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

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

# umount [/mnt]/boot
# fsck /dev/disk/by-uuid/55613467-559e-42af-b3ae-7421e021cf94

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

Offline

#5 2022-01-31 12:19:34

seth
Member
Registered: 2012-09-03
Posts: 51,179

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

Why is the root partition in the grub.cfg addressed as sda3 and not as " root=UUID=e7208f8b-2886-46ee-ba14-c7b6376658bc"?

Online

#6 2022-02-01 07:17:56

climbTheStairs
Member
From: North America
Registered: 2021-09-22
Posts: 12

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

schard wrote:
# umount [/mnt]/boot
# fsck /dev/disk/by-uuid/55613467-559e-42af-b3ae-7421e021cf94

I got the output:

fsck from util-linux 2.37.2
e2fsck 1.46.4 (18-Aug-2021)
/dev/sda1: clean, 380/51200 files, 40766/204800 blocks

After remounting, the same error persists, whether I run pacstrap /mnt linux, pacman -S linux, or mkinitcpio -p linux.

seth wrote:

Why is the root partition in the grub.cfg addressed as sda3 and not as " root=UUID=e7208f8b-2886-46ee-ba14-c7b6376658bc"?

That was what grub-mkconfig -o /boot/grub/grub.cfg generated.

Offline

#7 2022-02-01 07:28:29

seth
Member
Registered: 2012-09-03
Posts: 51,179

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

That was what grub-mkconfig -o /boot/grub/grub.cfg generated.

grub-mkconfig --version

If that's not a dated version, I'll update the question to "Why did you uncomment GRUB_DISABLE_LINUX_UUID=true in /etc/default/grub"?

Online

#8 2022-02-02 05:42:32

climbTheStairs
Member
From: North America
Registered: 2021-09-22
Posts: 12

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

I haven't edited /etc/default/grub before.

I checked and #GRUB_DISABLE_LINUX_UUID=true is still commented.

Again, I reformatted my /boot partition and tried reinstalling GRUB:

# grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.

# grub-mkconfig --version
grub-mkconfig (GRUB) 2.06

# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER document entry.
done

This is my /boot/grub/grub.cfg.

However, if I pacstrap the linux package first, then the results are different:

# mount /dev/sda3 /mnt
# mkfs.ext4 /dev/sda1
# mount /dev/sda1 /mnt/boot
# pacstrap /mnt linux
# arch-chroot /mnt

# grub-install /dev/sda
# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER document entry.
done

This is my /boot/grub/grub.cfg if I grub-mkconfig after pacstrapping linux.

Last edited by climbTheStairs (2022-02-02 08:12:08)

Offline

#9 2022-02-02 05:46:02

climbTheStairs
Member
From: North America
Registered: 2021-09-22
Posts: 12

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

I think the cause of my problem is with "mkinitcpio -p linux" unable to write to initramfs-linux.img, but I do not know what that means or why it is or how I can fix that.

Would it help if I tried installing a different bootloader?

Last edited by climbTheStairs (2022-02-02 05:46:20)

Offline

#10 2022-02-02 07:58:50

seth
Member
Registered: 2012-09-03
Posts: 51,179

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

ls -l /mnt/boot
findmnt /boot
mount | grep boot

pacstrap is not supposed to be run from within the chroot but my guess would be that you're somehow™ operating on the /boot partition of the installation iso.

Skip pacstrap, mount /mnt and /mnt/boot, arch-chroot into mount and run "pacman -S linux": what errors do you get and then try

mkinitcpio -v -p linux

Online

#11 2022-02-02 10:11:41

climbTheStairs
Member
From: North America
Registered: 2021-09-22
Posts: 12

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

seth wrote:
ls -l /mnt/boot
findmnt /boot
mount | grep boot

Do I run these commands from the live system or from inside the chroot?  I'm assuming the first is run outside the chroot and the last two are to be run inside?

# ls -l /mnt/boot
total 10285
drwxr-xr-x 6 root root     1024 Feb  2 08:23 grub
drwx------ 2 root root    12288 Feb  2 08:20 lost+found
-rw-r--r-- 1 root root 10518432 Feb  2 08:22 vmlinuz-linux

# arch-chroot /mnt

# findmnt /boot
TARGET SOURCE    FSTYPE OPTIONS
/boot  /dev/sda1 ext4   rw,relatime

# mount | grep boot
/dev/sda1 on /boot type ext4 (rw,relatime)

pacstrap is not supposed to be run from within the chroot but my guess would be that you're somehow™ operating on the /boot partition of the installation iso.

I know, I ran pacstrap outside, from the live system.  Sorry if I made that unclear.

Skip pacstrap, mount /mnt and /mnt/boot, arch-chroot into mount and run "pacman -S linux": what errors do you get and then try

mkinitcpio -v -p linux

With "pacman -S linux" (full output) as well as "mkinitcpio -v -p linux" (stdout/stderr), I got the same errors as before:

==> ERROR: Unable to write to path: `/boot/initramfs-linux.img'
==> ERROR: Unable to write to path: `/boot/initramfs-linux-fallback.img'

Last edited by climbTheStairs (2022-02-02 10:13:25)

Offline

#12 2022-02-02 11:07:39

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

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

readlink: realpath /boot/initramfs-linux.img: No such file or directory

Well, I suppose that "realpath /boot/initramfs-linux.img" is not a valid directory.
Please show us

$ cat /etc/mkinitcpio.d/*
$ sha1sum /usr/share/libalpm/scripts/mkinitcpio-install
$ sha1sum /usr/share/libalpm/hooks/90-mkinitcpio-install.hook
$ sha1sum /usr/bin/mkinitcpio

Last edited by schard (2022-02-02 11:41:26)


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

Offline

#13 2022-02-02 11:51:13

seth
Member
Registered: 2012-09-03
Posts: 51,179

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

Deep in the back of my head there was an error where something (somethingsomething haskell??) shadowed a binary invoked by the mkinitcpio script and screwed the outcome.

bash -x /usr/bin/mkinitcpio -v -p linux | curl -F 'f:1=<-' ix.io

Online

#14 2022-02-03 07:42:34

climbTheStairs
Member
From: North America
Registered: 2021-09-22
Posts: 12

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

schard wrote:
readlink: realpath /boot/initramfs-linux.img: No such file or directory

Well, I suppose that "realpath /boot/initramfs-linux.img" is not a valid directory.
Please show us

$ cat /etc/mkinitcpio.d/*
$ sha1sum /usr/share/libalpm/scripts/mkinitcpio-install
$ sha1sum /usr/share/libalpm/hooks/90-mkinitcpio-install.hook
$ sha1sum /usr/bin/mkinitcpio

The only file in /etc/mkinitcpio.d/ is linux.preset.

And:

6a9ffec73d2db4681808d61ca4898c943f0fc7de  /usr/share/libalpm/scripts/mkinitcpio-install
d7642b750767d78f128c4613b6552e624ea9d5ed  /usr/share/libalpm/hooks/90-mkinitcpio-install.hook
5ae27286ee83b32d23820da383754f2007b9bb52  /usr/bin/mkinitcpio
seth wrote:

Deep in the back of my head there was an error where something (somethingsomething haskell??) shadowed a binary invoked by the mkinitcpio script and screwed the outcome.

bash -x /usr/bin/mkinitcpio -v -p linux | curl -F 'f:1=<-' ix.io

stdout
stderr

Offline

#15 2022-02-03 08:33:14

seth
Member
Registered: 2012-09-03
Posts: 51,179

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

Fails in the subprocess…

bash -x /usr/bin/mkinitcpio -v -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img

Online

#16 2022-02-03 09:02:09

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

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

$ type realpath readlink

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

Offline

#17 2022-02-04 11:22:30

climbTheStairs
Member
From: North America
Registered: 2021-09-22
Posts: 12

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

seth wrote:

Fails in the subprocess…

bash -x /usr/bin/mkinitcpio -v -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img

I ran that command and now everything works normally.  I really appreciate your help!  Thank you all so much!!!

Offline

#18 2022-02-04 11:58:26

seth
Member
Registered: 2012-09-03
Posts: 51,179

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

That's weird but please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Online

#19 2022-02-15 09:02:15

climbTheStairs
Member
From: North America
Registered: 2021-09-22
Posts: 12

Re: [SOLVED] Can't boot b/c mkinitcpio cannot write to initramfs-linux.img

UPDATE:

After an update that involved installing the linux package, the same thing happened again, and this time I'm pretty sure I know the cause of this problem.

I have sbase and ubase installed in /local/bin (which is ahead of /bin in $PATH), while mkinitcpio uses features that are specific to the GNU coreutils.  Temporarily uninstalling sbase and ubase before updating fixes the problem.

Last edited by climbTheStairs (2022-02-15 09:21:17)

Offline

Board footer

Powered by FluxBB