当我运行时sudo update-initramfs -u
我得到错误输出
dpkg: warning: version 'KERNEL_VERSION' has bad syntax: version number does not start with digit
update-initramfs: Generating /boot/initrd.img-KERNEL_VERSION
dpkg: warning: version 'KERNEL_VERSION' has bad syntax: version number does not start with digit
grep: /boot/config-KERNEL_VERSION: No such file or directory
WARNING: missing /lib/modules/KERNEL_VERSION
Device driver support needs thus be built-in linux image!
depmod: FATAL: KERNEL_VERSION: not absolute path.
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
depmod: ERROR: could not open directory /tmp/mkinitramfs_Qe3Tum/lib/modules/4.0.0-040000-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
我怀疑一个变量被意外解释为文字,所以我运行
sudo grep -r 'KERNEL_VERSION' /boot/
却sudo grep -r 'KERNEL_VERSION' /lib/
没有结果,sudo grep -r 'KERNEL_VERSION' /usr/
返回太多结果以供调查。
我正在使用带有 Linux 4.0.0 的 Ubuntu 15.04 amd64。
sudo update-initramfs -u -v
产生输出
dpkg: warning: version 'KERNEL_VERSION' has bad syntax: version number does not start with digit
Available versions: KERNEL_VERSION 4.0.0-040000-generic 3.19.3-031903-generic 3.19.0-15-generic 3.19.0-14-generic 3.16.0-23-generic
Keeping /boot/initrd.img-KERNEL_VERSION.dpkg-bak
update-initramfs: Generating /boot/initrd.img-KERNEL_VERSION
dpkg: warning: version 'KERNEL_VERSION' has bad syntax: version number does not start with digit
grep: /boot/config-KERNEL_VERSION: No such file or directory
linux-2.6 misses gzip support, using gzip
WARNING: missing /lib/modules/KERNEL_VERSION
Device driver support needs thus be built-in linux image!
depmod: FATAL: KERNEL_VERSION: not absolute path.
Adding binary /usr/lib/initramfs-tools/bin/wait-for-root
Adding library /lib/x86_64-linux-gnu/libudev.so.1
Adding library /lib/x86_64-linux-gnu/libc.so.6
Adding library /lib/x86_64-linux-gnu/libpthread.so.0
Adding library /lib64/ld-linux-x86-64.so.2
Adding binary /sbin/modprobe
Adding binary /sbin/rmmod
Adding binary /sbin/blkid
Adding library /lib/x86_64-linux-gnu/libblkid.so.1
Adding library /lib/x86_64-linux-gnu/libuuid.so.1
Calling hook brltty
Adding binary /usr/share/brltty/initramfs/brltty.sh
Adding binary /sbin/brltty-setup
Calling hook btrfs
Adding binary /sbin/btrfs
Adding library /lib/x86_64-linux-gnu/libz.so.1
Adding library /lib/x86_64-linux-gnu/liblzo2.so.2
Adding binary /sbin/btrfs-zero-log
Adding binary /sbin/fsck.btrfs
Calling hook compcache
Calling hook cryptroot
Calling hook dmraid
Adding binary /sbin/dmraid
Adding library /lib/libdmraid.so.1.0.0.rc16
Adding library /lib/x86_64-linux-gnu/libdevmapper.so.1.02.1
Adding library /lib/x86_64-linux-gnu/libselinux.so.1
Adding library /lib/x86_64-linux-gnu/libpcre.so.3
Adding library /lib/x86_64-linux-gnu/libdl.so.2
Adding binary /sbin/dmraid-activate
Calling hook framebuffer
Calling hook fuse
Adding binary /sbin/mount.fuse
Calling hook klibc
Calling hook kmod
Adding binary /bin/kmod
Calling hook mountall
Calling hook thermal
Calling hook udev
Adding binary /lib/systemd/systemd-udevd
Adding library /lib/x86_64-linux-gnu/libkmod.so.2
Adding library /lib/x86_64-linux-gnu/libacl.so.1
Adding library /lib/x86_64-linux-gnu/libattr.so.1
Adding binary /bin/udevadm
Adding binary /lib/udev/ata_id
Adding binary /lib/udev/scsi_id
Calling hook zz-busybox
Adding binary /bin/busybox
Calling hook cryptpassdev
Calling hook cryptopensc
Calling hook cryptopenct
Calling hook cryptkeyctl
Calling hook cryptgnupg
Calling hook plymouth
Adding binary /sbin/plymouthd
Adding library /lib/x86_64-linux-gnu/libply.so.4
Adding library /lib/x86_64-linux-gnu/libply-splash-core.so.4
Adding library /lib/x86_64-linux-gnu/librt.so.1
Adding library /lib/x86_64-linux-gnu/libm.so.6
Adding binary /bin/plymouth
Adding binary /lib/x86_64-linux-gnu/plymouth/details.so
Adding binary /lib/x86_64-linux-gnu/plymouth/ubuntu-text.so
Adding binary /lib/x86_64-linux-gnu/plymouth/script.so
Adding library /lib/x86_64-linux-gnu/libply-splash-graphics.so.4
Adding library /lib/x86_64-linux-gnu/libpng12.so.0
Adding binary /lib/x86_64-linux-gnu/plymouth/label.so
Adding library /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0
Adding library /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
Adding library /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
Adding library /usr/lib/x86_64-linux-gnu/libcairo.so.2
Adding library /lib/x86_64-linux-gnu/libglib-2.0.so.0
Adding library /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0
Adding library /usr/lib/x86_64-linux-gnu/libfontconfig.so.1
Adding library /usr/lib/x86_64-linux-gnu/libfreetype.so.6
Adding library /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0
Adding library /usr/lib/x86_64-linux-gnu/libthai.so.0
Adding library /usr/lib/x86_64-linux-gnu/libffi.so.6
Adding library /usr/lib/x86_64-linux-gnu/libpixman-1.so.0
Adding library /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0
Adding library /usr/lib/x86_64-linux-gnu/libxcb-render.so.0
Adding library /usr/lib/x86_64-linux-gnu/libxcb.so.1
Adding library /usr/lib/x86_64-linux-gnu/libXrender.so.1
Adding library /usr/lib/x86_64-linux-gnu/libX11.so.6
Adding library /usr/lib/x86_64-linux-gnu/libXext.so.6
Adding library /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0
Adding library /lib/x86_64-linux-gnu/libexpat.so.1
Adding library /usr/lib/x86_64-linux-gnu/libdatrie.so.1
Adding library /usr/lib/x86_64-linux-gnu/libXau.so.6
Adding library /usr/lib/x86_64-linux-gnu/libXdmcp.so.6
Adding library /usr/lib/x86_64-linux-gnu/libgraphite2.so.3
Adding binary /lib/x86_64-linux-gnu/libnss_files-2.21.so
Adding binary /lib/x86_64-linux-gnu/libnss_files.so.2
Adding binary /lib/x86_64-linux-gnu/plymouth/renderers/frame-buffer.so
Adding binary /lib/x86_64-linux-gnu/plymouth/renderers/drm.so
Adding library /usr/lib/x86_64-linux-gnu/libdrm.so.2
Adding binary /lib/x86_64-linux-gnu/plymouth/renderers/vga16fb.so
Calling hook ntfs_3g
Adding binary /bin/ntfs-3g
Adding library /lib/x86_64-linux-gnu/libntfs-3g.so.853
Calling hook console_setup
Calling hook kbd
Adding binary /bin/setfont
Adding binary /bin/kbd_mode
Adding binary /bin/loadkeys
Calling hook busybox
Adding binary /usr/lib/initramfs-tools/bin/busybox
Calling hook zdev
Adding binary /lib/udev/vdev_id
Adding binary /lib/udev/zvol_id
Calling hook watershed
Adding binary /lib/udev/watershed
Calling hook mdadm
Adding binary /sbin/mdadm
Adding binary /sbin/mdmon
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
Calling hook lvm2
Adding binary /sbin/dmsetup
Adding binary /sbin/lvm
Adding library /lib/x86_64-linux-gnu/libdevmapper-event.so.1.02.1
Adding library /lib/x86_64-linux-gnu/libreadline.so.5
Adding library /lib/x86_64-linux-gnu/libtinfo.so.5
Calling hook kpartx
Adding binary /sbin/kpartx
Adding binary /lib/udev/dmsetup_env
Adding binary /lib/udev/kpartx_id
Calling hook fixrtc
Adding binary /sbin/dumpe2fs
Adding library /lib/x86_64-linux-gnu/libext2fs.so.2
Adding library /lib/x86_64-linux-gnu/libcom_err.so.2
Adding library /lib/x86_64-linux-gnu/libe2p.so.2
Calling hook dmsetup
Calling hook bcache
Adding binary /lib/udev/bcache-register
Adding binary /lib/udev/probe-bcache
Calling hook flashcache
Adding binary /sbin/flashcache_load
Adding binary /sbin/flashcache_create
Adding binary /sbin/flashcache_destroy
depmod: ERROR: could not open directory /tmp/mkinitramfs_H6lHuZ/lib/modules/4.0.0-040000-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
Building cpio /boot/initrd.img-KERNEL_VERSION.new initramfs
答案1
/var/lib/initramfs-tools 中有一个名为“KERNEL_VERSION”的文件夹
在某个时候,您或某个脚本错误地创建了它。
为了进行探索,您需要使用 find。
for x in /usr /var /boot; do find $x -name '*KERNEL_VERSION'; done
如果我的怀疑是正确的,你可以用以下方法解决这个问题
sudo rm -Rf /var/lib/initramfs-tools/KERNEL_VERSION
答案2
请检查文件夹 /var/lib/initramfs-tools/ 中是否有错误条目并删除它们。我在那里有一个名为“a”的文件,它也给出了与您相同的错误消息。
root@proxy:~# LANG=C dpkg-reconfigure initramfs-tools
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.103ubuntu4.2) ...
dpkg: warning: version 'a' has bad syntax: version number does not start with digit
update-initramfs: Generating /boot/initrd.img-a
dpkg: warning: version 'a' has bad syntax: version number does not start with digit
grep: /boot/config-a: No such file or directory
WARNING: missing /lib/modules/a
Device driver support needs thus be built-in linux image!
depmod: FATAL: a: not absolute path.
depmod: ERROR: could not open directory /tmp/mkinitramfs_fuhjWs/lib/modules/3.13.0-54-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
在“/usr/sbin/update-initramfs”的第 2 行中添加“set -x”后,我找到了这个文件夹。