“重新生成 initramfs”是什么意思?

imm*_*ane 13 software-installation

今天,我运行了一个脚本来修复 Acer One 10 S1003 上的一些问题。当脚本运行完成时,出现此消息。

All done, please regenerate your initramfs and reboot
Run Code Online (Sandbox Code Playgroud)

我想知道“重新生成你的 initramfs”是什么意思。

hey*_*ema 16

创建/重新创建/更新 initramfs 文件意味着更新initrd.img-*/boot 中的 ramdisk 文件。

这是我的 /boot 的列表。请注意文件的大小/日期initrd.img-*。根据您的情况,其中一项或多项需要更新。

~$ ls -al /boot
total 162745
drwxr-xr-x  4 root root     4096 Jul  5 05:19 .
drwxr-xr-x 23 root root     4096 Jun 19 12:40 ..
-rw-r--r--  1 root root   252994 May  7 05:38 config-5.11.0-18-generic
-rw-r--r--  1 root root   253022 Jun 16 15:38 config-5.11.0-22-generic
drwxr-xr-x  3 root root     1024 Dec 31  1969 efi
drwxr-xr-x  5 root root     4096 Jun 30 12:09 grub
lrwxrwxrwx  1 root root       28 Jun 25 12:42 initrd.img -> initrd.img-5.11.0-22-generic
-rw-r--r--  1 root root 62066094 Jul  5 05:19 initrd.img-5.11.0-18-generic
-rw-r--r--  1 root root 62067859 Jul  5 05:18 initrd.img-5.11.0-22-generic
lrwxrwxrwx  1 root root       28 Jun 25 12:42 initrd.img.old -> initrd.img-5.11.0-18-generic
-rw-r--r--  1 root root   182704 Aug 18  2020 memtest86+.bin
-rw-r--r--  1 root root   184380 Aug 18  2020 memtest86+.elf
-rw-r--r--  1 root root   184884 Aug 18  2020 memtest86+_multiboot.bin
-rw-------  1 root root  5968565 May  7 05:38 System.map-5.11.0-18-generic
-rw-------  1 root root  5969489 Jun 16 15:38 System.map-5.11.0-22-generic
lrwxrwxrwx  1 root root       25 Jun 25 12:42 vmlinuz -> vmlinuz-5.11.0-22-generic
-rw-------  1 root root 14737344 May  7 06:26 vmlinuz-5.11.0-18-generic
-rw-------  1 root root 14741312 Jun 16 15:55 vmlinuz-5.11.0-22-generic
lrwxrwxrwx  1 root root       25 Jun 25 12:42 vmlinuz.old -> vmlinuz-5.11.0-18-generic
Run Code Online (Sandbox Code Playgroud)

注意:我更喜欢使用该选项创建一个全新的版本-c,而不是仅使用该-u选项更新现有文件。

正确的命令是:

sudo update-initramfs -c -k $(uname -r)

这将为您当前启动的 Ubuntu 版本创建一个新的 initrd.img-* 文件。

但是,如果您无法启动到当前版本的 Ubuntu,则可能需要修改此命令,通过启动到旧版本的 Ubuntu,您可以这样做:

sudo update-initramfs -c -k 5.11.0-22-generic其中 5.11.0-22-generic 部分应替换为所需引导内核的版本。

要重新生成所有 initrd.img-* 文件(不推荐),请使用:

sudo update-initramfs -c -k all

要获取更详细的信息,请输入:

man update-initramfs


gui*_*erc 6

man update-initramfs

\n
   The  update-initramfs script manages your initramfs images on your lo\xe2\x80\x90\n   cal box.  It keeps track of the existing initramfs archives in  /boot.\n   There are three modes of operation create, update or delete.  You must\n   at least specify one of those modes.\n\n   The initramfs is a gzipped cpio archive.  At boot time, the kernel un\xe2\x80\x90\n   packs  that  archive into RAM disk, mounts and uses it as initial root\n   file system. All finding of the root  device  happens  in  this  early\n   userspace.\n
Run Code Online (Sandbox Code Playgroud)\n

这些man命令显示您提供的命令或主题的参考手册页。也存在其他文档工具(info等等)

\n

如果您不知道需要使用哪些命令,您可以使用诸如 之类的工具进行搜索apropos。如果我想知道我可能会使用哪些与 initramfs 相关的命令

\n
guiverc@d960-ubu2:/de2900/lubuntu$   apropos initramfs\n\ndh_installinitramfs (1) - install initramfs hooks and setup maintscripts\ninitramfs-tools (7)  - an introduction to writing scripts for mkinitramfs\ninitramfs.conf (5)   - configuration file for mkinitramfs\nkernel-install (8)   - Add and remove kernel and initramfs images to and from /boot\nlinux-update-symlinks (1) - maintain symlinks to default kernel and initramfs\nlsinitramfs (8)      - list content of an initramfs image\nmkinitramfs (8)      - low-level tool for generating an initramfs image\nunmkinitramfs (8)    - extract content from an initramfs image\nupdate-initramfs (8) - generate an initramfs image\nupdate-initramfs.conf (5) - configuration file for update-initramfs\n
Run Code Online (Sandbox Code Playgroud)\n