Por que o switch_root exclui todos os arquivos no initramfs?

1

WARNING: switch_root removes recursively all files and directories on the current root filesystem.

- man switch_root de util-linux , versão 2.32-2.fc28.x86_64

Por quê?

    
por sourcejedi 14.07.2018 / 00:14

1 resposta

1

O comportamento exato de switch_root é explicado aqui:

link

When switching another root device, initrd would pivot_root and then umount the ramdisk. But initramfs is rootfs: you can neither pivot_root rootfs, nor unmount it. Instead delete everything out of rootfs to free up the space (find -xdev / -exec rm '{}' ';') ...

E o motivo pelo qual o Linux não suporta a desmontagem do rootfs inicial:

Rootfs is a special instance of ramfs (or tmpfs, if that's enabled), which is always present in 2.6 systems. You can't unmount rootfs for approximately the same reason you can't kill the init process; rather than having special code to check for and handle an empty list, it's smaller and simpler for the kernel to just make sure certain lists can't become empty.

    
por 14.07.2018 / 00:14