Skip to content
Snippets Groups Projects
Commit 0414ec99 authored by Davide Cardillo's avatar Davide Cardillo
Browse files

[INITRAMFS] Add mounting of external partitions

Before to jump from ramfs image to the rootfs, the external partitions are
mounted into the folder where the rootfs is mounted.
parent c28d5033
No related branches found
No related tags found
1 merge request!20[WIC][CLASS] Add EgehogSystemPartitionPlugin class
...@@ -8,10 +8,14 @@ export PATH=/sbin:/bin:/usr/sbin:/usr/bin ...@@ -8,10 +8,14 @@ export PATH=/sbin:/bin:/usr/sbin:/usr/bin
# ------------------------------------------- # -------------------------------------------
DATAFS_LABEL=datafs
APPFS_LABEL=appfs
VARFS=varfs
BOOTDEVICE= BOOTDEVICE=
BOOTLOADER= BOOTLOADER=
EXTERNAL_ROOTFS_FOLDERS=
log_info() { echo "$0[$$]: $*" >&2; } log_info() { echo "$0[$$]: $*" >&2; }
log_error() { echo "$0[$$]: ERROR $*" >&2; } log_error() { echo "$0[$$]: ERROR $*" >&2; }
...@@ -31,6 +35,34 @@ do_mount_fs() { ...@@ -31,6 +35,34 @@ do_mount_fs() {
} }
mount_partition_from_label() {
label=$1
mount_point=$2
part=$(blkid -s LABEL /dev/${BOOTDEVICE}* | grep "LABEL=\"${label}\"" |head -n 1| awk -F: '{print $1}')
# no partition found or it is a LUKS(expanding done at LUKS creation)
[ -z ${part} ] && {
part=$(blkid -s LABEL | grep "LABEL=\"luks$datafs_label\"" |head -n 1| awk -F: '{print $1}')
[ -z ${part} ] && return 0
}
if [[ ! -d ${mount_point} ]]; then
log_error "Mount point ${mount_point} does not exist!!!"
return 0
fi
log_info "Mounting ${label} partition (${part})..."
while [ 1 ] ; do
mount -t ext4 "$part" ${mount_point} || {
log_info "Mounting $part failed, waiting 0.1s for the device to be available..."
sleep 0.1
continue
}
break
done
}
get_shell_initramfs() { get_shell_initramfs() {
for opt in $(cat /proc/cmdline); do for opt in $(cat /proc/cmdline); do
arg=$(echo "$opt" | cut -d'=' -f1) arg=$(echo "$opt" | cut -d'=' -f1)
...@@ -84,6 +116,31 @@ while [ 1 ] ; do ...@@ -84,6 +116,31 @@ while [ 1 ] ; do
done done
mount_partition_from_label ${DATAFS_LABEL} /rootfs-extension
log_info "Mount external folder..."
for external in ${EXTERNAL_ROOTFS_FOLDERS}; do
# var folder has an own partition
if [[ "${external//\//}" == "var" ]]; then
continue
fi
log_info "...mount /rootfs-extension/${external} -> /sysroot/${external}"
while [ 1 ] ; do
option=rw,bind
mount -o ${option} /rootfs-extension/${external} /sysroot/${external} || {
log_info "Mounting $external failed, waiting 0.1s for the device to be available..."
sleep 0.1
continue
}
break
done
done
# mount var partition
mount_partition_from_label ${VARFS} /sysroot/var
cd /sysroot cd /sysroot
for x in dev proc sys; do for x in dev proc sys; do
log_info "Moving /$x to new rootfs" log_info "Moving /$x to new rootfs"
...@@ -94,3 +151,5 @@ log_info "Switching to rootfs" ...@@ -94,3 +151,5 @@ log_info "Switching to rootfs"
exec switch_root /sysroot /sbin/init exec switch_root /sysroot /sbin/init
bail_out "Failed to switch_root to $ostree_sysroot" bail_out "Failed to switch_root to $ostree_sysroot"
exec sh
...@@ -11,8 +11,11 @@ do_install() { ...@@ -11,8 +11,11 @@ do_install() {
install -m 0755 ${WORKDIR}/init-boot.sh ${D}/init install -m 0755 ${WORKDIR}/init-boot.sh ${D}/init
install -d ${D}/sysroot install -d ${D}/sysroot
install -d ${D}/rootfs-extension
sed -i "s:EXTERNAL_ROOTFS_FOLDERS=:EXTERNAL_ROOTFS_FOLDERS=\"${EXTERNAL_ROOTFS_FOLDERS}\":" ${D}/init
} }
inherit allarch inherit allarch
FILES:${PN} += "/init /sysroot" FILES:${PN} += "/init /sysroot /rootfs-extension"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment