summaryrefslogtreecommitdiff
path: root/recipes-core/initrdscripts
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2019-10-28 11:39:46 -0500
committerSerhii Kostiuk <serhii.o.kostiuk@globallogic.com>2020-05-20 19:50:21 +0300
commit12ee8f8d7c73aee8193ab2d1663aaf56a9beb8d5 (patch)
treea4cde71c4d55a1eecaee2051b001ab435d1ccac6 /recipes-core/initrdscripts
parent06788a644501e5a7e12405d57c8649732b5a8d6f (diff)
downloadmeta-mlinux-12ee8f8d7c73aee8193ab2d1663aaf56a9beb8d5.tar.gz
meta-mlinux-12ee8f8d7c73aee8193ab2d1663aaf56a9beb8d5.tar.bz2
meta-mlinux-12ee8f8d7c73aee8193ab2d1663aaf56a9beb8d5.zip
Fix up logging (/var/log/dmesg) and kernel parameters for initramfs
Diffstat (limited to 'recipes-core/initrdscripts')
-rwxr-xr-xrecipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh63
1 files changed, 43 insertions, 20 deletions
diff --git a/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh b/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh
index 6ec69ab..545da5c 100755
--- a/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh
+++ b/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh
@@ -33,9 +33,23 @@
# Preen (-p) is the default
#
# Additional options exist to specify the init program
-# mount options, file system type. root_rwreset="yes"
+# mount options, file system type. rootrwreset="yes"
# will cause the read/write file system to be erased.
#
+# shintramfs starts a shell. To continue boot from
+# shell:
+#
+# bash-4.4# export ROOT_MOUNT=/mnt
+# bash-4.4# export INIT=/sbin/init
+# bash-4.4# exec switch_root $ROOT_MOUNT $INIT
+#
+#
+# U-Boot environment example to add an init overlay parameter:
+#
+# => printenv args_mmc
+# args_mmc=run finduuid;setenv bootargs console=${console} ${optargs} root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype}
+#
+# => setenv args_mmc 'run finduuid;setenv bootargs console=${console} ${optargs} root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype} rootrwreset=yes'
# Enable strict shell mode
@@ -106,6 +120,7 @@ read_args() {
if rootdev=$(finddevice "${ROOT_RODEVICE}") ; then
# Replace the rootfs string with the findfs device result
ROOT_RODEVICE="${rootdev}"
+ log "Actual root device to be used: $ROOT_RODEVICE"
fi
;;
rootfstype=*)
@@ -144,7 +159,7 @@ read_args() {
fsck_repair=$optarg
case $fsck_repair in
force)
- if ((${#FSCKOPT)) ; then
+ if ((${#FSCKOPT})) ; then
FSCKOPT+="f"
else
FSCKOPT="-f"
@@ -171,15 +186,18 @@ fatal() {
}
log() {
- echo "rorootfs-overlay: $1" >$CONSOLE
+ echo "rorootfs-overlay: ${BASH_LINENO[*]}: ${*-""}" >$CONSOLE
}
early_setup
-[ -z "${CONSOLE+x}" ] && CONSOLE="/dev/console"
+[ -z "${CONSOLE+x}" ] && CONSOLE="/dev/kmsg"
+log "Kernel args are:"
+log "$(cat /proc/cmdline)"
read_args
+
mount_and_boot() {
mkdir -p $ROOT_MOUNT $ROOT_ROMOUNT $ROOT_RWMOUNT
@@ -193,6 +211,7 @@ mount_and_boot() {
ROOT_ROMOUNTPARAMS="-t $ROOT_ROFSTYPE $ROOT_ROMOUNTPARAMS"
fi
else
+ log "ROOT_RODEVICE: empty: ${ROOT_RODEVICE}"
ROOT_ROMOUNTPARAMS="$ROOT_ROMOUNTPARAMS_BIND"
fi
@@ -200,13 +219,11 @@ mount_and_boot() {
mountresult=$?
if ((mountresult != 0)) ; then
log "Failed root mount (result $mountresult): $mountlog"
- log "mounts: $(cat /proc/mounts)"
else
+ log "Mounted root: $MOUNT $ROOT_ROMOUNTPARAMS "$ROOT_ROMOUNT": $mountlog"
log "Mounted ro root: $(grep "$ROOT_ROMOUNT" /proc/mounts)"
fi
- log "Mounted root: $(grep root /proc/mounts)"
-
# If future init is the same as current file, use $ROOT_ROINIT
# Tries to avoid loop to infinity if init is set to current file via
# kernel command line
@@ -214,7 +231,7 @@ mount_and_boot() {
INIT="$ROOT_ROINIT"
fi
- # find user_data
+ # find user_data
if [[ -z ${ROOT_RWDEVICE} ]] ; then
userdata=$(findfs PARTLABEL=user_data)
blkid_out=$(blkid $userdata)
@@ -228,6 +245,7 @@ mount_and_boot() {
ROOT_RWDEVICE="$userdata"
fi # Found user_data GPT partition
fi # Empty ROOT_RWDEVICE
+
# Build mount options for read write root file system.
# If a read-write device was specified via kernel command line
# or partition table, use it, otherwise default to tmpfs.
@@ -242,25 +260,26 @@ mount_and_boot() {
if ((DO_FSCK == 1)) ; then
if log_result=$(fsck $FSCKOPT $ROOT_RWDEVICE 2>&1) ; then
- log "OK fsck user_data: fsck $FSCKOPT $ROOT_RWDEVICE: $(fsck $FSCKOPT $ROOT_RWDEVICE 2>&1)"
- echo "fsck user_data: $log_result" >/dev/kmsg
+ log "OK fsck user_data: fsck $FSCKOPT $ROOT_RWDEVICE:"
+ log "fsck user_data: $log_result"
else
- log "ERR fsck user_data: fsck $FSCKOPT $ROOT_RWDEVICE: $(fsck $FSCKOPT $ROOT_RWDEVICE 2>&1)"
+ log "ERR fsck user_data: fsck $FSCKOPT $ROOT_RWDEVICE:"
log "$log_result"
- # Write fsck to kernel log
- echo "ERR fsck user_data: fsck $FSCKOPT $ROOT_RWDEVICE: $(fsck $FSCKOPT $ROOT_RWDEVICE 2>&1)" >/dev/kmsg
- echo "$log_result" >/dev/kmsg
fi
fi
+ log "user_data: $MOUNT $ROOT_RWMOUNTPARAMS $ROOT_RWMOUNT"
# Mount read-write file system into initram root file system
if ! $MOUNT $ROOT_RWMOUNTPARAMS $ROOT_RWMOUNT ; then
fatal "Could not mount read-write rootfs"
fi
# Reset read-write file system if specified
- if [ "yes" == "$ROOT_RWRESET" -a -n "${ROOT_RWMOUNT}" ]; then
+ log "ROOT_RWRESET=$ROOT_RWRESET ROOT_RWMOUNT=$ROOT_RWMOUNT"
+ if [ "yes" == "$ROOT_RWRESET" -a -n "${ROOT_RWMOUNT}" ]; then # JAK
+ log "Removing user_data files"
rm -rf $ROOT_RWMOUNT/*
+ log "Completed removal of user_data files"
fi
# Determine which unification file system to use
@@ -276,7 +295,6 @@ mount_and_boot() {
# Create/Mount overlay root file system
case $union_fs_type in
"overlay")
- log "$(cat /proc/mounts)"
mkdir -p $ROOT_RWMOUNT/upperdir $ROOT_RWMOUNT/work
if ! $MOUNT -t overlay overlay \
-o "$(printf "%s%s%s" \
@@ -306,17 +324,22 @@ mount_and_boot() {
# Move read-only and read-write root file system into the overlay
# file system
mkdir -p $ROOT_MOUNT/$ROOT_ROMOUNT $ROOT_MOUNT/$ROOT_RWMOUNT
+
$MOUNT -n --move $ROOT_ROMOUNT ${ROOT_MOUNT}/$ROOT_ROMOUNT
$MOUNT -n --move $ROOT_RWMOUNT ${ROOT_MOUNT}/$ROOT_RWMOUNT
+ if ((DO_STOP)) ; then
+ fatal "Initramfs Shell mode selected -- bash shell"
+ fi
+
$MOUNT -n --move /proc ${ROOT_MOUNT}/proc
$MOUNT -n --move /sys ${ROOT_MOUNT}/sys
$MOUNT -n --move /dev ${ROOT_MOUNT}/dev
- log "overlay: $(grep 'overlay' ${ROOT_MOUNT}/proc/mounts)"
+
+ CONSOLE="${ROOT_MOUNT}/dev/kmsg"
+ log "Mounted filesystems:"
+ log "$(cat ${ROOT_MOUNT}/proc/mounts)"
cd $ROOT_MOUNT
- if ((DO_STOP)) ; then
- fatal "Initramfs Shell mode selected -- bash shell"
- fi
# switch to actual init in the overlay root file system
exec switch_root $ROOT_MOUNT $INIT ||