Как передать несколько аргументов в команду Linux?

В отличие от initrd, Linux не позволяет размонтировать initramfs. Очевидно, это помогло сохранить простоту кода ядра.

Вместо pivot_rootвы можете использовать команду switch_root. Он реализует следующую процедуру. Обратите внимание, что switch_rootудаляет все файлы в старом корне, чтобы освободить память initramfs, поэтому вам нужно быть осторожным при выполнении этой команды.

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 '{}' ';'), overmount rootfs with the new root (cd /newmount; mount --move. /; chroot.), attach stdin/stdout/stderr to the new /dev/console, and exec the new init.

Обратите внимание, что предлагаемые команды оболочки являются лишь грубыми эквивалентами кода C. Команды на самом деле не будут работать, если они все не встроены в вашу оболочку, потому что первая команда удаляет все программы и другие файлы из initramfs :-).


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.

https://github.com/torvalds/linux/blob/v4.17/Documentation/filesystems/ramfs-rootfs-initramfs.txt

0
31.08.2020, 17:30
0 ответов

Теги

Похожие вопросы