diff options
| author | Gatis Paeglis <gatis.paeglis@theqtcompany.com> | 2015-12-07 18:22:18 +0100 |
|---|---|---|
| committer | Gatis Paeglis <gatis.paeglis@theqtcompany.com> | 2015-12-14 10:28:30 +0000 |
| commit | 8dce2ffb7320f7fbc1aba7bfbb61af633470049c (patch) | |
| tree | 04a6ff36cbabb03cb9ab207a476fe2524e89da7d | |
| parent | c97f13c28d29bd71c98043f709a5875606300142 (diff) | |
| download | meta-boot2qt-8dce2ffb7320f7fbc1aba7bfbb61af633470049c.tar.gz | |
Mount boot partition from ostree-prepare-root
This is more convenient than having to implement
two code paths to do the same thing - one for systemd
based images and one for systemd-less images.
This is also more efficient, the earlier implementation
in initramfs scripts relied on udev which affects boot
time.
Change-Id: I0fee1072ed34f13d5dffb846322ddd7cef5542fe
Reviewed-by: Samuli Piippo <samuli.piippo@theqtcompany.com>
| -rw-r--r-- | recipes/ostree/ostree.bb | 1 | ||||
| -rw-r--r-- | recipes/ostree/ostree/0004-Mount-boot-partition.patch | 82 |
2 files changed, 83 insertions, 0 deletions
diff --git a/recipes/ostree/ostree.bb b/recipes/ostree/ostree.bb index bc13ac2..016d8de 100644 --- a/recipes/ostree/ostree.bb +++ b/recipes/ostree/ostree.bb | |||
| @@ -32,6 +32,7 @@ SRC_URI = " \ | |||
| 32 | file://0001-Allow-updating-files-on-the-boot-partition.patch \ | 32 | file://0001-Allow-updating-files-on-the-boot-partition.patch \ |
| 33 | file://0002-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch \ | 33 | file://0002-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch \ |
| 34 | file://0003-Allow-updating-files-in-root-of-boot.patch \ | 34 | file://0003-Allow-updating-files-in-root-of-boot.patch \ |
| 35 | file://0004-Mount-boot-partition.patch \ | ||
| 35 | " | 36 | " |
| 36 | 37 | ||
| 37 | SRCREV = "efdb4d8f443768e59529c299290bee8b1f8f93c3" | 38 | SRCREV = "efdb4d8f443768e59529c299290bee8b1f8f93c3" |
diff --git a/recipes/ostree/ostree/0004-Mount-boot-partition.patch b/recipes/ostree/ostree/0004-Mount-boot-partition.patch new file mode 100644 index 0000000..092e142 --- /dev/null +++ b/recipes/ostree/ostree/0004-Mount-boot-partition.patch | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | From 5e9ed74a20026e5c9043eaf8a224ce84cb9cd9f0 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Gatis Paeglis <gatis.paeglis@theqtcompany.com> | ||
| 3 | Date: Mon, 7 Dec 2015 18:14:26 +0100 | ||
| 4 | Subject: [PATCH] Mount boot partition | ||
| 5 | |||
| 6 | On b2qt reference images the boot partition always is | ||
| 7 | the first partition on a device and rootfs is the second | ||
| 8 | partition. We can get the root parition from a kernel | ||
| 9 | command line and deduce the right boot partition from there. | ||
| 10 | --- | ||
| 11 | src/switchroot/ostree-prepare-root.c | 23 ++++++++++++++++++----- | ||
| 12 | 1 file changed, 18 insertions(+), 5 deletions(-) | ||
| 13 | |||
| 14 | diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c | ||
| 15 | index 3de137b..2637dc3 100644 | ||
| 16 | --- a/src/switchroot/ostree-prepare-root.c | ||
| 17 | +++ b/src/switchroot/ostree-prepare-root.c | ||
| 18 | @@ -45,7 +45,7 @@ | ||
| 19 | #include "ostree-mount-util.h" | ||
| 20 | |||
| 21 | static char * | ||
| 22 | -parse_ostree_cmdline (void) | ||
| 23 | +parse_kernel_cmdline (const char *arg) | ||
| 24 | { | ||
| 25 | FILE *f = fopen("/proc/cmdline", "r"); | ||
| 26 | char *cmdline = 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; | ||
| 50 | int i; | ||
| 51 | |||
| 52 | @@ -129,7 +131,7 @@ main(int argc, char *argv[]) | ||
| 53 | |||
| 54 | root_mountpoint = argv[1]; | ||
| 55 | |||
| 56 | - ostree_target = parse_ostree_cmdline (); | ||
| 57 | + ostree_target = parse_kernel_cmdline ("ostree="); | ||
| 58 | if (!ostree_target) | ||
| 59 | { | ||
| 60 | fprintf (stderr, "No OSTree target; expected ostree=/ostree/boot.N/...\n"); | ||
| 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 | + { | ||
| 74 | + perrorv ("failed to mount boot parition %s to %s", boot_partition, boot_mountpoint); | ||
| 75 | + exit (EXIT_FAILURE); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | exit (EXIT_SUCCESS); | ||
| 79 | } | ||
| 80 | -- | ||
| 81 | 2.1.4 | ||
| 82 | |||
