diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:31:53 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:31:53 +0000 |
| commit | 8c22ff0d8b70d9b12f0487ef696a7e915b9e3173 (patch) | |
| tree | efdc32587159d0050a69009bdf2330a531727d95 /meta/recipes-core/initrdscripts/initramfs-framework | |
| parent | d412d2747595c1cc4a5e3ca975e3adc31b2f7891 (diff) | |
| download | poky-8c22ff0d8b70d9b12f0487ef696a7e915b9e3173.tar.gz | |
The poky repository master branch is no longer being updated.
You can either:
a) switch to individual clones of bitbake, openembedded-core, meta-yocto and yocto-docs
b) use the new bitbake-setup
You can find information about either approach in our documentation:
https://docs.yoctoproject.org/
Note that "poky" the distro setting is still available in meta-yocto as
before and we continue to use and maintain that.
Long live Poky!
Some further information on the background of this change can be found
in: https://lists.openembedded.org/g/openembedded-architecture/message/2179
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/initrdscripts/initramfs-framework')
12 files changed, 0 insertions, 748 deletions
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/debug b/meta/recipes-core/initrdscripts/initramfs-framework/debug deleted file mode 100644 index 00bfd7d3f5..0000000000 --- a/meta/recipes-core/initrdscripts/initramfs-framework/debug +++ /dev/null | |||
| @@ -1,82 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Copyright (C) 2011 O.S. Systems Software LTDA. | ||
| 3 | # Licensed on MIT | ||
| 4 | |||
| 5 | # Adds support to dynamic debugging of initramfs using bootparam in | ||
| 6 | # following format: | ||
| 7 | # shell : starts a shell before and after each module | ||
| 8 | # shell=before:<module> : starts a shell before <module> is loaded and run | ||
| 9 | # shell=after:<module> : starts a shell after <module> is loaded and run | ||
| 10 | # | ||
| 11 | # shell-debug : run set -x as soon as possible | ||
| 12 | # shell-debug=before:<module> : run set -x before <module> is loaded and run | ||
| 13 | # shell-debug=after:<module> : run set -x after <module> is loaded and run | ||
| 14 | |||
| 15 | DEBUG_SHELL="false" | ||
| 16 | |||
| 17 | debug_hook_handler() { | ||
| 18 | status=$1 | ||
| 19 | module=$2 | ||
| 20 | |||
| 21 | if [ -n "$bootparam_shell" ] && [ "$bootparam_shell" != "true" ]; then | ||
| 22 | shell_wanted_status=`expr $bootparam_shell : '\(.*\):.*'` | ||
| 23 | shell_wanted_module=`expr $bootparam_shell : '.*:\(.*\)'` | ||
| 24 | |||
| 25 | if [ "$shell_wanted_status" = "before" ]; then | ||
| 26 | shell_wanted_status=pre | ||
| 27 | else | ||
| 28 | shell_wanted_status=post | ||
| 29 | fi | ||
| 30 | fi | ||
| 31 | |||
| 32 | if [ "$bootparam_shell" = "true" ] || | ||
| 33 | ( [ "$status" = "$shell_wanted_status" ] && | ||
| 34 | [ "$module" = "$shell_wanted_module" ] ); then | ||
| 35 | if [ "$status" = "pre" ]; then | ||
| 36 | status_msg="before" | ||
| 37 | else | ||
| 38 | status_msg="after" | ||
| 39 | fi | ||
| 40 | |||
| 41 | msg "Starting shell $status_msg $module..." | ||
| 42 | sh | ||
| 43 | fi | ||
| 44 | |||
| 45 | if [ -n "$bootparam_shell_debug" ] && [ "$bootparam_shell_debug" != "true" ]; then | ||
| 46 | shell_debug_wanted_status=`expr $bootparam_shell_debug : '\(.*\):.*'` | ||
| 47 | shell_debug_wanted_module=`expr $bootparam_shell_debug : '.*:\(.*\)'` | ||
| 48 | |||
| 49 | if [ "$shell_debug_wanted_status" = "before" ]; then | ||
| 50 | shell_debug_wanted_status=pre | ||
| 51 | else | ||
| 52 | shell_debug_wanted_status=post | ||
| 53 | fi | ||
| 54 | fi | ||
| 55 | |||
| 56 | if [ "$bootparam_shell_debug" = "true" ] || | ||
| 57 | ( [ "$status" = "$shell_debug_wanted_status" ] && | ||
| 58 | [ "$module" = "$shell_debug_wanted_module" ] ); then | ||
| 59 | if [ "$DEBUG_SHELL" = "true" ]; then | ||
| 60 | return 0 | ||
| 61 | fi | ||
| 62 | |||
| 63 | if [ "$status" = "pre" ]; then | ||
| 64 | status_msg="before" | ||
| 65 | else | ||
| 66 | status_msg="after" | ||
| 67 | fi | ||
| 68 | |||
| 69 | msg "Starting shell debugging $status_msg $module..." | ||
| 70 | DEBUG_SHELL="true" | ||
| 71 | set -x | ||
| 72 | fi | ||
| 73 | } | ||
| 74 | |||
| 75 | debug_enabled() { | ||
| 76 | return 0 | ||
| 77 | } | ||
| 78 | |||
| 79 | debug_run() { | ||
| 80 | add_module_pre_hook "debug_hook_handler" | ||
| 81 | add_module_post_hook "debug_hook_handler" | ||
| 82 | } | ||
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/e2fs b/meta/recipes-core/initrdscripts/initramfs-framework/e2fs deleted file mode 100755 index 29f801a7bd..0000000000 --- a/meta/recipes-core/initrdscripts/initramfs-framework/e2fs +++ /dev/null | |||
| @@ -1,28 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Copyright (C) 2011 O.S. Systems Software LTDA. | ||
| 3 | # Licensed on MIT | ||
| 4 | |||
| 5 | e2fs_enabled() { | ||
| 6 | return 0 | ||
| 7 | } | ||
| 8 | |||
| 9 | e2fs_run() { | ||
| 10 | filesystems="ext4 ext3 ext2" | ||
| 11 | |||
| 12 | # load modules | ||
| 13 | for fs in $filesystems; do | ||
| 14 | load_kernel_module $fs | ||
| 15 | done | ||
| 16 | |||
| 17 | for fs in $filesystems; do | ||
| 18 | eval "fs_options=\$bootparam_${fs}" | ||
| 19 | if [ -n "$fs_options" ]; then | ||
| 20 | dev=`expr "$fs_options" : '\([^:]*\).*'` | ||
| 21 | path=`expr "$fs_options" : '[^:]*:\([^:]*\).*'` | ||
| 22 | |||
| 23 | info "Mounting $dev as $fs on $path as $fs..." | ||
| 24 | mkdir -p $path | ||
| 25 | mount -t $fs $dev $path | ||
| 26 | fi | ||
| 27 | done | ||
| 28 | } | ||
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/exec b/meta/recipes-core/initrdscripts/initramfs-framework/exec deleted file mode 100644 index a8e2432bb6..0000000000 --- a/meta/recipes-core/initrdscripts/initramfs-framework/exec +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Copyright (C) 2017 O.S. Systems Software LTDA. | ||
| 3 | # Licensed on MIT | ||
| 4 | |||
| 5 | EXEC_DIR=/exec.d # place to look for modules | ||
| 6 | |||
| 7 | exec_enabled() { | ||
| 8 | return 0 | ||
| 9 | } | ||
| 10 | |||
| 11 | exec_run() { | ||
| 12 | if [ ! -d $EXEC_DIR ]; then | ||
| 13 | msg "No contents to exec in $EXEC_DIR. Starting shell ..." | ||
| 14 | sh | ||
| 15 | fi | ||
| 16 | |||
| 17 | # Load and run modules | ||
| 18 | for m in $EXEC_DIR/*; do | ||
| 19 | # Skip backup files | ||
| 20 | if [ "`echo $m | sed -e 's/\~$//'`" != "$m" ]; then | ||
| 21 | continue | ||
| 22 | fi | ||
| 23 | |||
| 24 | debug "Starting $m" | ||
| 25 | |||
| 26 | # process module | ||
| 27 | ./$m | ||
| 28 | done | ||
| 29 | } | ||
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/finish b/meta/recipes-core/initrdscripts/initramfs-framework/finish deleted file mode 100755 index 21eaa57393..0000000000 --- a/meta/recipes-core/initrdscripts/initramfs-framework/finish +++ /dev/null | |||
| @@ -1,49 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Copyright (C) 2011 O.S. Systems Software LTDA. | ||
| 3 | # Licensed on MIT | ||
| 4 | |||
| 5 | finish_enabled() { | ||
| 6 | return 0 | ||
| 7 | } | ||
| 8 | |||
| 9 | finish_run() { | ||
| 10 | if [ -n "$ROOTFS_DIR" ]; then | ||
| 11 | if [ ! -d $ROOTFS_DIR/dev ]; then | ||
| 12 | fatal "ERROR: There's no '/dev' on rootfs." | ||
| 13 | fi | ||
| 14 | |||
| 15 | # Unmount anything that was automounted by busybox via mdev-mount.sh. | ||
| 16 | # We're about to switch_root, and leaving anything mounted will prevent | ||
| 17 | # the next rootfs from modifying the block device. Ignore ROOT_DISK, | ||
| 18 | # if it was set by setup-live, because it'll be mounted over loopback | ||
| 19 | # to ROOTFS_DIR. | ||
| 20 | local dev | ||
| 21 | for dev in /run/media/*; do | ||
| 22 | if mountpoint -q "${dev}" && [ "${dev##*/}" != "${ROOT_DISK}" ]; then | ||
| 23 | umount -f "${dev}" || debug "Failed to unmount ${dev}" | ||
| 24 | fi | ||
| 25 | done | ||
| 26 | |||
| 27 | info "Switching root to '$ROOTFS_DIR'..." | ||
| 28 | |||
| 29 | debug "Moving basic mounts onto rootfs" | ||
| 30 | for dir in `awk '/\/dev.* \/run\/media/{print $2}' /proc/mounts`; do | ||
| 31 | # Parse any OCT or HEX encoded chars such as spaces | ||
| 32 | # in the mount points to actual ASCII chars | ||
| 33 | dir=`printf $dir` | ||
| 34 | mkdir -p "${ROOTFS_DIR}/media/${dir##*/}" | ||
| 35 | mount -n --move "$dir" "${ROOTFS_DIR}/media/${dir##*/}" | ||
| 36 | done | ||
| 37 | |||
| 38 | debug "Moving /dev, /proc, /sys and /run onto rootfs..." | ||
| 39 | mount --move /dev $ROOTFS_DIR/dev | ||
| 40 | mount --move /proc $ROOTFS_DIR/proc | ||
| 41 | mount --move /sys $ROOTFS_DIR/sys | ||
| 42 | mount --move /run $ROOTFS_DIR/run | ||
| 43 | |||
| 44 | cd $ROOTFS_DIR | ||
| 45 | exec switch_root $ROOTFS_DIR ${bootparam_init:-/sbin/init} | ||
| 46 | else | ||
| 47 | debug "No rootfs has been set" | ||
| 48 | fi | ||
| 49 | } | ||
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/init b/meta/recipes-core/initrdscripts/initramfs-framework/init deleted file mode 100755 index fe6e3cbf07..0000000000 --- a/meta/recipes-core/initrdscripts/initramfs-framework/init +++ /dev/null | |||
| @@ -1,168 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Copyright (C) 2011 O.S. Systems Software LTDA. | ||
| 3 | # Licensed on MIT | ||
| 4 | # | ||
| 5 | # Provides the API to be used by the initramfs modules | ||
| 6 | # | ||
| 7 | # Modules need to provide the following functions: | ||
| 8 | # | ||
| 9 | # <module>_enabled : check if the module ought to run (return 1 to skip) | ||
| 10 | # <module>_run : do what is need | ||
| 11 | # | ||
| 12 | # Boot parameters are available on environment in the as: | ||
| 13 | # | ||
| 14 | # 'foo=value' as 'bootparam_foo=value' | ||
| 15 | # 'foo' as 'bootparam_foo=true' | ||
| 16 | # 'foo.bar[=value] as 'foo_bar=[value|true]' | ||
| 17 | |||
| 18 | # Register a function to be called before running a module | ||
| 19 | # The hook is called as: | ||
| 20 | # <function> pre <module> | ||
| 21 | add_module_pre_hook() { | ||
| 22 | MODULE_PRE_HOOKS="$MODULE_PRE_HOOKS $1" | ||
| 23 | } | ||
| 24 | |||
| 25 | # Register a function to be called after running a module | ||
| 26 | # The hook is called as: | ||
| 27 | # <function> post <module> | ||
| 28 | add_module_post_hook() { | ||
| 29 | MODULE_POST_HOOKS="$MODULE_POST_HOOKS $1" | ||
| 30 | } | ||
| 31 | |||
| 32 | # Load kernel module | ||
| 33 | load_kernel_module() { | ||
| 34 | if modprobe $1 >/dev/null 2>&1; then | ||
| 35 | info "Loaded module $1" | ||
| 36 | else | ||
| 37 | debug "Failed to load module $1" | ||
| 38 | fi | ||
| 39 | } | ||
| 40 | |||
| 41 | # Prints information | ||
| 42 | msg() { | ||
| 43 | echo "$@" >/dev/console | ||
| 44 | } | ||
| 45 | |||
| 46 | # Prints information if verbose bootparam is used | ||
| 47 | info() { | ||
| 48 | [ -n "$bootparam_verbose" ] && echo "$@" >/dev/console | ||
| 49 | } | ||
| 50 | |||
| 51 | # Prints information if debug bootparam is used | ||
| 52 | debug() { | ||
| 53 | [ -n "$bootparam_debug" ] && echo "DEBUG: $@" >/dev/console | ||
| 54 | } | ||
| 55 | |||
| 56 | # Prints a message and start a endless loop | ||
| 57 | # Force reboot if init_fatal_reboot bootparam is set | ||
| 58 | fatal() { | ||
| 59 | echo $1 >/dev/console | ||
| 60 | echo >/dev/console | ||
| 61 | |||
| 62 | if [ -n "$bootparam_init_fatal_reboot" ]; then | ||
| 63 | reboot -f | ||
| 64 | elif [ -n "$bootparam_init_fatal_sh" ]; then | ||
| 65 | sh | ||
| 66 | else | ||
| 67 | while [ "true" ]; do | ||
| 68 | sleep 3600 | ||
| 69 | done | ||
| 70 | fi | ||
| 71 | } | ||
| 72 | |||
| 73 | # Variables shared among modules | ||
| 74 | ROOTFS_DIR="/rootfs" # where to do the switch root | ||
| 75 | MODULE_PRE_HOOKS="" # functions to call before running each module | ||
| 76 | MODULE_POST_HOOKS="" # functions to call after running each module | ||
| 77 | MODULES_DIR=/init.d # place to look for modules | ||
| 78 | EFI_DIR=/sys/firmware/efi # place to store device firmware information | ||
| 79 | |||
| 80 | # make mount stop complaining about missing /etc/fstab | ||
| 81 | touch /etc/fstab | ||
| 82 | |||
| 83 | # initialize /proc, /sys and /run/lock | ||
| 84 | mkdir -p /proc /sys /run | ||
| 85 | mount -t proc proc /proc | ||
| 86 | mount -t sysfs sysfs /sys | ||
| 87 | mount -t tmpfs tmpfs /run | ||
| 88 | mkdir -p /run/lock | ||
| 89 | |||
| 90 | if [ -d $EFI_DIR ];then | ||
| 91 | mount -t efivarfs none /sys/firmware/efi/efivars | ||
| 92 | fi | ||
| 93 | |||
| 94 | # populate bootparam environment | ||
| 95 | for p in `cat /proc/cmdline`; do | ||
| 96 | if [ -n "$quoted" ]; then | ||
| 97 | value="$value $p" | ||
| 98 | if [ "`echo $p | sed -e 's/\"$//'`" != "$p" ]; then | ||
| 99 | eval "bootparam_${quoted}=${value}" | ||
| 100 | unset quoted | ||
| 101 | fi | ||
| 102 | continue | ||
| 103 | fi | ||
| 104 | |||
| 105 | opt=`echo $p | cut -d'=' -f1` | ||
| 106 | opt=`echo $opt | sed -e 'y/.-/__/'` | ||
| 107 | if [ "`echo $p | cut -d'=' -f1`" = "$p" ]; then | ||
| 108 | eval "bootparam_${opt}=true" | ||
| 109 | else | ||
| 110 | value="`echo $p | cut -d'=' -f2-`" | ||
| 111 | if [ "`echo $value | sed -e 's/^\"//'`" != "$value" ]; then | ||
| 112 | quoted=${opt} | ||
| 113 | continue | ||
| 114 | fi | ||
| 115 | eval "bootparam_${opt}=\"${value}\"" | ||
| 116 | fi | ||
| 117 | done | ||
| 118 | |||
| 119 | # use /dev with devtmpfs | ||
| 120 | if grep -q devtmpfs /proc/filesystems; then | ||
| 121 | mkdir -p /dev | ||
| 122 | mount -t devtmpfs devtmpfs /dev | ||
| 123 | else | ||
| 124 | if [ ! -d /dev ]; then | ||
| 125 | fatal "ERROR: /dev doesn't exist and kernel doesn't have devtmpfs enabled." | ||
| 126 | fi | ||
| 127 | fi | ||
| 128 | |||
| 129 | mkdir $ROOTFS_DIR | ||
| 130 | |||
| 131 | # Load and run modules | ||
| 132 | for m in $MODULES_DIR/*; do | ||
| 133 | # Skip backup files | ||
| 134 | if [ "`echo $m | sed -e 's/\~$//'`" != "$m" ]; then | ||
| 135 | continue | ||
| 136 | fi | ||
| 137 | |||
| 138 | module=`basename $m | cut -d'-' -f 2` | ||
| 139 | debug "Loading module $module" | ||
| 140 | |||
| 141 | # pre hooks | ||
| 142 | for h in $MODULE_PRE_HOOKS; do | ||
| 143 | debug "Calling module hook (pre): $h" | ||
| 144 | eval "$h pre $module" | ||
| 145 | debug "Finished module hook (pre): $h" | ||
| 146 | done | ||
| 147 | |||
| 148 | # process module | ||
| 149 | . $m | ||
| 150 | |||
| 151 | if ! eval "${module}_enabled"; then | ||
| 152 | debug "Skipping module $module" | ||
| 153 | continue | ||
| 154 | fi | ||
| 155 | |||
| 156 | debug "Running ${module}_run" | ||
| 157 | eval "${module}_run" | ||
| 158 | |||
| 159 | # post hooks | ||
| 160 | for h in $MODULE_POST_HOOKS; do | ||
| 161 | debug "Calling module hook (post): $h" | ||
| 162 | eval "$h post $module" | ||
| 163 | debug "Finished module hook (post): $h" | ||
| 164 | done | ||
| 165 | done | ||
| 166 | |||
| 167 | # Catch all | ||
| 168 | fatal "ERROR: Initramfs failed to initialize the system." | ||
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/lvm b/meta/recipes-core/initrdscripts/initramfs-framework/lvm deleted file mode 100644 index 7deeccb9a2..0000000000 --- a/meta/recipes-core/initrdscripts/initramfs-framework/lvm +++ /dev/null | |||
| @@ -1,13 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | lvm_enabled() { | ||
| 4 | if ! lvscan |grep -i -w "inactive" &>/dev/null;then | ||
| 5 | return 1 | ||
| 6 | fi | ||
| 7 | return 0 | ||
| 8 | } | ||
| 9 | |||
| 10 | lvm_run() { | ||
| 11 | lvm pvscan --cache --activate ay | ||
| 12 | udevadm trigger --action=add | ||
| 13 | } | ||
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/mdev b/meta/recipes-core/initrdscripts/initramfs-framework/mdev deleted file mode 100644 index 9814d9764a..0000000000 --- a/meta/recipes-core/initrdscripts/initramfs-framework/mdev +++ /dev/null | |||
| @@ -1,30 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Copyright (C) 2011, 2017 O.S. Systems Software LTDA. | ||
| 3 | # Licensed on MIT | ||
| 4 | |||
| 5 | mdev_enabled() { | ||
| 6 | if [ ! -e /sbin/mdev ]; then | ||
| 7 | debug "/sbin/mdev doesn't exist" | ||
| 8 | return 1 | ||
| 9 | fi | ||
| 10 | |||
| 11 | return 0 | ||
| 12 | } | ||
| 13 | |||
| 14 | mdev_run() { | ||
| 15 | # setup the environment | ||
| 16 | mount -t tmpfs tmpfs /dev | ||
| 17 | |||
| 18 | mkdir -m 1777 /dev/shm | ||
| 19 | |||
| 20 | mkdir -m 0755 /dev/pts | ||
| 21 | mount -t devpts devpts /dev/pts | ||
| 22 | |||
| 23 | echo /sbin/mdev > /proc/sys/kernel/hotplug | ||
| 24 | mdev -s | ||
| 25 | |||
| 26 | # load modules for devices | ||
| 27 | find /sys -name modalias | while read m; do | ||
| 28 | load_kernel_module $(cat "$m") | ||
| 29 | done | ||
| 30 | } | ||
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/nfsrootfs b/meta/recipes-core/initrdscripts/initramfs-framework/nfsrootfs deleted file mode 100644 index 30555aef55..0000000000 --- a/meta/recipes-core/initrdscripts/initramfs-framework/nfsrootfs +++ /dev/null | |||
| @@ -1,48 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | nfsrootfs_enabled() { | ||
| 4 | if [ "${bootparam_root}" != "/dev/nfs" ] || [ -z ${bootparam_nfsroot} ]; then | ||
| 5 | return 1 | ||
| 6 | fi | ||
| 7 | return 0 | ||
| 8 | } | ||
| 9 | |||
| 10 | nfsrootfs_run() { | ||
| 11 | local nfs_opts | ||
| 12 | local location | ||
| 13 | local flags | ||
| 14 | local server_ip | ||
| 15 | |||
| 16 | nfs_opts="" | ||
| 17 | if [ "${bootparam_nfsroot#*,}" != "${bootparam_nfsroot}" ]; then | ||
| 18 | nfs_opts="-o ${bootparam_nfsroot#*,}" | ||
| 19 | fi | ||
| 20 | |||
| 21 | location="${bootparam_nfsroot%%,*}" | ||
| 22 | if [ "${location#*:}" = "${location}" ]; then | ||
| 23 | # server-ip not given. Get server ip from ip option | ||
| 24 | server_ip="" | ||
| 25 | if [ "${bootparam_ip#*:}" != "${bootparam_ip}" ]; then | ||
| 26 | server_ip=$(echo "$bootparam_ip" | cut -d: -f2) | ||
| 27 | fi | ||
| 28 | |||
| 29 | if [ -z "$server_ip" ]; then | ||
| 30 | fatal "Server IP is not set. Update ip or nfsroot options." | ||
| 31 | fi | ||
| 32 | location=${server_ip}:${location} | ||
| 33 | fi | ||
| 34 | |||
| 35 | flags="-o nolock" | ||
| 36 | if [ -n "$bootparam_ro" ] && ! echo "$bootparam_rootflags" | grep -w -q "ro"; then | ||
| 37 | if [ -n "$bootparam_rootflags" ]; then | ||
| 38 | bootparam_rootflags="$bootparam_rootflags," | ||
| 39 | fi | ||
| 40 | bootparam_rootflags="${bootparam_rootflags}ro" | ||
| 41 | fi | ||
| 42 | if [ -n "$bootparam_rootflags" ]; then | ||
| 43 | flags="$flags -o $bootparam_rootflags" | ||
| 44 | fi | ||
| 45 | |||
| 46 | mount -t nfs ${flags} ${nfs_opts} ${location} ${ROOTFS_DIR} | ||
| 47 | } | ||
| 48 | |||
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot b/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot deleted file mode 100644 index 0d41432878..0000000000 --- a/meta/recipes-core/initrdscripts/initramfs-framework/overlayroot +++ /dev/null | |||
| @@ -1,118 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # SPDX-License-Identifier: MIT | ||
| 4 | # | ||
| 5 | # Copyright 2022 (C), Microsoft Corporation | ||
| 6 | |||
| 7 | # Simple initramfs module intended to mount a read-write (RW) | ||
| 8 | # overlayfs on top of /, keeping the original root filesystem | ||
| 9 | # as read-only (RO), free from modifications by the user. | ||
| 10 | # | ||
| 11 | # NOTE: The read-only IMAGE_FEATURE is not required for this to work | ||
| 12 | # | ||
| 13 | # This script is based on the overlay-etc.bbclass, which sets up | ||
| 14 | # an overlay on top of the /etc directory, but in this case allows | ||
| 15 | # accessing the original, unmodified rootfs at /rofs after boot. | ||
| 16 | # | ||
| 17 | # It relies on the initramfs-module-rootfs to mount the original | ||
| 18 | # root filesystem, and requires 'overlayrootrwdev=<foo>' to be passed as a | ||
| 19 | # kernel parameter, specifying the device/partition intended to | ||
| 20 | # use as RW. | ||
| 21 | # Mount options of the RW device can be tweaked with 'overlayrootfstype=' | ||
| 22 | # (defaults to 'ext4') and 'overlayrootfsflags=' ('defaults'). | ||
| 23 | # | ||
| 24 | # This module needs to be executed after the initramfs-module-rootfs | ||
| 25 | # since it relies on it to mount the filesystem at initramfs startup | ||
| 26 | # but before the finish module which normally switches root. | ||
| 27 | # After overlayroot is executed the usual boot flow continues from | ||
| 28 | # the real init process. | ||
| 29 | # | ||
| 30 | # If something goes wrong while running this module, the rootfs | ||
| 31 | # is still mounted RO (with no overlay) and the finish module is | ||
| 32 | # executed to continue booting normally. | ||
| 33 | # | ||
| 34 | # It also has a dependency on overlayfs being enabled in the | ||
| 35 | # running kernel via KERNEL_FEATURES (kmeta) or any other means. | ||
| 36 | |||
| 37 | |||
| 38 | PATH=/sbin:/bin:/usr/sbin:/usr/bin | ||
| 39 | |||
| 40 | # We get OLDROOT from the rootfs module | ||
| 41 | OLDROOT="/rootfs" | ||
| 42 | |||
| 43 | NEWROOT="${RWMOUNT}/root" | ||
| 44 | RWMOUNT="/overlay" | ||
| 45 | ROMOUNT="${RWMOUNT}/rofs" | ||
| 46 | UPPER_DIR="${RWMOUNT}/upper" | ||
| 47 | WORK_DIR="${RWMOUNT}/work" | ||
| 48 | |||
| 49 | MODULES_DIR=/init.d | ||
| 50 | |||
| 51 | # Something went wrong, make sure / is mounted as read only anyway. | ||
| 52 | exit_gracefully() { | ||
| 53 | echo $1 >/dev/console | ||
| 54 | echo >/dev/console | ||
| 55 | echo "OverlayRoot mounting failed, starting system as read-only" >/dev/console | ||
| 56 | echo >/dev/console | ||
| 57 | |||
| 58 | # The following is borrowed from rootfs-postcommands.bbclass | ||
| 59 | # This basically looks at the real rootfs mounting options and | ||
| 60 | # replaces them with "ro" | ||
| 61 | |||
| 62 | # Tweak the mount option and fs_passno for rootfs in fstab | ||
| 63 | if [ -f ${OLDROOT}/etc/fstab ]; then | ||
| 64 | sed -i -e '/^[#[:space:]]*\/dev\/root/{s/defaults/ro/;s/\([[:space:]]*[[:digit:]]\)\([[:space:]]*\)[[:digit:]]$/\1\20/}' ${OLDROOT}/etc/fstab | ||
| 65 | fi | ||
| 66 | |||
| 67 | # Tweak the "mount -o remount,rw /" command in busybox-inittab inittab | ||
| 68 | if [ -f ${OLDROOT}/etc/inittab ]; then | ||
| 69 | sed -i 's|/bin/mount -o remount,rw /|/bin/mount -o remount,ro /|' ${OLDROOT}/etc/inittab | ||
| 70 | fi | ||
| 71 | |||
| 72 | # Continue as if the overlayroot module didn't exist to continue booting | ||
| 73 | . $MODULES_DIR/99-finish | ||
| 74 | eval "finish_run" | ||
| 75 | } | ||
| 76 | |||
| 77 | # migrate legacy parameter | ||
| 78 | if [ ! -z "$bootparam_rootrw" ]; then | ||
| 79 | bootparam_overlayrootrwdev="$bootparam_rootrw" | ||
| 80 | fi | ||
| 81 | |||
| 82 | if [ -z "$bootparam_overlayrootrwdev" ]; then | ||
| 83 | exit_gracefully "overlayrootrwdev= kernel parameter doesn't exist and its required to mount the overlayfs" | ||
| 84 | fi | ||
| 85 | |||
| 86 | mkdir -p ${RWMOUNT} | ||
| 87 | |||
| 88 | # Mount RW device | ||
| 89 | if mount -n -t ${bootparam_overlayrootfstype:-ext4} -o ${bootparam_overlayrootfsflags:-defaults} ${bootparam_overlayrootrwdev} ${RWMOUNT} | ||
| 90 | then | ||
| 91 | # Set up overlay directories | ||
| 92 | mkdir -p ${UPPER_DIR} | ||
| 93 | mkdir -p ${WORK_DIR} | ||
| 94 | mkdir -p ${NEWROOT} | ||
| 95 | mkdir -p ${ROMOUNT} | ||
| 96 | |||
| 97 | # Remount OLDROOT as read-only | ||
| 98 | mount -o bind ${OLDROOT} ${ROMOUNT} | ||
| 99 | mount -o remount,ro ${ROMOUNT} | ||
| 100 | |||
| 101 | # Mount RW overlay | ||
| 102 | mount -t overlay overlay -o lowerdir=${ROMOUNT},upperdir=${UPPER_DIR},workdir=${WORK_DIR} ${NEWROOT} || exit_gracefully "initramfs-overlayroot: Mounting overlay failed" | ||
| 103 | else | ||
| 104 | exit_gracefully "initramfs-overlayroot: Mounting RW device failed" | ||
| 105 | fi | ||
| 106 | |||
| 107 | # Set up filesystems on overlay | ||
| 108 | mkdir -p ${NEWROOT}/proc | ||
| 109 | mkdir -p ${NEWROOT}/dev | ||
| 110 | mkdir -p ${NEWROOT}/sys | ||
| 111 | mkdir -p ${NEWROOT}/rofs | ||
| 112 | |||
| 113 | mount -n --move ${ROMOUNT} ${NEWROOT}/rofs | ||
| 114 | mount -n --move /proc ${NEWROOT}/proc | ||
| 115 | mount -n --move /sys ${NEWROOT}/sys | ||
| 116 | mount -n --move /dev ${NEWROOT}/dev | ||
| 117 | |||
| 118 | exec chroot ${NEWROOT}/ ${bootparam_init:-/sbin/init} || exit_gracefully "Couldn't chroot into overlay" | ||
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/rootfs b/meta/recipes-core/initrdscripts/initramfs-framework/rootfs deleted file mode 100644 index df0cbfb091..0000000000 --- a/meta/recipes-core/initrdscripts/initramfs-framework/rootfs +++ /dev/null | |||
| @@ -1,69 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Copyright (C) 2011 O.S. Systems Software LTDA. | ||
| 3 | # Licensed on MIT | ||
| 4 | |||
| 5 | rootfs_enabled() { | ||
| 6 | return 0 | ||
| 7 | } | ||
| 8 | |||
| 9 | rootfs_run() { | ||
| 10 | if [ -z "$ROOTFS_DIR" ]; then | ||
| 11 | return | ||
| 12 | fi | ||
| 13 | C=0 | ||
| 14 | delay=${bootparam_rootdelay:-1} | ||
| 15 | timeout=${bootparam_roottimeout:-5} | ||
| 16 | while ! mountpoint -q $ROOTFS_DIR; do | ||
| 17 | if [ $(( $C * $delay )) -gt $timeout ]; then | ||
| 18 | fatal "root '$bootparam_root' doesn't exist or does not contain a /dev." | ||
| 19 | fi | ||
| 20 | |||
| 21 | if [ -n "$bootparam_root" ]; then | ||
| 22 | debug "No e2fs compatible filesystem has been mounted, mounting $bootparam_root..." | ||
| 23 | |||
| 24 | if [ "`echo ${bootparam_root} | cut -c1-5`" = "UUID=" ]; then | ||
| 25 | root_uuid=`echo $bootparam_root | cut -c6-` | ||
| 26 | bootparam_root="/dev/disk/by-uuid/$root_uuid" | ||
| 27 | elif [ "`echo ${bootparam_root} | cut -c1-9`" = "PARTUUID=" ]; then | ||
| 28 | root_partuuid=`echo $bootparam_root | cut -c10-` | ||
| 29 | bootparam_root="/dev/disk/by-partuuid/$root_partuuid" | ||
| 30 | elif [ "`echo ${bootparam_root} | cut -c1-10`" = "PARTLABEL=" ]; then | ||
| 31 | root_partlabel=`echo $bootparam_root | cut -c11-` | ||
| 32 | bootparam_root="/dev/disk/by-partlabel/$root_partlabel" | ||
| 33 | elif [ "`echo ${bootparam_root} | cut -c1-6`" = "LABEL=" ]; then | ||
| 34 | root_label=`echo $bootparam_root | cut -c7-` | ||
| 35 | bootparam_root="/dev/disk/by-label/$root_label" | ||
| 36 | elif echo "${bootparam_root}" | grep -q '^ubi[0-9]\+:'; then | ||
| 37 | bootparam_rootfstype="ubifs" | ||
| 38 | fi | ||
| 39 | |||
| 40 | if [ -e "$bootparam_root" ] || [ -n "$bootparam_rootfstype" ]; then | ||
| 41 | flags="" | ||
| 42 | if [ -n "$bootparam_ro" ] && ! echo "$bootparam_rootflags" | grep -w -q "ro"; then | ||
| 43 | if [ -n "$bootparam_rootflags" ]; then | ||
| 44 | bootparam_rootflags="$bootparam_rootflags," | ||
| 45 | fi | ||
| 46 | bootparam_rootflags="${bootparam_rootflags}ro" | ||
| 47 | fi | ||
| 48 | if [ -n "$bootparam_rootflags" ]; then | ||
| 49 | flags="$flags -o$bootparam_rootflags" | ||
| 50 | fi | ||
| 51 | if [ -n "$bootparam_rootfstype" ]; then | ||
| 52 | flags="$flags -t$bootparam_rootfstype" | ||
| 53 | fi | ||
| 54 | debug "mount $flags $bootparam_root $ROOTFS_DIR" | ||
| 55 | mount $flags $bootparam_root $ROOTFS_DIR | ||
| 56 | if mountpoint -q $ROOTFS_DIR; then | ||
| 57 | break | ||
| 58 | else | ||
| 59 | # It is unlikely to change, but keep trying anyway. | ||
| 60 | # Perhaps we pick a different device next time. | ||
| 61 | umount $ROOTFS_DIR | ||
| 62 | fi | ||
| 63 | fi | ||
| 64 | fi | ||
| 65 | debug "Sleeping for $delay second(s) to wait for root to settle..." | ||
| 66 | sleep $delay | ||
| 67 | C=$(( $C + 1 )) | ||
| 68 | done | ||
| 69 | } | ||
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/setup-live b/meta/recipes-core/initrdscripts/initramfs-framework/setup-live deleted file mode 100644 index 7e92f93322..0000000000 --- a/meta/recipes-core/initrdscripts/initramfs-framework/setup-live +++ /dev/null | |||
| @@ -1,64 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Copyright (C) 2011 O.S. Systems Software LTDA. | ||
| 3 | # Licensed on MIT | ||
| 4 | |||
| 5 | setup_enabled() { | ||
| 6 | return 0 | ||
| 7 | } | ||
| 8 | |||
| 9 | setup_run() { | ||
| 10 | ROOT_IMAGE="rootfs.img" | ||
| 11 | ISOLINUX="" | ||
| 12 | ROOT_DISK="" | ||
| 13 | shelltimeout=30 | ||
| 14 | |||
| 15 | if [ -z "$bootparam_root" -o "$bootparam_root" = "/dev/ram0" ]; then | ||
| 16 | echo "Waiting for removable media..." | ||
| 17 | C=0 | ||
| 18 | while true | ||
| 19 | do | ||
| 20 | for i in `ls /run/media 2>/dev/null`; do | ||
| 21 | if [ -f /run/media/$i/$ROOT_IMAGE ] ; then | ||
| 22 | found="yes" | ||
| 23 | ROOT_DISK="$i" | ||
| 24 | break | ||
| 25 | elif [ -f /run/media/$i/isolinux/$ROOT_IMAGE ]; then | ||
| 26 | found="yes" | ||
| 27 | ISOLINUX="isolinux" | ||
| 28 | ROOT_DISK="$i" | ||
| 29 | break | ||
| 30 | fi | ||
| 31 | done | ||
| 32 | if [ "$found" = "yes" ]; then | ||
| 33 | break; | ||
| 34 | fi | ||
| 35 | # don't wait for more than $shelltimeout seconds, if it's set | ||
| 36 | if [ -n "$shelltimeout" ]; then | ||
| 37 | echo -n " " $(( $shelltimeout - $C )) | ||
| 38 | if [ $C -ge $shelltimeout ]; then | ||
| 39 | echo "..." | ||
| 40 | echo "Mounted filesystems" | ||
| 41 | mount | grep media | ||
| 42 | echo "Available block devices" | ||
| 43 | cat /proc/partitions | ||
| 44 | fatal "Cannot find $ROOT_IMAGE file in /run/media/* , dropping to a shell " | ||
| 45 | fi | ||
| 46 | C=$(( C + 1 )) | ||
| 47 | fi | ||
| 48 | sleep 1 | ||
| 49 | done | ||
| 50 | # The existing rootfs module has no support for rootfs images. Assign the rootfs image. | ||
| 51 | bootparam_root="/run/media/$ROOT_DISK/$ISOLINUX/$ROOT_IMAGE" | ||
| 52 | fi | ||
| 53 | |||
| 54 | if [ "$bootparam_LABEL" != "boot" -a -f /init.d/$bootparam_LABEL.sh ] ; then | ||
| 55 | if [ -f /run/media/$i/$ISOLINUX/$ROOT_IMAGE ] ; then | ||
| 56 | ./init.d/$bootparam_LABEL.sh $i/$ISOLINUX $ROOT_IMAGE $video_mode $vga_mode $console_params | ||
| 57 | else | ||
| 58 | fatal "Could not find $bootparam_LABEL script" | ||
| 59 | fi | ||
| 60 | |||
| 61 | # If we're getting here, we failed... | ||
| 62 | fatal "Target $bootparam_LABEL failed" | ||
| 63 | fi | ||
| 64 | } | ||
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/udev b/meta/recipes-core/initrdscripts/initramfs-framework/udev deleted file mode 100644 index 4898b89246..0000000000 --- a/meta/recipes-core/initrdscripts/initramfs-framework/udev +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Copyright (C) 2011, 2012 O.S. Systems Software LTDA. | ||
| 3 | # Licensed on MIT | ||
| 4 | |||
| 5 | udev_shutdown_hook_handler() { | ||
| 6 | status=$1 | ||
| 7 | module=$2 | ||
| 8 | if [ "$status" = "pre" ] && [ "$module" = "finish" ]; then | ||
| 9 | udevadm settle | ||
| 10 | killall `basename $_UDEV_DAEMON` 2>/dev/null | ||
| 11 | fi | ||
| 12 | } | ||
| 13 | |||
| 14 | udev_daemon() { | ||
| 15 | OPTIONS="/sbin/udev/udevd /sbin/udevd /lib/udev/udevd /lib/systemd/systemd-udevd" | ||
| 16 | |||
| 17 | for o in $OPTIONS; do | ||
| 18 | if [ -x "$o" ]; then | ||
| 19 | echo $o | ||
| 20 | return 0 | ||
| 21 | fi | ||
| 22 | done | ||
| 23 | |||
| 24 | return 1 | ||
| 25 | } | ||
| 26 | |||
| 27 | _UDEV_DAEMON=`udev_daemon` | ||
| 28 | |||
| 29 | udev_enabled() { | ||
| 30 | if [ -z "$_UDEV_DAEMON" ]; then | ||
| 31 | msg "WARNING: Cannot find the udev daemon; daemon will not be started in initramfs." | ||
| 32 | return 1 | ||
| 33 | fi | ||
| 34 | |||
| 35 | return 0 | ||
| 36 | } | ||
| 37 | |||
| 38 | udev_run() { | ||
| 39 | add_module_pre_hook "udev_shutdown_hook_handler" | ||
| 40 | |||
| 41 | mkdir -p /run | ||
| 42 | mkdir -p /var/run | ||
| 43 | |||
| 44 | # Workaround if console=null, systemd-udevd needs valid stdin, stdout and stderr to work | ||
| 45 | sh -c "exec 4< /dev/console" || { exec 0> /dev/null; exec 1> /dev/null; exec 2> /dev/null; } | ||
| 46 | |||
| 47 | $_UDEV_DAEMON --daemon | ||
| 48 | udevadm trigger --action=add | ||
| 49 | udevadm settle | ||
| 50 | } | ||
