Score:2

What does "regenerate your initramfs" mean?

br flag

Today I ran an script to fix some issues on an acer one 10 s1003 when It finished running this message

All done, please regenerate your initramfs and reboot

I want to know what "regenerate your initramfs" means.

guiverc avatar
cn flag
`sudo update-initramfs` (but usually options are provided; you've given no specifics on what you're doing currently; what you've installed or script you've run, so I've not provided options)
immaplane avatar
br flag
Ok, Thanks again
WinEunuuchs2Unix avatar
in flag
You should run initramfs on all kernel versions.
Score:4
cn flag

From man update-initramfs

   The  update-initramfs script manages your initramfs images on your lo‐
   cal box.  It keeps track of the existing initramfs archives in  /boot.
   There are three modes of operation create, update or delete.  You must
   at least specify one of those modes.

   The initramfs is a gzipped cpio archive.  At boot time, the kernel un‐
   packs  that  archive into RAM disk, mounts and uses it as initial root
   file system. All finding of the root  device  happens  in  this  early
   userspace.

The man commands shows you the reference manual page for the command or topic you provided. Other documentation tools exist too (info etc)

If you don't know what commands you need to use, you can search using tools like apropos, eg. if I wanted to know what commands related to initramfs I might use

guiverc@d960-ubu2:/de2900/lubuntu$   apropos initramfs

dh_installinitramfs (1) - install initramfs hooks and setup maintscripts
initramfs-tools (7)  - an introduction to writing scripts for mkinitramfs
initramfs.conf (5)   - configuration file for mkinitramfs
kernel-install (8)   - Add and remove kernel and initramfs images to and from /boot
linux-update-symlinks (1) - maintain symlinks to default kernel and initramfs
lsinitramfs (8)      - list content of an initramfs image
mkinitramfs (8)      - low-level tool for generating an initramfs image
unmkinitramfs (8)    - extract content from an initramfs image
update-initramfs (8) - generate an initramfs image
update-initramfs.conf (5) - configuration file for update-initramfs
guiverc avatar
cn flag
If you read further in the `man update-initramfs` you'll see it refers to teh version, and includes an "all" option to regenerate for all installer kernel versions.. This is what @WinEunuuchs2Unix's excellent comment is suggesting :)
Score:2
ru flag

To create/recreate/update the initramfs file means to update the initrd.img-* ramdisk files in /boot.

Here's a listing of my /boot. Note the size/date of the initrd.img-* files. One or more of these need updating in your case.

~$ 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

Note: I prefer to create a totally fresh version by using the -c option, instead of just updating the existing file by using the -u option.

The proper command would be:

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

This will create a fresh initrd.img-* file for your currently booted version of Ubuntu.

However, if you can't boot to the current version of Ubuntu, you may have to modify this command, and by booting to an older version of Ubuntu, you can do it this way:

sudo update-initramfs -c -k 5.11.0-22-generic where the 5.11.0-22-generic part should be replaced with the version of the desired boot kernel.

To regenerate all of the initrd.img-* files (not recommended), use:

sudo update-initramfs -c -k all

To get more detailed information, type:

man update-initramfs

immaplane avatar
br flag
Thanks @heynnema for the details :D
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.