Score:0

Trying to update initramfs from Live USB: /usr/sbin/mkinitramfs: 76: modprobe: not found

cn flag

I recently bought a used Lenovo Thinkpad T470. After installing Ubuntu 20.04 and using it a little while, I noticed that it would freeze once in a while, apparently the SSD disk stopped responding. After this I could always restart the system and things would be fine.

But then the other day it crashed while the system was updating and when booting I would get the message that the system gave up waiting for root file system device and

ALERT! UUID=xxx does not exist. Dropping to a shell!

I tried adding rootdelay=5 from the GRUB start parameters (pressing 'e') but it didn't help.

So my experimenting began. There is no valuable data on the system so I have tried a lot of advice trying to restore the system including trying fixing and formatting partitions but without any luck.

The SSD seems to be ok physically ok - running the BIOS memory and storage tests shipped with the system, all seems fine. I have decided to reinstall Ubuntu with the Live USB, but I don't get any options for choosing a partition when running the installer. Running boot-repair I get a similar issue - the button for fixing boot is not there.

So this is my second attempt at rescuing the system and I have decided to document this to some detail, hopefully this can help others.

Updating initram and GRUB

Following the advice given here

ALERT! /dev/disk/by-uuid/xxxxxxxxx does not exist. Dropping to a shell

I booted up with Live USB (Ubuntu 20.04) and looking at the output from sudo blkid:

ubuntu@ubuntu:~$ sudo blkid
/dev/sda1: UUID="2020-07-31-16-51-12-00" LABEL="Ubuntu 20.04.1 LTS amd64" TYPE="iso9660" PTUUID="zzzz" PTTYPE="dos" PARTUUID="zzzzz"
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/sda2: SEC_TYPE="msdos" UUID="zzzz" TYPE="vfat" PARTUUID="zzz"
/dev/sda3: UUID="yyy" TYPE="ext4" PARTUUID="zzzz"

The UUID given in the boot error message is different from the one I get from blkid. Based on this information and the output from fdisk -l

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sda1  *          0  5439487  5439488  2.6G  0 Empty
/dev/sda2       5017392  5025327     7936  3.9M ef EFI (FAT-12/16/32)
/dev/sda3       5439488 30031871 24592384 11.7G 83 Linux

I decided to continue:

ubuntu@ubuntu:~$ sudo mount /dev/sda3 /mnt
ubuntu@ubuntu:~$ sudo mount --bind /dev /mnt/dev
mount: /mnt/dev: mount point does not exist.

Ok - I can create the directories first, np

sudo mkdir /mnt/dev
ubuntu@ubuntu:~$ sudo mount /dev/sda3 /mnt
ubuntu@ubuntu:~$ sudo mount --bind /dev /mnt/dev
mount: /mnt/dev: mount point does not exist.
ubuntu@ubuntu:~$ sudo mkdir /mnt/dev
ubuntu@ubuntu:~$ sudo mount --bind /dev /mnt/dev
ubuntu@ubuntu:~$ sudo mount --bind /proc /mnt/proc
mount: /mnt/proc: mount point does not exist.
ubuntu@ubuntu:~$ sudo mkdir /mnt/proc
ubuntu@ubuntu:~$ sudo mount --bind /proc /mnt/proc
ubuntu@ubuntu:~$ sudo mount --bind /sys /mnt/sys
mount: /mnt/sys: mount point does not exist.
ubuntu@ubuntu:~$ sudo mkdir /mnt/sys
ubuntu@ubuntu:~$ sudo mount --bind /sys /mnt/sys
ubuntu@ubuntu:~$ sudo chroot /mnt
chroot: failed to run command ‘/bin/bash’: No such file or directory

https://unix.stackexchange.com/questions/128046/chroot-failed-to-run-command-bin-bash-no-such-file-or-directory

We need to make bash accessible from chroot

ubuntu@ubuntu:~$ sudo chroot /mnt /usr/bin/bash
chroot: failed to run command ‘/usr/bin/bash’: No such file or directory
ubuntu@ubuntu:~$ which bash
/usr/bin/bash
ubuntu@ubuntu:~$ sudo mkdir /mnt/usr
ubuntu@ubuntu:~$ sudo mount --bind /usr /mnt/usr
ubuntu@ubuntu:~$ sudo chroot /mnt /usr/bin/bash
chroot: failed to run command ‘/usr/bin/bash’: No such file or directory

ok

ubuntu@ubuntu:~$ sudo mkdir /mnt/lib
ubuntu@ubuntu:~$ sudo mkdir /mnt/lib64
ubuntu@ubuntu:~$ sudo mount --bind /lib /mnt/lib
ubuntu@ubuntu:~$ sudo mount --bind /lib64 /mnt/lib64
ubuntu@ubuntu:~$ sudo chroot /mnt /usr/bin/bash
bash-5.0# 

YES! Back to updating initramfs!

bash-5.0# update-initramfs -u
bash: /usr/sbin/update-initramfs: /bin/sh: bad interpreter: No such file or directory

I know that trick now.

bash-5.0# exit
exit
ubuntu@ubuntu:~$ sudo mkdir /mnt/bin
ubuntu@ubuntu:~$ sudo mount --bind /bin /mnt/bin
ubuntu@ubuntu:~$ sudo chroot /mnt /usr/bin/bash
bash-5.0# update-initramfs -u
update-initramfs is disabled since running on read-only media

Disappointing.

https://superuser.com/questions/903142/how-to-run-update-initramfs-from-bootable-usb

bash-5.0# whereis update-initramfs
update-initramfs: /usr/sbin/update-initramfs /usr/sbin/update-initramfs.distrib /usr/share/man/man8/update-initramfs.8.gz
bash-5.0# cat /usr/sbin/update-initramfs
#! /bin/sh
echo "update-initramfs is disabled since running on read-only media"
exit 0

We need to call mkinitramfs directly, it seems

bash-5.0# cd /lib/modules
bash-5.0# ls
5.4.0-42-generic

Exciting!

root@ubuntu:/# mkinitramfs -o /boot/initrm.img-5.4.0-42-generic 5.4.0-42-generic
touch: cannot touch '/boot/initrm.img-5.4.0-42-generic': No such file or directory
mktemp: failed to create directory via template ‘/var/tmp/mkinitramfs_XXXXXX’: No such file or directory

Gotcha. Still some directories to be mounted.

root@ubuntu:/# exit
exit
ubuntu@ubuntu:~$ sudo mkdir /mnt/boot
ubuntu@ubuntu:~$ sudo mount --bind /boot /mnt/boot
ubuntu@ubuntu:~$ sudo chroot /mnt /usr/bin/bash
root@ubuntu:/# mkinitramfs -o /boot/initrm.img-5.4.0-42-generic 5.4.0-42-generic
mktemp: failed to create directory via template ‘/var/tmp/mkinitramfs_XXXXXX’: No such file or directory
root@ubuntu:/# exit
exit
ubuntu@ubuntu:~$ sudo mkdir /mnt/var
ubuntu@ubuntu:~$ sudo mount --bind /var /mnt/var
ubuntu@ubuntu:~$ sudo chroot /mnt /usr/bin/bash

Fingers crossed!

root@ubuntu:/# mkinitramfs -o /boot/initrm.img-5.4.0-42-generic 5.4.0-42-generic
...
/usr/sbin/mkinitramfs: 76: modprobe: not found
/usr/sbin/mkinitramfs: 75: modprobe: not found
/usr/sbin/mkinitramfs: 76: modprobe: not found
find: ‘/var/tmp/mkinitramfs_TcMfi0/lib/modules/5.4.0-42-generic/kernel’: No such file or directory
/usr/sbin/mkinitramfs: 75: modprobe: not found
/usr/sbin/mkinitramfs: 76: modprobe: not found
E: /usr/share/initramfs-tools/hooks/brltty failed with return 1.

No joy.

initramfs error when installing / updating

Following the above advice regarding packages did unfortunately not help:

root@ubuntu:/# apt-get auto-remove && apt-get clean && apt-get update && apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Ign:1 cdrom://Ubuntu 20.04.1 LTS _Focal Fossa_ - Release amd64 (20200731) focal InRelease
Hit:2 cdrom://Ubuntu 20.04.1 LTS _Focal Fossa_ - Release amd64 (20200731) focal Release
Err:3 http://archive.ubuntu.com/ubuntu focal InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:5 http://security.ubuntu.com/ubuntu focal-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:6 cdrom://Ubuntu 20.04.1 LTS _Focal Fossa_ - Release amd64 (20200731) focal Release.gpg
  Couldn't create temporary file /tmp/apt.conf.NMc68S for passing config to apt-key
Reading package lists... Error!
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: cdrom://Ubuntu 20.04.1 LTS _Focal Fossa_ - Release amd64 (20200731) focal Release: Couldn't create temporary file /tmp/apt.conf.NMc68S for passing config to apt-key
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch cdrom://Ubuntu 20.04.1 LTS _Focal Fossa_ - Release amd64 (20200731)/dists/focal/Release.gpg  Couldn't create temporary file /tmp/apt.conf.NMc68S for passing config to apt-key
W: Some index files failed to download. They have been ignored, or old ones used instead.
E: Sub-process returned an error code
E: Unable to mkstemp /tmp/clearsigned.message.WSluIb - GetTempFile (2: No such file or directory)
E: The package lists or status file could not be parsed or opened.
root@ubuntu:/# 

Wits end here. Help most appreciated.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.