Re: [OE-core] [master-next][PATCHv3] wic: Add plugin for single partition disk
On Mon, Apr 27, 2015 at 03:00:23PM +0200, Adrian Freihofer wrote: The wic plugin creates a disk image containig one ext2/3/4 partition. No additional boot partition is required. Syslinux is installed into the image. The target device is a legacy BIOS PC. Purpose of this plugin: Other avaliable plugins create a fat partition for /boot and an ext partition for rootfs. Current linux-yocto kernel packages are not compatible with this disk layout. The boot partition is not mounted by default, hence the kernel is installed into rootfs and not into boot partition. A kernel update ends up in a bricked device. The old kernel which is still in boot likely does not even boot with updated kernel modules from /. Even if the boot partition is mounted during the kernel update the update will fail. The kernel package installs a symbolic link which is not supported by the fat partition. Creating just one ext partition for boot and rootfs solves all issues related to package based kernel updates on the device. The plugin depends on syslinux-nomtools a user space installer for syslinux on ext filesystems. Thanks to Robert Yang who implemented syslinux-nomtools and supported the implementation of this plugin. Signed-off-by: Adrian Freihofer adrian.freiho...@gmail.com --- .../lib/wic/plugins/source/rootfs_pcbios_ext.py| 182 + scripts/lib/wic/utils/syslinux.py | 58 +++ 2 files changed, 240 insertions(+) create mode 100644 scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py create mode 100644 scripts/lib/wic/utils/syslinux.py diff --git a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py new file mode 100644 index 000..ebf95ae --- /dev/null +++ b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py @@ -0,0 +1,182 @@ +# ex:ts=4:sw=4:sts=4:et +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- +# +# This program is free software; you can distribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for mo details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# AUTHOR +# Adrian Freihofer adrian.freihofer (at] neratec.com +# + +import os +from wic import kickstart +from wic import msger +from wic.utils import syslinux +from wic.utils import runner +from wic.utils.oe import misc +from wic.utils.errors import ImageError +from wic.pluginbase import SourcePlugin + + +# pylint: disable=no-init +class RootfsPlugin(SourcePlugin): + +Create root partition and install syslinux bootloader + +This plugin creates a disk image containing a bootable root partition with +syslinux installed. The filesystem is ext2/3/4, no extra boot partition is +required. + +Example kickstart file: +part / --source rootfs-pcbios-ext --ondisk sda --fstype=ext4 --label rootfs --align 1024 +bootloader --source rootfs-pcbios-ext --timeout=0 --append=rootwait rootfstype=ext4 + +The first line generates a root file system including a syslinux.cfg file +The --source rootfs-pcbios-ext in the second line triggers the installation +of ldlinux.sys into the image. + + +name = 'rootfs-pcbios-ext' + +@staticmethod +def _get_rootfs_dir(rootfs_dir): + +Find rootfs pseudo dir + +If rootfs_dir is a directory consider it as rootfs directory. +Otherwise ask bitbake about the IMAGE_ROOTFS directory. + +if os.path.isdir(rootfs_dir): +return rootfs_dir + +bitbake_env_lines = misc.find_bitbake_env_lines(rootfs_dir) +if not bitbake_env_lines: +msger.error(Couldn't get bitbake environment, exiting.) + +image_rootfs_dir = misc.find_artifact(bitbake_env_lines, IMAGE_ROOTFS) +if not os.path.isdir(image_rootfs_dir): +msg = No valid artifact IMAGE_ROOTFS from image named +msg += %s has been found at %s, exiting.\n % \ +(rootfs_dir, image_rootfs_dir) +msger.error(msg) + +return image_rootfs_dir + +# pylint: disable=unused-argument +@classmethod +def do_configure_partition(cls, part, source_params, image_creator, + image_creator_workdir, oe_builddir, bootimg_dir, + kernel_dir, native_sysroot): + +Creates syslinux config in rootfs directory + +
[OE-core] [master-next][PATCHv3] wic: Add plugin for single partition disk
The wic plugin creates a disk image containig one ext2/3/4 partition. No additional boot partition is required. Syslinux is installed into the image. The target device is a legacy BIOS PC. Purpose of this plugin: Other avaliable plugins create a fat partition for /boot and an ext partition for rootfs. Current linux-yocto kernel packages are not compatible with this disk layout. The boot partition is not mounted by default, hence the kernel is installed into rootfs and not into boot partition. A kernel update ends up in a bricked device. The old kernel which is still in boot likely does not even boot with updated kernel modules from /. Even if the boot partition is mounted during the kernel update the update will fail. The kernel package installs a symbolic link which is not supported by the fat partition. Creating just one ext partition for boot and rootfs solves all issues related to package based kernel updates on the device. The plugin depends on syslinux-nomtools a user space installer for syslinux on ext filesystems. Thanks to Robert Yang who implemented syslinux-nomtools and supported the implementation of this plugin. Signed-off-by: Adrian Freihofer adrian.freiho...@gmail.com --- .../lib/wic/plugins/source/rootfs_pcbios_ext.py| 182 + scripts/lib/wic/utils/syslinux.py | 58 +++ 2 files changed, 240 insertions(+) create mode 100644 scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py create mode 100644 scripts/lib/wic/utils/syslinux.py diff --git a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py new file mode 100644 index 000..ebf95ae --- /dev/null +++ b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py @@ -0,0 +1,182 @@ +# ex:ts=4:sw=4:sts=4:et +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- +# +# This program is free software; you can distribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for mo details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# AUTHOR +# Adrian Freihofer adrian.freihofer (at] neratec.com +# + +import os +from wic import kickstart +from wic import msger +from wic.utils import syslinux +from wic.utils import runner +from wic.utils.oe import misc +from wic.utils.errors import ImageError +from wic.pluginbase import SourcePlugin + + +# pylint: disable=no-init +class RootfsPlugin(SourcePlugin): + +Create root partition and install syslinux bootloader + +This plugin creates a disk image containing a bootable root partition with +syslinux installed. The filesystem is ext2/3/4, no extra boot partition is +required. + +Example kickstart file: +part / --source rootfs-pcbios-ext --ondisk sda --fstype=ext4 --label rootfs --align 1024 +bootloader --source rootfs-pcbios-ext --timeout=0 --append=rootwait rootfstype=ext4 + +The first line generates a root file system including a syslinux.cfg file +The --source rootfs-pcbios-ext in the second line triggers the installation +of ldlinux.sys into the image. + + +name = 'rootfs-pcbios-ext' + +@staticmethod +def _get_rootfs_dir(rootfs_dir): + +Find rootfs pseudo dir + +If rootfs_dir is a directory consider it as rootfs directory. +Otherwise ask bitbake about the IMAGE_ROOTFS directory. + +if os.path.isdir(rootfs_dir): +return rootfs_dir + +bitbake_env_lines = misc.find_bitbake_env_lines(rootfs_dir) +if not bitbake_env_lines: +msger.error(Couldn't get bitbake environment, exiting.) + +image_rootfs_dir = misc.find_artifact(bitbake_env_lines, IMAGE_ROOTFS) +if not os.path.isdir(image_rootfs_dir): +msg = No valid artifact IMAGE_ROOTFS from image named +msg += %s has been found at %s, exiting.\n % \ +(rootfs_dir, image_rootfs_dir) +msger.error(msg) + +return image_rootfs_dir + +# pylint: disable=unused-argument +@classmethod +def do_configure_partition(cls, part, source_params, image_creator, + image_creator_workdir, oe_builddir, bootimg_dir, + kernel_dir, native_sysroot): + +Creates syslinux config in rootfs directory + +Called before do_prepare_partition() + +rootdev = image_creator._get_boot_config()[0] +options = image_creator.ks.handler.bootloader.appendLine + +syslinux_conf = +