On 2024-10-07 21:23:40 +0200, Ben Hutchings wrote:
> Control: tag -1 moreinfo
> 
> On Mon, 2024-10-07 at 00:39 +0200, Vincent Lefevre wrote:
> > Package: initramfs-tools
> > Version: 0.145
> > Severity: normal
> > 
> > When updating an initrd file, update-initramfs keeps 2 temporary
> > copies in /boot,
> 
> I don't believe this is the case.  A successful run of
> "update-initramfs -u" will do:
> 
> 1. Hard-link initrd.img-<version> to initrd.img-<version>.dpkg-bak
> 2. Create new initramfs as initrd.img-<version>.new
> 3. Move initrd.img-<version>.new to initrd.img-<version>
> 4. Remove initrd.img-<version>.dpkg-bak (unless backup_initramfs is
>    enabled)
> 
> There is 1 temporary copy created in step 2, and after step 4 there are
> 0 temporary copies.
> 
> Step 1 does have a fallback to copying if hard-linking fails.  That
> could happen if your /boot uses VFAT or some other un-Unix-like
> filesystem, but that's not supported by Debian.  But maybe there's some
> other reason it can fail?

Indeed, with 3 installed kernels:

Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p2  456M  295M  137M  69% /boot

So there isn't enough space for a 4th kernel + a temporary copy
(90 MB each at maximum compression + 9 MB for the vmlinuz file).

> > though its space is typically *very* limited
> > (456 MB by default). This means that one can keep a limited number
> > of kernels. With the 456 MB default size and maximum compression
> > (COMPRESS=lzma and COMPRESSLEVEL=9), only 3 kernels are possible.
> > 
> > The temporary copies should be stored on the main file system,
> > which is not space limited.
> [...]
> 
> The initramfs must be replaced atomically, otherwise we can end up with
> a previously working image being deleted or replaced with a truncated
> image.  So there has to be 1 temporary copy.

The temporary copy could be on the main file system. The goal is
anyway to keep *at least* an additional working kernel in /boot
in case the rebuild of the kernel gets broken (which cannot be
detected until booting on this kernel). So, if anything goes wrong
(either at install time or when booting on the rebuilt kernel), it
is possible to boot on the working kernel to fix things.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Reply via email to