aboutsummaryrefslogtreecommitdiffstats
path: root/meta-mentor-staging/recipes-core/initrdscripts/files/0001-initramfs-framework-finish-move-mounts-to-rootfs-bef.patch
blob: 1aad394912835b6f07e0eb3d2fc8c37b5a212ab1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From 59f5fd34edae4e1c4633b160ee6c6e51ec6a98e4 Mon Sep 17 00:00:00 2001
From: Awais Belal <awais_belal@mentor.com>
Date: Wed, 28 Nov 2018 13:02:08 +0500
Subject: [PATCH] initramfs-framework/finish: move mounts to rootfs before
 switching

If basic device mounts are not moved onto the rootfs before
switching, the device is not properly accessible for operations
such as mkfs and for such devices once the system is fully booted
we see

root@v1000:~# mkfs.ext4 /dev/sdb1
mke2fs 1.43.8 (1-Jan-2018)
/dev/sdb1 contains a ext4 file system
	last mounted on Wed Nov 28 07:33:54 2018
Proceed anyway? (y,N) y
/dev/sdb1 is apparently in use by the system; will not make a filesystem here!

This fragment is picked up from initramfs-live-boot. See
8293f564685d0f587ab63a107285625dc4f98f1c and
6f8f984ba363f764e83290b972ec31a90aad1603
for more details.

Signed-off-by: Awais Belal <awais_belal@mentor.com>
---
 finish | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/finish b/finish
index 717383e..9722d02 100755
--- a/finish
+++ b/finish
@@ -14,6 +14,15 @@ finish_run() {
 
 		info "Switching root to '$ROOTFS_DIR'..."
 
+		debug "Moving basic mounts onto rootfs"
+		for dir in `awk '/\/dev.* \/run\/media/{print $2}' /proc/mounts`; do
+			# Parse any OCT or HEX encoded chars such as spaces
+			# in the mount points to actual ASCII chars
+			dir=`printf $dir`
+			mkdir -p "${ROOTFS_DIR}/media/${dir##*/}"
+			mount -n --move "$dir" "${ROOTFS_DIR}/media/${dir##*/}"
+		done
+
 		debug "Moving /dev, /proc and /sys onto rootfs..."
 		mount --move /dev $ROOTFS_DIR/dev
 		mount --move /proc $ROOTFS_DIR/proc
-- 
2.11.1