From 96e0463569cb5deaef8e40c7a54fcebbe663ccf5 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Mon, 31 Aug 2015 20:16:37 +0100 Subject: Add sphinx documentation --- doc/Makefile | 153 +++++++++++++++++++++++++++++++++++++++ doc/conf.py | 213 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/devel.rst | 110 ++++++++++++++++++++++++++++ doc/index.rst | 9 +++ doc/live.rst | 96 +++++++++++++++++++++++++ doc/overview.rst | 190 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 771 insertions(+) create mode 100644 doc/Makefile create mode 100644 doc/conf.py create mode 100644 doc/devel.rst create mode 100644 doc/index.rst create mode 100644 doc/live.rst create mode 100644 doc/overview.rst (limited to 'doc') diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..551fe06 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,153 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/vmdebootstrap.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/vmdebootstrap.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/vmdebootstrap" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/vmdebootstrap" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." diff --git a/doc/conf.py b/doc/conf.py new file mode 100644 index 0000000..9a1c0f2 --- /dev/null +++ b/doc/conf.py @@ -0,0 +1,213 @@ +# -*- coding: utf-8 -*- +# +# vmdebootstrap documentation build configuration file +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.append(os.path.abspath('..')) + +# -- General configuration ----------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'sphinx.ext.intersphinx', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.viewcode'] + +# Configuration for sphinx.ext.todo +todo_include_todos = True + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +# source_encoding = 'utf-8' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'vmdebootstrap' +copyright = u'2015 Neil Williams' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +import subprocess +# The short X.Y version. +version = subprocess.Popen(['python', 'setup.py', '-V'], cwd=r'..', stdout=subprocess.PIPE).stdout.read().rstrip() +# The full version, including alpha/beta/rc tags. +release = version + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of documents that shouldn't be included in the build. +# unused_docs = [] + +# List of directories, relative to source directory, that shouldn't be searched +# for source files. +exclude_trees = [] + +exclude_patterns = ['pages/reference-architecture', 'tables.rst'] + +# The reST default role (used for this markup: `text`) to use for all documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = "" + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = "favicon.ico" + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_use_modindex = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +html_show_sphinx = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = '' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'vmdebootstrapdocs' + + +# -- Options for LaTeX output -------------------------------------------------- + +# The paper size ('letter' or 'a4'). +# latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +# latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'vmdebootstrap.tex', u'vmdebootstrap', + u'Neil Williams', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# Additional stuff for the LaTeX preamble. +# latex_preamble = '' + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_use_modindex = True + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/doc/devel.rst b/doc/devel.rst new file mode 100644 index 0000000..d6acf1f --- /dev/null +++ b/doc/devel.rst @@ -0,0 +1,110 @@ +Developing live scripts and customisation hooks +=============================================== + +vmdebootstrap is available in git and in Debian. The live image +processing requires several options which are only available in +versions of vmdebootstrap newer than version 0.5-2 available in +Debian Jessie. vmdebootstrap is able to run on Stretch, Jessie or +Wheezy and able to build any suite supported by debootstrap (and +and architecture supported by QEMU) on any of those versions of +Debian. This leads to a large matrix of build options and hooks. + +Calls to vmdebootstrap are best scripted. See the README for notes +on which options and settings are required to make a live image using +vmdebootstrap. + +The 'common' library contains functions and parameters which need to +be used in *all* images, including: + +cleanup +export_env +mount_proc +disable_daemons +prepare_apt_source +remove_daemon_block +replace_apt_source + +cleanup +------- + +Ensure that proc is unmounted even if the customisation fails or else +the image build itself will fail to unmount ${rootdir}. + +export_env +---------- + +Debconf needs to be set in noninteractive mode to prevent the image +build waiting for keyboard intervention. + +mount_proc +---------- + +Many packages require /proc to be mounted inside the chroot during +installation - cleanup must be specified as a trap if mount_proc is +used: trap cleanup 0 + +disable_daemons +--------------- + +Packages which include a daemon *must not* start those daemons inside +the chroot as this will make the ${rootdir} appear busy and the unmount +will fail. All scripts need to use remove_daemon_block after package +installation is complete. + +prepare_apt_source +------------------ + +The final Debian mirror location is not useful during the build as there +is a faster mirror available during the build. This function moves the +specified mirror file aside and uses the nearby mirror. Always use with +replace_apt_source. + +replace_apt_source +------------------ + +Requires prepare_apt_source to have been run first, then undoes the +change to the apt sources and cleans up. + +TASK_PACKAGES +------------- + +Some task packages are useful to all images, these are specified here +and should be included in the set of packages to be installed using +all customisation scripts. + +EXTRA_PACKAGES +-------------- + +Packages which are not part of an existing task but which are useful for +all images and should be included in the set of packages to be installed +using all customisation scripts. + +Testing +------- + +Testing - unsquashfs creates a squashfs-root/ directory +containing the original image which QEMU can now use: +$ unsquashfs jessie.img.squash +$ qemu-system-x86_64 -machine accel=kvm:tcg -m 4096 -smp 2 -drive file=squashfs-root/jessie.img,format=raw + +This needs to be done on a local system which has a usable display, +not on pettersson itself. + +New architectures +----------------- + +The precursor to new architecture support is vmdebootstrap support. A +default vmdebootstrap (with no customisation hook) will need to work +and any changes to the settings (e.g. --no-kernel --package linux-myarch-flavour) +There is default support for some architectures in vmdebootstrap +(e.g. armhf architectures select the armmp kernel), such support depends +on how many users would use the same kernel compared to the number of +possible kernel flavours for that architecture. + +For a Debian LIVE image, *all* packages must exist in Debian. + +The package list also needs a review - some packages will simply not +exist for the specified architecture. Some architecture-specific packages +need to be added, so each architecture has a particular customisation +hook script. Package names frequently change between releases, so the +package selection needs to be suite specific as well. diff --git a/doc/index.rst b/doc/index.rst new file mode 100644 index 0000000..8b15fd9 --- /dev/null +++ b/doc/index.rst @@ -0,0 +1,9 @@ +VMDebootstrap +############# + +.. toctree:: + :maxdepth: 2 + + overview.rst + live.rst + devel.rst diff --git a/doc/live.rst b/doc/live.rst new file mode 100644 index 0000000..002072c --- /dev/null +++ b/doc/live.rst @@ -0,0 +1,96 @@ +Initial schemes for vmdebootstrap creation of live images +========================================================= + +#. vmdebootstrap has explicit support for foreign architecture + bootstraps using qemu static binformat handling as well as + support for Debian releases from wheezy onwards. + +#. vmdebootstrap can support adding specific packages but a + simpler approach is to use the existing task-* packages and + only add packages manually where explicitly needed for a live + image, e.g. ``wpa-supplicant`` + +#. Once a standard set of packages exist, create a metapackage + expressing this support - possibly as a part of the vmdebootstrap + packaging or as part of debian-cd. + +#. debian-cd runs vmdebootstrap inside a VM in a similar manner to + how debian-live currently operates, as both debian-live and + vmdebootstrap need to call debootstrap which involves making + device nodes and needs to run as root. This outer VM is specific + for the release of Debian being built. vmdebootstrap can build + older releases and it may be necessary to use a newer version of + vmdebootstrap than is present in jessie to build jessie and to + use that version to build wheezy. + +#. vmdebootstrap uses a single config file per image type and each + config file can have a single customisation script. The config + file specifies the architecture of the image and the binformat + handler for that architecture, so the customisation hook script + can be architecture-specific. + +#. Customisation hook scripts are shell scripts which will be passed + a single parameter - the directory which represents the root + directory of the final image. These scripts can use standard shell + support to include other common functions or call out to utilities + known to be installed in the outer VM running vmdebootstrap. + +#. Customisation hooks clearly need to live in a VCS - possibly within + the debian-cd git repo. + +#. Although vmdebootstrap does have architecture support, the deciding + factor is the availability of a working default kernel for the images + built for that architecture and how to configure the bootloader(s) to + provide the relevant dtb where needed. + +#. Testing vmdebootstrap images uses qemu along the lines of:: + + $ qemu-system-x86_64 -machine accel=kvm:tcg -m 4096 -smp 2 -drive file=test.img,format=raw + +#. Unlike standard vmdebootstrap example scripts, the scripts calling + vmdebootstrap itself do not need to use sudo as the call is made inside + the outer VM which already has root. Using sudo will work but will output + a message: sudo: unable to resolve host JESSIE-debian-live-builder + +#. The building of live images doesn't appear to need changes in the + vmdebootstrap package itself. The changes to isolinux to add the menu config, + splash screen and to provide access to the install menus can all be done + in the customisation hook. + +#. Remember to use ``http://cdbuilder.debian.org/debian/`` for the bootstrap + operations (--mirror option) and ``http://httpredir.debian.org/debian`` for + the mirror to be used after the image has booted (--apt-mirror option). + +#. Ensure that a user is created (``--user 'user/live'``) and that ``sudo`` is + added to the set of packages to install and the --sudo option is passed + to vmdebootstrap to ensure that the user is added to the sudo group. The + root user password should also be locked (--lock-root-password). + +#. Installing task packages using debootstrap **omits** ``Recommended`` packages, + resulting in a much smaller image which is not expected for a live image. + Task selection needs to be done in the customisation hook using the chroot + command, at which point the default apt configuration will install the + Recommends as well as the Depends packages. Ensure that the image size is + big enough. + +#. When installing using apt in the customisation script, ensure that the + debconf non-interactive settings are exported to prevent the install + waiting for keyboard interaction. ``DEBIAN_FRONTEND=noninteractive`` + +#. The customisation script needs to mount proc before starting the apt install. + +#. Calls to apt should also not output the progress bar but the actual package + installation steps should be logged. + +#. Move the image apt sources aside and set the cdimage apt source instead. + Use ``http://cdbuilder.debian.org/debian/`` Then, at the end of the + customisation hook, remove that source and replace the original. + +#. ``mksquashfs`` can fail without indication of why and when it does, the image + file can be 4Kb or so of junk. To prevent this, avoid running + vmdebootstrap with the ``--squash`` option and run mksquashfs as a second step + **after** copying the raw image to a new file for safety / debugging. + Newer versions of vmdebootstrap will emit a warning and not delete + the original file if the squashfs output is less than 1MB. This can + occur if the drive runs out of space but squashfs does not report + an error. diff --git a/doc/overview.rst b/doc/overview.rst new file mode 100644 index 0000000..09356c5 --- /dev/null +++ b/doc/overview.rst @@ -0,0 +1,190 @@ +VMDebootstrap +############# + +Purpose +******* +vmdebootstrap is a helper to install basic Debian system into virtual +disk image. It wraps **debootstrap**. You need to run :file:`vmdebootstrap` +as root. If the ``--verbose`` option is not used, no output will be +sent to the command line. If the ``--log`` option is not used, no +output will be sent to any log files either. + +To use the image, you probably want to create a virtual machine using +your preferred virtualization technology, such as file:`kvm` or +file:`qemu`. Configure the virtual machine to use the image you've +created. Then start the virtual machine and log into it via its console +to configure it. The image has an empty root password and will not have +networking configured by default. Set the root password before you +configure networking. + +Networking +********** + +The ``--enable-networking`` option uses the :file:`/etc/network/interfaces.d/` +source directory, with the default settings for ``lo`` and ``eth0`` +being added to :file:`/etc/network/interfaces.d/setup`. Other networking +configuration can be specified using a customisation script. +Localhost settings would be:: + + auto lo + iface lo inet loopback + +If ``--enable-dhcp`` is specified, these settings are also included +into :file:`/etc/network/interfaces.d/setup`:: + + auto eth0 + iface eth0 inet dhcp + +Bootloaders +*********** + +Unless the ``--no-extlinux`` or ``--grub`` options are specified, the +image will use ``extlinux`` as a boot loader. ``bootsize`` is not +recommended when using ``extlinux`` - use ``grub`` instead. + +Versions of grub2 in wheezy +=========================== + +Grub2 in wheezy can fail to install in the VM, at which point +:file:`vmdebootstrap` will fall back to ``extlinux``. It may still be +possible to complete the installation of ``grub2`` after booting the +VM as the problem may be related to the need to use loopback devices +during the ``grub-install`` operation. Details of the error will appear +in the vmdebootstrap log file, if enabled with the ``--log`` option. + +.. note:: **grub-legacy** is not supported. + +:file:`vmdebootstrap` also supports **EFI**. + +Use ``--use-uefi`` to use ``grub-efi`` instead of ``grub-pc``. If the +default 5Mb is not enough space, use the ``--esp-size`` option to +specify a different size for the EFI partition. Registered firmware is +not supported as it would need to be done after boot. If the system you +are creating is for more than just a VM or live image, you will likely +need a larger ESP, up to 500Mb. + +UBoot +===== + +UBoot needs manual configuration via the customisation hook scripts, +typically support requires adding ``u-boot`` using ``--package`` and then +copying or manipulating the relevant ``u-boot`` files in the customisation +script. Examples are included for beaglebone-black. + +Installation images and virtual machines +**************************************** + +:file:`vmdebootstrap`` is aimed principally at creating virtual machines, +not installers or prebuilt installation images. It is possible to create +prebuilt installation images for some devices but this depends on the +specific device. (A 'prebuilt installation image' is a single image file +which can be written to physical media in a single operation and which +allows the device to boot directly into a fully installed system - in +a similar way to how a virtual machine would behave.) + +:file:`vmdebootstrap` assumes that all operations take place on a local +image file, not a physical block device / removable media. + +:file:`vmdebootstrap` is intended to be used with tools like ``qemu`` on +the command line to launch a new virtual machine. Not all devices have +virtualisation support in hardware. + +This has implications for file:`u-boot` support in some cases. If the +device can support reading the bootloader from a known partition, like +the beaglebone-black, then :file:`vmdebootstrap` can provide space for +the bootloader and the image will work as a prebuilt installation image. +If the device expects that the bootloader exists at a specific offset +and therefore requires that the bootloader is written as an image not +as a binary which can be copied into an existing partition, +:file:vmdebootstrap` is unable to include that bootloader image into +the virtual machine image. + +The beagleboneblack.sh script in the examples/ directory provides a worked +example to create a prebuilt installation image. However, the beagleboneblack +itself does not support virtualisation in hardware, so is unable to launch +a virtual machine. Other devices, like the Cubietruck or Wandboard need +:file:`u-boot` at a predefined offset but can launch a virtual machine +using ``qemu``, so the cubietruck and wandboard6q scripts in the +examples/ directory relate to building images for virtual machines once +the device is already installed and booted into a suitable kernel. + +It is possible to wrap :file:`vmdebootstrap` in such a way as to prepare +a physical block device with a bootloader image and then deploy the +bootstrap on top. However, this does require physical media to be +inserted and removed each time the wrapper is executed. To do this, use +the ``--tarball`` option instead of the ``--image`` option. Then setup +the physical media and bootloader image manually, as required for the +device, redefine the partitions to make space for the rootfs, create a +filesystem on the physical media and unpack the :file:`vmdebootstrap` +tarball onto that filesystem. Once you have working media, an image can be +created using dd to read back from the media to an image file, allowing +other media to be written with a single image file. + +Example +******* + +To create an image for the stable release of Debian:: + + sudo vmdebootstrap --image test.img --size 1g \\ + --log test.log --log-level debug --verbose \\ + --mirror http://mirror.lan/debian/ + +To run the test image, make sure it is writeable. Use the ``--owner`` +option to set mode 0644 for the specified user or use chmod manually:: + + sudo chmod a+w ./test.img + +Execute using qemu, e.g. on amd64 using qemu-system-x86_64:: + + qemu-system-x86_64 -drive format=raw,file=./test.img + +(This loads the image in a new window.) Note the use of ``-drive +file=,format=raw`` which is needed for newer versions of QEMU. + +There is EFI firmware available to use with QEMU when testing images built +using the UEFI support, but this software is in Debian non-free due to patent +concerns. If you choose to install ``ovmf`` to test UEFI builds, a +secondary change is also needed to symlink the provided ``OVMF.fd`` to +the file required by QEMU: ``bios-256k.bin`` and then tell QEMU about +the location of this file with the -L option:: + + $ qemu-system-x86_64 -L /usr/share/ovmf/ -machine accel=kvm \\ + -m 4096 -smp 2 -drive format=raw,file=test.img + +For further examples, including u-boot support for beaglebone-black, +see ``/usr/share/vmdebootstrap/examples`` + +Notes +***** + +If you get problems with the bootstrap process, run a similar bootstrap +call directly and chroot into the directory to investigate the failure. +The actual debootstrap call is part of the vmdebootstrap logfile. The +debootstrap logfile, if any, will be copied into your current working +directory on error. + +:file:`debootstrap` will download all the apt archive files into the apt cache and does not +remove them before starting the configuration of the packages. This can +mean that debootstrap can fail due to a lack of space on the device if +the VM size is small. vmdebootstrap cleans up the apt cache once debootstrap +has finished but this doesn't help if the package unpack or configuration +steps use up all of the space in the meantime. Avoid this problem by +specifying a larger size for the image. + +.. note:: if you are also using a separate /boot partition in your options to + :file:`vmdebootstrap` it may well be the boot partition which needs + to be enlarged rather than the entire image. + +It is advisable to change the mirror in the example scripts to a mirror +closer to your location, particularly if you need to do repeated builds. +Use the --apt-mirror option to specify the apt mirror to be used inside +the image, after boot. + +There are two types of examples for ARM devices available with +:file:`vmdebootstrap`: prebuilt installation images (like the beaglebone-black) and virtual +machine images (cubietruck and wandboard). ARM devices which do not +support hypervisor mode and which also rely on the bootloader being at +a specific offset instead of using a normal partition will +**not** be supportable by vmdebootstrap. Similarly, devices which support +hypervisor will only be supported using virtual machine images, unless +the bootloader can be executed from a normal partition. -- cgit v1.2.1