diff options
Diffstat (limited to 'meta/recipes-core/initrdscripts/initramfs-framework')
8 files changed, 180 insertions, 5 deletions
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/exec b/meta/recipes-core/initrdscripts/initramfs-framework/exec new file mode 100644 index 0000000000..a8e2432bb6 --- /dev/null +++ b/meta/recipes-core/initrdscripts/initramfs-framework/exec @@ -0,0 +1,29 @@ +#!/bin/sh +# Copyright (C) 2017 O.S. Systems Software LTDA. +# Licensed on MIT + +EXEC_DIR=/exec.d # place to look for modules + +exec_enabled() { + return 0 +} + +exec_run() { + if [ ! -d $EXEC_DIR ]; then + msg "No contents to exec in $EXEC_DIR. Starting shell ..." + sh + fi + + # Load and run modules + for m in $EXEC_DIR/*; do + # Skip backup files + if [ "`echo $m | sed -e 's/\~$//'`" != "$m" ]; then + continue + fi + + debug "Starting $m" + + # process module + ./$m + done +} diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/init b/meta/recipes-core/initrdscripts/initramfs-framework/init index 37527a840a..c71ce0ce8c 100755 --- a/meta/recipes-core/initrdscripts/initramfs-framework/init +++ b/meta/recipes-core/initrdscripts/initramfs-framework/init @@ -72,6 +72,7 @@ ROOTFS_DIR="/rootfs" # where to do the switch root MODULE_PRE_HOOKS="" # functions to call before running each module MODULE_POST_HOOKS="" # functions to call after running each module MODULES_DIR=/init.d # place to look for modules +EFI_DIR=/sys/firmware/efi # place to store device firmware information # make mount stop complaining about missing /etc/fstab touch /etc/fstab @@ -81,10 +82,14 @@ mkdir -p /proc /sys /run/lock /var/lock mount -t proc proc /proc mount -t sysfs sysfs /sys +if [ -d $EFI_DIR ];then + mount -t efivarfs none /sys/firmware/efi/efivars +fi + # populate bootparam environment for p in `cat /proc/cmdline`; do opt=`echo $p | cut -d'=' -f1` - opt=`echo $opt | tr '.-' '__'` + opt=`echo $opt | sed -e 'y/.-/__/'` if [ "`echo $p | cut -d'=' -f1`" = "$p" ]; then eval "bootparam_${opt}=true" else diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/lvm b/meta/recipes-core/initrdscripts/initramfs-framework/lvm new file mode 100644 index 0000000000..7deeccb9a2 --- /dev/null +++ b/meta/recipes-core/initrdscripts/initramfs-framework/lvm @@ -0,0 +1,13 @@ +#!/bin/sh + +lvm_enabled() { + if ! lvscan |grep -i -w "inactive" &>/dev/null;then + return 1 + fi + return 0 +} + +lvm_run() { + lvm pvscan --cache --activate ay + udevadm trigger --action=add +} diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/mdev b/meta/recipes-core/initrdscripts/initramfs-framework/mdev index a5df1d717a..9814d9764a 100644 --- a/meta/recipes-core/initrdscripts/initramfs-framework/mdev +++ b/meta/recipes-core/initrdscripts/initramfs-framework/mdev @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2011 O.S. Systems Software LTDA. +# Copyright (C) 2011, 2017 O.S. Systems Software LTDA. # Licensed on MIT mdev_enabled() { @@ -25,6 +25,6 @@ mdev_run() { # load modules for devices find /sys -name modalias | while read m; do - load_kernel_module $(cat $m) + load_kernel_module $(cat "$m") done } diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/nfsrootfs b/meta/recipes-core/initrdscripts/initramfs-framework/nfsrootfs new file mode 100644 index 0000000000..e67ee4c25d --- /dev/null +++ b/meta/recipes-core/initrdscripts/initramfs-framework/nfsrootfs @@ -0,0 +1,48 @@ +#!/bin/sh + +nfsrootfs_enabled() { + if [ ${bootparam_root} != "/dev/nfs" ] || [ -z ${bootparam_nfsroot} ]; then + return 1 + fi + return 0 +} + +nfsrootfs_run() { + local nfs_opts + local location + local flags + local server_ip + + nfs_opts="" + if [ "${bootparam_nfsroot#*,}" != "${bootparam_nfsroot}" ]; then + nfs_opts="-o ${bootparam_nfsroot#*,}" + fi + + location="${bootparam_nfsroot%%,*}" + if [ "${location#*:}" = "${location}" ]; then + # server-ip not given. Get server ip from ip option + server_ip="" + if [ "${bootparam_ip#*:}" != "${bootparam_ip}" ]; then + server_ip=$(echo "$bootparam_ip" | cut -d: -f2) + fi + + if [ -z "$server_ip" ]; then + fatal "Server IP is not set. Update ip or nfsroot options." + fi + location=${server_ip}:${location} + fi + + flags="-o nolock" + if [ -n "$bootparam_ro" ] && ! echo "$bootparam_rootflags" | grep -w -q "ro"; then + if [ -n "$bootparam_rootflags" ]; then + bootparam_rootflags="$bootparam_rootflags," + fi + bootparam_rootflags="${bootparam_rootflags}ro" + fi + if [ -n "$bootparam_rootflags" ]; then + flags="$flags -o $bootparam_rootflags" + fi + + mount -t nfs ${flags} ${nfs_opts} ${location} ${ROOTFS_DIR} +} + diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/rootfs b/meta/recipes-core/initrdscripts/initramfs-framework/rootfs index 14768f1cd4..748c9391c0 100644 --- a/meta/recipes-core/initrdscripts/initramfs-framework/rootfs +++ b/meta/recipes-core/initrdscripts/initramfs-framework/rootfs @@ -27,8 +27,23 @@ rootfs_run() { fi if [ "`echo ${bootparam_root} | cut -c1-9`" = "PARTUUID=" ]; then - root_uuid=`echo $bootparam_root | cut -c10-` - bootparam_root="/dev/disk/by-partuuid/$root_uuid" + root_partuuid=`echo $bootparam_root | cut -c10-` + bootparam_root="/dev/disk/by-partuuid/$root_partuuid" + fi + + if [ "`echo ${bootparam_root} | cut -c1-10`" = "PARTLABEL=" ]; then + root_partlabel=`echo $bootparam_root | cut -c11-` + bootparam_root="/dev/disk/by-partlabel/$root_partlabel" + fi + + if [ "`echo ${bootparam_root} | cut -c1-10`" = "PARTLABEL=" ]; then + root_partlabel=`echo $bootparam_root | cut -c11-` + bootparam_root="/dev/disk/by-partlabel/$root_partlabel" + fi + + if [ "`echo ${bootparam_root} | cut -c1-6`" = "LABEL=" ]; then + root_label=`echo $bootparam_root | cut -c7-` + bootparam_root="/dev/disk/by-label/$root_label" fi if [ -e "$bootparam_root" ]; then diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/setup-live b/meta/recipes-core/initrdscripts/initramfs-framework/setup-live new file mode 100644 index 0000000000..4c79f41285 --- /dev/null +++ b/meta/recipes-core/initrdscripts/initramfs-framework/setup-live @@ -0,0 +1,64 @@ +#/bin/sh +# Copyright (C) 2011 O.S. Systems Software LTDA. +# Licensed on MIT + +setup_enabled() { + return 0 +} + +setup_run() { +ROOT_IMAGE="rootfs.img" +ISOLINUX="" +ROOT_DISK="" +shelltimeout=30 + + if [ -z "$bootparam_root" -o "$bootparam_root" = "/dev/ram0" ]; then + echo "Waiting for removable media..." + C=0 + while true + do + for i in `ls /run/media 2>/dev/null`; do + if [ -f /run/media/$i/$ROOT_IMAGE ] ; then + found="yes" + ROOT_DISK="$i" + break + elif [ -f /run/media/$i/isolinux/$ROOT_IMAGE ]; then + found="yes" + ISOLINUX="isolinux" + ROOT_DISK="$i" + break + fi + done + if [ "$found" = "yes" ]; then + break; + fi + # don't wait for more than $shelltimeout seconds, if it's set + if [ -n "$shelltimeout" ]; then + echo -n " " $(( $shelltimeout - $C )) + if [ $C -ge $shelltimeout ]; then + echo "..." + echo "Mounted filesystems" + mount | grep media + echo "Available block devices" + cat /proc/partitions + fatal "Cannot find $ROOT_IMAGE file in /run/media/* , dropping to a shell " + fi + C=$(( C + 1 )) + fi + sleep 1 + done + # The existing rootfs module has no support for rootfs images. Assign the rootfs image. + bootparam_root="/run/media/$ROOT_DISK/$ISOLINUX/$ROOT_IMAGE" + fi + + if [ "$bootparam_LABEL" != "boot" -a -f /init.d/$bootparam_LABEL.sh ] ; then + if [ -f /run/media/$i/$ISOLINUX/$ROOT_IMAGE ] ; then + ./init.d/$bootparam_LABEL.sh $i/$ISOLINUX $ROOT_IMAGE $video_mode $vga_mode $console_params + else + fatal "Could not find $bootparam_LABEL script" + fi + + # If we're getting here, we failed... + fatal "Target $bootparam_LABEL failed" + fi +} diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/udev b/meta/recipes-core/initrdscripts/initramfs-framework/udev index 79c8867823..87551ff4a9 100644 --- a/meta/recipes-core/initrdscripts/initramfs-framework/udev +++ b/meta/recipes-core/initrdscripts/initramfs-framework/udev @@ -6,6 +6,7 @@ udev_shutdown_hook_handler() { status=$1 module=$2 if [ "$status" = "pre" ] && [ "$module" = "finish" ]; then + udevadm settle killall `basename $_UDEV_DAEMON` 2>/dev/null fi } |