Merge "Add block-device defaults"

This commit is contained in:
Zuul 2018-03-16 08:31:10 +00:00 committed by Gerrit Code Review
commit 96af247400
15 changed files with 146 additions and 46 deletions

View File

@ -0,0 +1,11 @@
================
Block Device EFI
================
This provides a block-device configuration for the ``vm`` element to
get a single-partition disk suitable for EFI booting.
Note on x86 this provides the extra `BIOS boot partition
<https://en.wikipedia.org/wiki/BIOS_boot_partition>`__ and a EFI boot
partition for maximum compatability.

View File

@ -0,0 +1,30 @@
- local_loop:
name: image0
- partitioning:
base: image0
label: gpt
partitions:
- name: ESP
type: 'EF00'
size: 8MiB
mkfs:
type: vfat
mount:
mount_point: /boot/efi
fstab:
options: "defaults"
fsck-passno: 1
- name: BSP
type: 'EF02'
size: 8MiB
- name: root
type: '8300'
size: 100%
mkfs:
type: ext4
mount:
mount_point: /
fstab:
options: "defaults"
fsck-passno: 1

View File

@ -0,0 +1 @@
block-device

View File

@ -2,10 +2,10 @@
Block Device GPT
================
This is an override for the default block-device configuration
provided in the ``vm`` element to get a GPT based single-partition
disk, rather than the default MBR.
This provides a block-device configuration for the ``vm`` element to
get a GPT based single-partition disk.
Note this provides the extra `BIOS boot partition
Note on x86 this provides the extra `BIOS boot partition
<https://en.wikipedia.org/wiki/BIOS_boot_partition>`__ as required for
non-EFI boot environments.

View File

@ -0,0 +1,32 @@
# Default GPT block device setup for PPC
# --------------------------------------
#
# Details (extracted from [1])
#
# Power Firmware (OFW) scans chosen (nvram value boot-device) device,
# for either PReP* partition or vfat.
#
# PReP is raw and small (8M max) partition which caries only stage1
# binary.
#
# [1] https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/W51a7ffcf4dfd_4b40_9d82_446ebc23c550/page/PowerLinux%20Boot%20howto
- local_loop:
name: image0
- partitioning:
base: image0
label: gpt
partitions:
- name: boot
type: '0x4100'
size: 8MiB
- name: root
size: 100%
mkfs:
type: ext4
mount:
mount_point: /
fstab:
options: "defaults"
fsck-passno: 1

View File

@ -0,0 +1 @@
block-device

View File

@ -0,0 +1,7 @@
================
Block Device MBR
================
This provides the default legacy block-device configuration for the
"vm" element. This configures a single partition and is suitable for
a MBR based bootloader.

View File

@ -0,0 +1 @@
block-device

View File

@ -1,2 +1,3 @@
block-device-mbr
openstack-ci-mirrors
vm

View File

@ -1,2 +1,4 @@
block-device-mbr
openstack-ci-mirrors
vm

View File

@ -1 +1,2 @@
block-device
bootloader

View File

@ -239,9 +239,52 @@ function run_d() {
check_break after-$1 bash
}
function _arg_defaults_hack() {
# The block-device configuration looks in all elements for a
# "block-device-default.yaml" file. The "vm" element used to
# provide the default block-device, which was fine when there was
# only one option; but now we have mbr, gpt & efi versions.
#
# So now the vm element has a dependency on the block-device
# element, which several different elements can provide. However,
# for backwards compatability we need to ensure you can still
# build without specifying it. Thus if we see the vm element, but
# no block-device-* element, we will automatically add the old
# default MBR.
#
# Note that you can still override this by setting
# DIB_BLOCK_DEVICE_CONFIG; any value there will be taken over the
# element defaults. In this case you'd have "block-device-mbr" as
# an element, but it wouldn't actually be used for configuration.
#
# XXX: if this is becoming a common problem, we could have some
# sort of "element-defaults" that maps a "element-deps" entry to a
# default.
local vm_seen
local blockdev_seen
local elements
for arg do
if [[ "$arg" =~ "vm" ]]; then
vm_seen=1
elif [[ "$arg" =~ "block-device-" ]]; then
blockdev_seen=1
fi
elements="$elements $arg"
done
if [[ -n "${vm_seen}" && -z "${blockdev_seen}" ]]; then
elements="$elements block-device-mbr"
fi
echo $elements
}
function arg_to_elements() {
for arg do IMAGE_ELEMENT="$IMAGE_ELEMENT $arg" ; done
IMAGE_ELEMENT="$(_arg_defaults_hack $IMAGE_ELEMENT)"
if [ "$SKIP_BASE" != "1" ]; then
IMAGE_ELEMENT="base $IMAGE_ELEMENT"
fi

View File

@ -67,54 +67,24 @@ on.
There are currently two defaults:
* When using the `vm` element a MBR based partition layout is created
with exactly one partition that fills up the whole disk and used as
root device.
* When not using the `vm` element a plain filesystem image, without
* When using the ``vm`` element, an element that provides
``block-device`` should be included. Available ``block-device-*``
elements cover the common case of a single partition that fills up
the whole disk and used as root device. Currently there are MBR,
GPT and EFI versions. For example, to use a GPT disk you could
build with ::
disk-image-create -o output.qcow vm block-device-gpt ubuntu-minimal
* When not using the ``vm`` element a plain filesystem image, without
any partitioning, is created.
The user can overwrite the default handling by setting the environment
If you wish to customise the top-level ``block-device-default.yaml``
file from one of the ``block-device-*`` elements, set the environment
variable `DIB_BLOCK_DEVICE_CONFIG`. This variable must hold YAML
structured configuration data or be a ``file://`` URL reference to a
on-disk configuration file.
The default when using the `vm` element is:
.. code-block:: yaml
DIB_BLOCK_DEVICE_CONFIG='
- local_loop:
name: image0
- partitioning:
base: image0
label: mbr
partitions:
- name: root
flags: [ boot, primary ]
size: 100%
mkfs:
mount:
mount_point: /
fstab:
options: "defaults"
fsck-passno: 1'
The default when not using the `vm` element is:
.. code-block:: yaml
DIB_BLOCK_DEVICE_CONFIG='
- local_loop:
name: image0
mkfs:
name: mkfs_root
mount:
mount_point: /
fstab:
options: "defaults"
fsck-passno: 1'
There are a lot of different options for the different levels. The
following sections describe each level in detail.