Initial Commit

- initial default booting image
This commit is contained in:
2026-11-06 20:45:42 +01:00
commit b8783708ae
15201 changed files with 602532 additions and 0 deletions

112
fs/cpio/Config.in Normal file
View File

@@ -0,0 +1,112 @@
config BR2_TARGET_ROOTFS_CPIO
bool "cpio the root filesystem (for use as an initial RAM filesystem)"
help
Build a cpio archive of the root filesystem. This is typically
used for an initial RAM filesystem that is passed to the
kernel by the bootloader.
if BR2_TARGET_ROOTFS_CPIO
choice
prompt "cpio type"
default BR2_TARGET_ROOTFS_CPIO_FULL
config BR2_TARGET_ROOTFS_CPIO_FULL
bool "cpio the whole root filesystem"
help
Build a cpio archive containing the whole root filesystem.
config BR2_TARGET_ROOTFS_CPIO_DRACUT
bool "Invoke dracut to make a partial initramfs"
select BR2_PACKAGE_HOST_DRACUT
help
Build an additional initramfs using dracut-ng. This only
contains a subset of the rootfs, as determined by the
configuration file.
This can be useful to create a recovery system, for instance.
endchoice
if BR2_TARGET_ROOTFS_CPIO_DRACUT
config BR2_TARGET_ROOTFS_CPIO_DRACUT_MODULES
string "extra dracut modules"
help
Space-separated list of directories containing dracut modules.
config BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILES
string "dracut configuration files"
default "fs/cpio/dracut.conf"
help
Space-separated list of Dracut configuration files. They
determine which parts of the rootfs get included in the
cpio image. See:
dracut.conf(5)
https://github.com/dracutdevs/dracut/blob/master/man/dracut.conf.5.asc
The default configuration file is suitable for busybox init.
It doesn't, however, pivot_root into a full rootfs.
endif
choice
prompt "Compression method"
default BR2_TARGET_ROOTFS_CPIO_NONE
help
Select compressor for cpio filesystem of the root filesystem.
If you use the cpio archive as an initial RAM filesystem, make
sure the kernel contains the decompression algorithm selected
here.
config BR2_TARGET_ROOTFS_CPIO_NONE
bool "no compression"
help
Do not compress the cpio filesystem.
config BR2_TARGET_ROOTFS_CPIO_GZIP
bool "gzip"
help
Do compress the cpio filesystem with gzip.
config BR2_TARGET_ROOTFS_CPIO_BZIP2
bool "bzip2"
help
Do compress the cpio filesystem with bzip2.
config BR2_TARGET_ROOTFS_CPIO_LZ4
bool "lz4"
help
Do compress the cpio filesystem with lz4.
config BR2_TARGET_ROOTFS_CPIO_LZMA
bool "lzma"
help
Do compress the cpio filesystem with lzma.
config BR2_TARGET_ROOTFS_CPIO_LZO
bool "lzo"
help
Do compress the cpio filesystem with lzop.
config BR2_TARGET_ROOTFS_CPIO_XZ
bool "xz"
help
Do compress the cpio filesystem with xz.
config BR2_TARGET_ROOTFS_CPIO_ZSTD
bool "zstd"
help
Do compress the cpio filesystem with zstd.
endchoice
config BR2_TARGET_ROOTFS_CPIO_UIMAGE
bool "Create U-Boot image of the root filesystem"
select BR2_PACKAGE_HOST_UBOOT_TOOLS
help
Add a U-Boot header to the cpio root filesystem. This allows
the initramfs to be loaded with the bootm command in U-Boot.
The U-Boot image will be called rootfs.cpio.uboot
endif # BR2_TARGET_ROOTFS_CPIO

109
fs/cpio/cpio.mk Normal file
View File

@@ -0,0 +1,109 @@
################################################################################
#
# cpio to archive target filesystem
#
################################################################################
ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
define ROOTFS_CPIO_ADD_INIT
if [ ! -e $(TARGET_DIR)/init ]; then \
ln -sf sbin/init $(TARGET_DIR)/init; \
fi
endef
else
# devtmpfs does not get automounted when initramfs is used.
# Add a pre-init script to mount it before running init
# We must have /dev/console very early, even before /init runs,
# for stdin/stdout/stderr
define ROOTFS_CPIO_ADD_INIT
if [ ! -e $(TARGET_DIR)/init ]; then \
$(INSTALL) -m 0755 fs/cpio/init $(TARGET_DIR)/init; \
fi
mkdir -p $(TARGET_DIR)/dev
mknod -m 0622 $(TARGET_DIR)/dev/console c 5 1
endef
endif # BR2_ROOTFS_DEVICE_CREATION_STATIC
ROOTFS_CPIO_PRE_GEN_HOOKS += ROOTFS_CPIO_ADD_INIT
# --reproducible option was introduced in cpio v2.12, which may not be
# available in some old distributions, so we build host-cpio
ifeq ($(BR2_REPRODUCIBLE),y)
ROOTFS_CPIO_DEPENDENCIES += host-cpio
ROOTFS_CPIO_OPTS += --reproducible
endif
ifeq ($(BR2_TARGET_ROOTFS_CPIO_FULL),y)
define ROOTFS_CPIO_CMD
cd $(TARGET_DIR) && \
find . \
| LC_ALL=C sort \
| cpio $(ROOTFS_CPIO_OPTS) --quiet -o -H newc \
> $@
endef
else ifeq ($(BR2_TARGET_ROOTFS_CPIO_DRACUT),y)
ROOTFS_CPIO_DEPENDENCIES += host-dracut
ROOTFS_CPIO_DRACUT_MODULES = $(call qstrip,$(BR2_TARGET_ROOTFS_CPIO_DRACUT_MODULES))
ifeq ($(BR_BUILDING),y)
ifneq ($(words $(ROOTFS_CPIO_DRACUT_MODULES)),$(words $(sort $(notdir $(ROOTFS_CPIO_DRACUT_MODULES)))))
$(error No two dracut modules can have the same basename, check your BR2_TARGET_ROOTFS_CPIO_DRACUT_MODULES setting)
endif
endif
ROOTFS_CPIO_DRACUT_CONF_FILES = $(call qstrip,$(BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILES))
ifeq ($(BR_BUILDING),y)
ifeq ($(ROOTFS_CPIO_DRACUT_CONF_FILES),)
$(error No dracut config file name specified, check your BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILES setting)
endif
ifneq ($(words $(ROOTFS_CPIO_DRACUT_CONF_FILES)),$(words $(sort $(notdir $(ROOTFS_CPIO_DRACUT_CONF_FILES)))))
$(error No two dracut config files can have the same basename, check your BR2_TARGET_ROOTFS_CPIO_DRACUT_CONF_FILES setting)
endif
endif
ifeq ($(BR2_LINUX_KERNEL),y)
ROOTFS_CPIO_DEPENDENCIES += linux
ROOTFS_CPIO_OPTS += --kver $(LINUX_VERSION_PROBED)
else
ROOTFS_CPIO_OPTS += --no-kernel
endif
define ROOTFS_CPIO_CMD
mkdir -p $(ROOTFS_CPIO_DIR)/tmp $(ROOTFS_CPIO_DIR)/confdir $(HOST_DIR)/lib/dracut/modules.d
touch $(ROOTFS_CPIO_DIR)/empty-config
$(foreach cfg,$(ROOTFS_CPIO_DRACUT_CONF_FILES), \
cp $(cfg) $(ROOTFS_CPIO_DIR)/confdir/$(notdir $(cfg))
)
$(foreach m,$(ROOTFS_CPIO_DRACUT_MODULES), \
cp -a $(m)/* $(HOST_DIR)/lib/dracut/modules.d/
)
$(HOST_DIR)/bin/dracut \
$(ROOTFS_CPIO_OPTS) \
-c $(ROOTFS_CPIO_DIR)/empty-config \
--confdir $(ROOTFS_CPIO_DIR)/confdir \
--sysroot $(TARGET_DIR) \
--tmpdir $(ROOTFS_CPIO_DIR)/tmp \
-M \
--force \
--no-compress \
$@
endef
endif #BR2_TARGET_ROOTFS_CPIO_DRACUT
ifeq ($(BR2_TARGET_ROOTFS_CPIO_UIMAGE),y)
ROOTFS_CPIO_DEPENDENCIES += host-uboot-tools
define ROOTFS_CPIO_UBOOT_MKIMAGE
$(MKIMAGE) -A $(MKIMAGE_ARCH) -T ramdisk \
-C none -d $@$(ROOTFS_CPIO_COMPRESS_EXT) $@.uboot
endef
ROOTFS_CPIO_POST_GEN_HOOKS += ROOTFS_CPIO_UBOOT_MKIMAGE
endif
$(eval $(rootfs))

92
fs/cpio/dracut.conf Normal file
View File

@@ -0,0 +1,92 @@
#Simple dracut config for a system without systemd
#Dracut configuration
show_modules=yes
i18n_install_all=no
lvmconf=no
mdadmconf=no
early_microcode=no
hostonly=no
hostonly_cmdline=no
use_fstab=no
kernel_cmdline="rd.break=initqueue"
do_strip=no
# Dracut modules needed
add_dracutmodules+=" \
busybox-init
"
# Modules to ignore
omit_dracutmodules+=" \
bash \
biosdevname \
btrfs \
bluetooth \
busybox \
caps \
cifs \
crypt \
crypt-gpg \
dash \
dbus-broker \
dbus-daemon \
dm \
dmraid \
dmsquash-live-ntfs \
dracut-systemd \
fcoe \
fcoe-uefi \
fs-lib \
iscsi \
i18n \
lvmmerge \
lvm \
lunmask \
mdraid \
memstrack \
mksh \
modsign \
mount-root \
multipath \
nbd \
network-legacy \
network-wicked \
nfs \
nvdimm \
nvmf \
parse-lunmask \
qemu \
qemu-net \
resume \
rootfs-block \
rngd \
systemd \
systemd-udevd \
systemd-coredump \
systemd-ask-password \
systemd-timedated \
systemd-rfkill \
systemd-resolved \
systemd-hostnamed \
systemd-initrd \
systemd-journald \
systemd-ldconfig \
systemd-networkd \
systemd-timesyncd \
systemd-veritysetup \
systemd-modules-load \
systemd-sysctl \
systemd-repart \
systemd-sysext \
systemd-sysusers \
systemd-tmpfiles \
squash \
ssh-client \
stratis \
tpm2-tss \
udev-rules \
url-lib \
usrmount \
"

15
fs/cpio/init Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
# devtmpfs does not get automounted for initramfs
/bin/mount -t devtmpfs devtmpfs /dev
# use the /dev/console device node from devtmpfs if possible to not
# confuse glibc's ttyname_r().
# This may fail (E.G. booted with console=), and errors from exec will
# terminate the shell, so use a subshell for the test
if (exec 0</dev/console) 2>/dev/null; then
exec 0</dev/console
exec 1>/dev/console
exec 2>/dev/console
fi
exec /sbin/init "$@"