I'm on Ubuntu 22.10, when trying to run apt
or apt-get
with {install|remove|auto-remove}
I got the following error:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up initramfs-tools (0.140ubuntu17) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.140ubuntu17) ...
/usr/sbin/update-initramfs: 175: awk: Too many levels of symbolic links
dpkg: error processing package initramfs-tools (--configure):
installed initramfs-tools package post-installation script subprocess returned
error exit status 127
Errors were encountered while processing:
initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)
the error message shows:
/usr/sbin/update-initramfs: 175: awk: Too many levels of symbolic links
so I tried to run update-initramfs
separately
ya22y@IYB:~$ sudo update-initramfs -u
/usr/sbin/update-initramfs: 175: awk: Too many levels of symbolic links
to ensure file permissions
ya22y@IYB:~$ stat ../../usr/sbin/update-initramfs
File: ../../usr/sbin/update-initramfs
Size: 6906 Blocks: 16 IO Block: 4096 regular file
Device: 803h/2051d Inode: 6553706 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
as far as I know, there's an infinite loop of file A referencing to file B leading to this error. I checked to update-initramfs code but I have no clue how to resolve this error.
EDIT
I checked update-initramfs
again, the error source was boot_opts
ro_boot_check()
{
# check irrelevant inside of a chroot
if [ ! -r /proc/mounts ] || ischroot; then
return 0
fi
#shellcheck disable=SC1004
boot_opts=$(awk '/boot/{if ((match($4, /^ro/) || match($4, /,ro/)) \
&& $2 == "/boot") print "ro"}' /proc/mounts)
if [ -n "${boot_opts}" ]; then
echo "W: /boot is ro mounted." >&2
echo "W: update-initramfs: Not updating ${initramfs}" >&2
exit 0
fi
}
boot directory
ya22y@IYB:~$ ls ../../boot
config-5.19.0-35-generic memtest86+.elf
efi memtest86+_multiboot.bin
grub System.map-5.19.0-35-generic
initrd.img vmlinuz
initrd.img-5.19.0-35-generic vmlinuz-5.19.0-35-generic
memtest86+.bin
I tried
awk
Command 'awk' not found, but can be installed with:
sudo apt install gawk # version 1:5.1.0-1build3, or
sudo apt install mawk # version 1.3.4.20200120-3.1
sudo apt install original-awk # version 2018-08-27-1
as @Bodo mentionned
ya22y@IYB:~$ ls -l ../../usr/bin/awk
lrwxrwxrwx 1 root root 12 mars 6 23:17 ../../usr/bin/awk -> /usr/bin/awk
also tried
sudo sh -c 'awk'
sh: 1: awk: Too many levels of symbolic links
so i decided to change awk
to mawk
inside /usr/sbin/update-initramfs
#shellcheck disable=SC1004
#changing awk to mawk
boot_opts=$(mawk '/boot/{if ((match($4, /^ro/) || match($4, /,ro/)) \
&& $2 == "/boot") print "ro"}' /proc/mounts)
checking
ya22y@IYB:~$ sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-5.19.0-35-generic
ya22y@IYB:~$
Now i got a different error
sudo apt autoremove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up initramfs-tools (0.140ubuntu17) ...
update-initramfs: deferring update (trigger activated)
Setting up original-awk (2018-08-27-1) ...
update-alternatives: error: cannot stat file '/usr/bin/awk': Too many levels of
symbolic links
dpkg: error processing package original-awk (--configure):
installed original-awk package post-installation script subprocess returned err
or exit status 2
Mainly, the awk
link is broken, how can i repaire that ?