Support for booting without initramfs
Previously when initramfs-* was not found in a deployment's boot directory, it was assumed that rootfs is prepared for ostree booting by a kernel patch. With this patch, the behaviour changes to be - if initramfs-* is not found, assume that system is using a static ostree-prepare-root as init process. Booting without initramfs is a common use case on embedded systems. This approach is also more convenient, than having to patch the kernel. Closes: #1401 Approved by: cgwalters
This commit is contained in:
parent
652d9dd98a
commit
4233b1db19
|
|
@ -116,6 +116,7 @@ _installed_or_uninstalled_test_scripts = \
|
||||||
tests/test-pull-mirrorlist.sh \
|
tests/test-pull-mirrorlist.sh \
|
||||||
tests/test-summary-update.sh \
|
tests/test-summary-update.sh \
|
||||||
tests/test-summary-view.sh \
|
tests/test-summary-view.sh \
|
||||||
|
tests/test-no-initramfs.sh \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
experimental_test_scripts = \
|
experimental_test_scripts = \
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ entries_path=$(dirname $new_grub2_cfg)/entries
|
||||||
|
|
||||||
read_config()
|
read_config()
|
||||||
{
|
{
|
||||||
config_file=${entries_path}/${1}
|
config_file=${1}
|
||||||
title=""
|
title=""
|
||||||
initrd=""
|
initrd=""
|
||||||
options=""
|
options=""
|
||||||
|
|
@ -67,11 +67,13 @@ populate_menu()
|
||||||
else
|
else
|
||||||
boot_prefix="${OSTREE_BOOT_PARTITION}"
|
boot_prefix="${OSTREE_BOOT_PARTITION}"
|
||||||
fi
|
fi
|
||||||
for config in $(ls ${entries_path}); do
|
for config in $(ls $entries_path/*.conf); do
|
||||||
read_config ${config}
|
read_config ${config}
|
||||||
menu="${menu}menuentry '${title}' {\n"
|
menu="${menu}menuentry '${title}' {\n"
|
||||||
menu="${menu}\t linux ${boot_prefix}${linux} ${options}\n"
|
menu="${menu}\t linux ${boot_prefix}${linux} ${options}\n"
|
||||||
|
if [ -n "${initrd}" ] ; then
|
||||||
menu="${menu}\t initrd ${boot_prefix}${initrd}\n"
|
menu="${menu}\t initrd ${boot_prefix}${initrd}\n"
|
||||||
|
fi
|
||||||
menu="${menu}}\n\n"
|
menu="${menu}}\n\n"
|
||||||
done
|
done
|
||||||
# The printf command seems to be more reliable across shells for special character (\n, \t) evaluation
|
# The printf command seems to be more reliable across shells for special character (\n, \t) evaluation
|
||||||
|
|
|
||||||
|
|
@ -1700,21 +1700,29 @@ install_deployment_kernel (OstreeSysroot *sysroot,
|
||||||
g_autofree char * boot_relpath = g_strconcat ("/", bootcsumdir, "/", kernel_layout->kernel_namever, NULL);
|
g_autofree char * boot_relpath = g_strconcat ("/", bootcsumdir, "/", kernel_layout->kernel_namever, NULL);
|
||||||
ostree_bootconfig_parser_set (bootconfig, "linux", boot_relpath);
|
ostree_bootconfig_parser_set (bootconfig, "linux", boot_relpath);
|
||||||
|
|
||||||
|
val = ostree_bootconfig_parser_get (bootconfig, "options");
|
||||||
|
g_autoptr(OstreeKernelArgs) kargs = _ostree_kernel_args_from_string (val);
|
||||||
|
|
||||||
if (kernel_layout->initramfs_namever)
|
if (kernel_layout->initramfs_namever)
|
||||||
{
|
{
|
||||||
g_autofree char * boot_relpath = g_strconcat ("/", bootcsumdir, "/", kernel_layout->initramfs_namever, NULL);
|
g_autofree char * boot_relpath = g_strconcat ("/", bootcsumdir, "/", kernel_layout->initramfs_namever, NULL);
|
||||||
ostree_bootconfig_parser_set (bootconfig, "initrd", boot_relpath);
|
ostree_bootconfig_parser_set (bootconfig, "initrd", boot_relpath);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
val = ostree_bootconfig_parser_get (bootconfig, "options");
|
{
|
||||||
|
g_autofree char *prepare_root_arg = NULL;
|
||||||
|
prepare_root_arg = g_strdup_printf ("init=/ostree/boot.%d/%s/%s/%d/usr/lib/ostree/ostree-prepare-root",
|
||||||
|
new_bootversion, osname, bootcsum,
|
||||||
|
ostree_deployment_get_bootserial (deployment));
|
||||||
|
_ostree_kernel_args_replace_take (kargs, g_steal_pointer (&prepare_root_arg));
|
||||||
|
}
|
||||||
|
|
||||||
/* Note this is parsed in ostree-impl-system-generator.c */
|
/* Note this is parsed in ostree-impl-system-generator.c */
|
||||||
g_autofree char *ostree_kernel_arg = g_strdup_printf ("ostree=/ostree/boot.%d/%s/%s/%d",
|
g_autofree char *ostree_kernel_arg = g_strdup_printf ("ostree=/ostree/boot.%d/%s/%s/%d",
|
||||||
new_bootversion, osname, bootcsum,
|
new_bootversion, osname, bootcsum,
|
||||||
ostree_deployment_get_bootserial (deployment));
|
ostree_deployment_get_bootserial (deployment));
|
||||||
g_autoptr(OstreeKernelArgs) kargs = _ostree_kernel_args_from_string (val);
|
_ostree_kernel_args_replace_take (kargs, g_steal_pointer (&ostree_kernel_arg));
|
||||||
_ostree_kernel_args_replace_take (kargs, ostree_kernel_arg);
|
|
||||||
ostree_kernel_arg = NULL;
|
|
||||||
g_autofree char *options_key = _ostree_kernel_args_to_string (kargs);
|
g_autofree char *options_key = _ostree_kernel_args_to_string (kargs);
|
||||||
ostree_bootconfig_parser_set (bootconfig, "options", options_key);
|
ostree_bootconfig_parser_set (bootconfig, "options", options_key);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. $(dirname $0)/libtest.sh
|
||||||
|
|
||||||
|
echo "1..3"
|
||||||
|
|
||||||
|
setup_os_repository "archive-z2" "uboot"
|
||||||
|
|
||||||
|
cd ${test_tmpdir}
|
||||||
|
|
||||||
|
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos $(cat httpd-address)/ostree/testos-repo
|
||||||
|
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull testos testos/buildmaster/x86_64-runtime
|
||||||
|
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=rootfs --os=testos testos:testos/buildmaster/x86_64-runtime
|
||||||
|
|
||||||
|
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'root=LABEL=rootfs'
|
||||||
|
assert_not_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'init='
|
||||||
|
|
||||||
|
echo "ok deployment with initramfs"
|
||||||
|
|
||||||
|
cd ${test_tmpdir}/osdata/boot
|
||||||
|
rm -f initramfs* vmlinuz*
|
||||||
|
echo "the kernel only" > vmlinuz-3.6.0
|
||||||
|
bootcsum=$(cat vmlinuz-3.6.0 | sha256sum | cut -f 1 -d ' ')
|
||||||
|
mv vmlinuz-3.6.0 vmlinuz-3.6.0-${bootcsum}
|
||||||
|
cd -
|
||||||
|
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --tree=dir=osdata/ -b testos/buildmaster/x86_64-runtime
|
||||||
|
${CMD_PREFIX} ostree pull testos:testos/buildmaster/x86_64-runtime
|
||||||
|
${CMD_PREFIX} ostree admin deploy --os=testos --karg=root=/dev/sda2 --karg=rootwait testos:testos/buildmaster/x86_64-runtime
|
||||||
|
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'rootwait'
|
||||||
|
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'init='
|
||||||
|
assert_not_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'initrd'
|
||||||
|
|
||||||
|
echo "ok switching to bootdir with no initramfs"
|
||||||
|
|
||||||
|
cd ${test_tmpdir}/osdata/boot
|
||||||
|
rm -f initramfs* vmlinuz*
|
||||||
|
echo "the kernel" > vmlinuz-3.6.0
|
||||||
|
echo "initramfs to assist the kernel" > initramfs-3.6.0
|
||||||
|
bootcsum=$(cat vmlinuz-3.6.0 initramfs-3.6.0 | sha256sum | cut -f 1 -d ' ')
|
||||||
|
mv vmlinuz-3.6.0 vmlinuz-3.6.0-${bootcsum}
|
||||||
|
mv initramfs-3.6.0 initramfs-3.6.0-${bootcsum}
|
||||||
|
cd -
|
||||||
|
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --tree=dir=osdata/ -b testos/buildmaster/x86_64-runtime
|
||||||
|
${CMD_PREFIX} ostree pull testos:testos/buildmaster/x86_64-runtime
|
||||||
|
${CMD_PREFIX} ostree admin deploy --os=testos --karg-none --karg=root=LABEL=rootfs testos:testos/buildmaster/x86_64-runtime
|
||||||
|
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'initrd'
|
||||||
|
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'root=LABEL=rootfs'
|
||||||
|
assert_not_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'rootwait'
|
||||||
|
assert_not_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'init='
|
||||||
|
|
||||||
|
echo "ok switching from no initramfs to initramfs enabled sysroot"
|
||||||
|
|
||||||
Loading…
Reference in New Issue