summaryrefslogtreecommitdiffstats
path: root/recipes/ostree
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@theqtcompany.com>2016-03-07 14:55:13 +0100
committerGatis Paeglis <gatis.paeglis@theqtcompany.com>2016-03-08 09:55:29 +0000
commit2bd715056f84d866ec52e015c3658c0e2ac509be (patch)
treee7e1baf46eb98985b281ec4cd910d600148ca4cc /recipes/ostree
parent91b76a3addfd33df204ae4fabbe694a775e9c56c (diff)
downloadmeta-boot2qt-2bd715056f84d866ec52e015c3658c0e2ac509be.tar.gz
ostree: Mount boot partition from user space
In the current approach we assumed that boot/ - is on a separate boot partition - boot partition is right before rootfs partition - rootfs parition is provided as a *device node* - has "ext2" filesystem (mount shell cmd tries to auto detect FS type, mount system call does not.) The new approch does not assume any of the above, and moves this logic from early user space (initramfs) to user space. Initramfs by design should be used only to prepare the rootfs, other tasks should be done later. Change-Id: Idc429c8061c1fd486658e4b4d170ee487682cc91 Reviewed-by: Samuli Piippo <samuli.piippo@theqtcompany.com>
Diffstat (limited to 'recipes/ostree')
-rw-r--r--recipes/ostree/ostree/0004-Mount-boot-partition.patch108
1 files changed, 43 insertions, 65 deletions
diff --git a/recipes/ostree/ostree/0004-Mount-boot-partition.patch b/recipes/ostree/ostree/0004-Mount-boot-partition.patch
index 092e142..a81f731 100644
--- a/recipes/ostree/ostree/0004-Mount-boot-partition.patch
+++ b/recipes/ostree/ostree/0004-Mount-boot-partition.patch
@@ -1,82 +1,60 @@
1From 5e9ed74a20026e5c9043eaf8a224ce84cb9cd9f0 Mon Sep 17 00:00:00 2001 1From 33642082578946fdc73ade8b78c05ba8d8521652 Mon Sep 17 00:00:00 2001
2From: Gatis Paeglis <gatis.paeglis@theqtcompany.com> 2From: Gatis Paeglis <gatis.paeglis@theqtcompany.com>
3Date: Mon, 7 Dec 2015 18:14:26 +0100 3Date: Mon, 7 Mar 2016 15:17:34 +0100
4Subject: [PATCH] Mount boot partition 4Subject: [PATCH] ostree: Mount boot partition from user space
5 5
6On b2qt reference images the boot partition always is 6In the current approach we assumed that boot/
7the first partition on a device and rootfs is the second 7
8partition. We can get the root parition from a kernel 8- is on a separate boot partition
9command line and deduce the right boot partition from there. 9- boot partition is right before rootfs partition
10- rootfs parition is provided as a *device node*
11- has "ext2" filesystem (mount shell cmd tries to
12 auto detect FS type, mount system call does not.)
13
14The new approch does not assume any of the above, and
15moves this logic from early user space (initramfs) to
16user space. Initramfs by design should be used only to
17prepare the rootfs, other tasks should be done later.
10--- 18---
11 src/switchroot/ostree-prepare-root.c | 23 ++++++++++++++++++----- 19 src/switchroot/ostree-remount.c | 19 ++++++++++++++++++-
12 1 file changed, 18 insertions(+), 5 deletions(-) 20 1 file changed, 18 insertions(+), 1 deletion(-)
13 21
14diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c 22diff --git a/src/switchroot/ostree-remount.c b/src/switchroot/ostree-remount.c
15index 3de137b..2637dc3 100644 23index b8d3a96..33f2645 100644
16--- a/src/switchroot/ostree-prepare-root.c 24--- a/src/switchroot/ostree-remount.c
17+++ b/src/switchroot/ostree-prepare-root.c 25+++ b/src/switchroot/ostree-remount.c
18@@ -45,7 +45,7 @@ 26@@ -77,7 +77,7 @@ maybe_mount_tmpfs_on_var (void)
19 #include "ostree-mount-util.h" 27 int
20 28 main(int argc, char *argv[])
21 static char *
22-parse_ostree_cmdline (void)
23+parse_kernel_cmdline (const char *arg)
24 { 29 {
25 FILE *f = fopen("/proc/cmdline", "r"); 30- const char *remounts[] = { "/sysroot", "/etc", "/home", "/root", "/tmp", "/var", NULL };
26 char *cmdline = NULL; 31+ const char *remounts[] = { "/sysroot", "/etc", "/home", "/root", "/tmp", "/var", "/boot", NULL };
27@@ -75,9 +75,9 @@ parse_ostree_cmdline (void)
28 const char *next_nonspc = next;
29 while (next_nonspc && *next_nonspc == ' ')
30 next_nonspc += 1;
31- if (strncmp (iter, "ostree=", strlen ("ostree=")) == 0)
32+ if (strncmp (iter, arg, strlen (arg)) == 0)
33 {
34- const char *start = iter + strlen ("ostree=");
35+ const char *start = iter + strlen (arg);
36 if (next)
37 ret = strndup (start, next - start);
38 else
39@@ -114,10 +114,12 @@ main(int argc, char *argv[])
40 const char *readonly_bind_mounts[] = { "/usr", NULL };
41 const char *root_mountpoint = NULL;
42 char *ostree_target = NULL;
43+ char *boot_partition = NULL;
44 char *deploy_path = NULL;
45 char srcpath[PATH_MAX];
46 char destpath[PATH_MAX];
47 char newroot[PATH_MAX];
48+ char boot_mountpoint[PATH_MAX];
49 struct stat stbuf; 32 struct stat stbuf;
50 int i; 33 int i;
51 34
52@@ -129,7 +131,7 @@ main(int argc, char *argv[]) 35@@ -117,5 +117,22 @@ main(int argc, char *argv[])
53 36
54 root_mountpoint = argv[1]; 37 maybe_mount_tmpfs_on_var ();
55 38
56- ostree_target = parse_ostree_cmdline (); 39+ /* ostree-prepare-root mounts boot/ if it is on the same partition as root filesystem.
57+ ostree_target = parse_kernel_cmdline ("ostree="); 40+ * If boot/ is not mounted, then it must be on a different partition. Try to mount
58 if (!ostree_target) 41+ * filesystem where LABEL=boot-ostree.
59 { 42+ */
60 fprintf (stderr, "No OSTree target; expected ostree=/ostree/boot.N/...\n"); 43+ if (!(lstat ("/boot/loader", &stbuf) == 0 && S_ISLNK (stbuf.st_mode)))
61@@ -246,6 +248,17 @@ main(int argc, char *argv[])
62 perrorv ("failed to MS_MOVE %s to %s", deploy_path, root_mountpoint);
63 exit (EXIT_FAILURE);
64 }
65-
66+
67+ /* first partition always is the boot partition */
68+ boot_partition = parse_kernel_cmdline ("root=");
69+ boot_partition[strlen (boot_partition) - 1] = '1';
70+ /* mount the real boot parition over the deployment's boot directory */
71+ snprintf (boot_mountpoint, sizeof(boot_mountpoint), "%s/boot/", root_mountpoint);
72+ if (mount (boot_partition, boot_mountpoint, "ext2", 0, NULL) < 0)
73+ { 44+ {
74+ perrorv ("failed to mount boot parition %s to %s", boot_partition, boot_mountpoint); 45+ /* mount the real boot parition over the deployment's boot directory */
75+ exit (EXIT_FAILURE); 46+ const char *mount_cmd="mount LABEL=boot-ostree /boot";
47+ FILE *fp = popen (mount_cmd, "w");
48+ if (fp == NULL)
49+ {
50+ perrorv ("popen failed for: %s", mount_cmd);
51+ exit (EXIT_FAILURE);
52+ }
53+ pclose (fp);
76+ } 54+ }
77+ 55+
78 exit (EXIT_SUCCESS); 56 exit (EXIT_SUCCESS);
79 } 57 }
80-- 58--
812.1.4 592.7.0
82 60