| 1 |
.. _network_overlay_boot: |
| 2 |
|
| 3 |
Booting a Root Filesystem from Network |
| 4 |
====================================== |
| 5 |
|
| 6 |
.. sidebar:: Abstract |
| 7 |
|
| 8 |
This page provides further information for handling |
| 9 |
KIS images built with {kiwi} and references the following |
| 10 |
article: |
| 11 |
|
| 12 |
* :ref:`kis` |
| 13 |
|
| 14 |
In {kiwi}, the `kiwi-overlay` dracut module can be used to boot |
| 15 |
from a remote exported root filesystem. The exported device |
| 16 |
is visible as a block device on the network client. {kiwi} |
| 17 |
supports the two export backends, `NBD` (Network Block Device) |
| 18 |
and `AoE` (ATA over Ethernet), for this purpose. A system that is |
| 19 |
booted in this mode will read the contents of the root filesystem |
| 20 |
from a remote location and target any write action into RAM by |
| 21 |
default. The kernel cmdline option `rd.root.overlay.write` can |
| 22 |
be used to specify an alternative device to use for writing. |
| 23 |
The two layers (read and write) are combined using the `overlayfs` |
| 24 |
filesystem. |
| 25 |
|
| 26 |
For remote boot of a network client, the PXE boot protocol |
| 27 |
is used. This functionality requires a network boot server |
| 28 |
setup on the system. Details on how to set up such a server |
| 29 |
can be found in :ref:`network-boot-server`. |
| 30 |
|
| 31 |
Before the KIS image can be built, the following configuration step |
| 32 |
is required: |
| 33 |
|
| 34 |
* Create dracut configuration to include the `kiwi-overlay` module |
| 35 |
|
| 36 |
.. code:: bash |
| 37 |
|
| 38 |
$ cd kiwi/build-tests/{exc_description_kis} |
| 39 |
$ mkdir -p root/etc/dracut.conf.d |
| 40 |
$ cd root/etc/dracut.conf.d |
| 41 |
$ echo 'add_dracutmodules+=" kiwi-overlay "' > overlay.conf |
| 42 |
|
| 43 |
Now, the KIS image can be built as shown in :ref:`kis`. After the |
| 44 |
build, the following configuration steps are required to boot |
| 45 |
from the network: |
| 46 |
|
| 47 |
1. Copy the initrd/kernel from the KIS build to the PXE server |
| 48 |
|
| 49 |
The PXE boot process loads the configured kernel and initrd from |
| 50 |
the PXE server. For this reason, the following files must be |
| 51 |
copied to the PXE server as follows: |
| 52 |
|
| 53 |
.. code:: bash |
| 54 |
|
| 55 |
$ cp *.initrd /srv/tftpboot/boot/initrd |
| 56 |
$ cp *.kernel /srv/tftpboot/boot/linux |
| 57 |
|
| 58 |
2. Export Root FileSystem to the Network |
| 59 |
|
| 60 |
Access to the root filesystem is implemented using either the |
| 61 |
AoE or the NBD protocol. This requires the export of the |
| 62 |
root filesystem image as a remote block device: |
| 63 |
|
| 64 |
Export via AoE: |
| 65 |
Install the `vblade` package on the system that is expected |
| 66 |
to export the root filesystem. |
| 67 |
|
| 68 |
.. note:: |
| 69 |
|
| 70 |
Not all versions of AoE are compatible with any kernel. This |
| 71 |
means the kernel on the system exporting the root filesystem image |
| 72 |
must provide a compatible aoe kernel module compared to the |
| 73 |
kernel used inside of the root filesystem image. |
| 74 |
|
| 75 |
Once done, export the filesystem from the KIS build above as follows: |
| 76 |
|
| 77 |
.. code:: bash |
| 78 |
|
| 79 |
$ vbladed 0 1 IFACE {exc_image_base_name_kis}.x86_64-{exc_image_version_kis} |
| 80 |
|
| 81 |
The above command exports the given filesystem image file as a block |
| 82 |
storage device to the network of the given `IFACE`. On any machine except |
| 83 |
the one exporting the file, it will appear as :file:`/dev/etherd/e0.1` |
| 84 |
once the `aoe` kernel module has been loaded. The two numbers, |
| 85 |
0 and 1 in the above example, classify a major and minor number |
| 86 |
that is used in the device node name on the reading side, in this |
| 87 |
case, :file:`e0.1`. |
| 88 |
|
| 89 |
.. note:: |
| 90 |
|
| 91 |
Only machines in the same network of the given `IFACE` |
| 92 |
can see the exported block device. |
| 93 |
|
| 94 |
Export via NBD: |
| 95 |
Install the `nbd` package on the system that is expected |
| 96 |
to export the root filesystem. |
| 97 |
|
| 98 |
Once done, export the filesystem from the KIS build above as follows: |
| 99 |
|
| 100 |
.. code:: bash |
| 101 |
|
| 102 |
$ losetup /dev/loop0 {exc_image_base_name_kis}.x86_64-{exc_image_version_kis} |
| 103 |
|
| 104 |
$ vi /etc/nbd-server/config |
| 105 |
|
| 106 |
[generic] |
| 107 |
user = root |
| 108 |
group = root |
| 109 |
[export] |
| 110 |
exportname = /dev/loop0 |
| 111 |
|
| 112 |
$ nbd-server |
| 113 |
|
| 114 |
3. Setup boot entry in the PXE configuration |
| 115 |
|
| 116 |
.. note:: |
| 117 |
|
| 118 |
The following step assumes that the `pxelinux.0` loader |
| 119 |
has been configured on the boot server to boot up network |
| 120 |
clients. |
| 121 |
|
| 122 |
Edit the file :file:`/srv/tftpboot/pxelinux.cfg/default` and create |
| 123 |
a boot entry of the form: |
| 124 |
|
| 125 |
Using NBD: |
| 126 |
.. code:: bash |
| 127 |
|
| 128 |
LABEL Overlay-Boot |
| 129 |
kernel boot/linux |
| 130 |
append initrd=boot/initrd root=overlay:nbd=server-ip:export |
| 131 |
|
| 132 |
The boot parameter `root=overlay:nbd=server-ip:export` specifies |
| 133 |
the NBD server's IP address and the name of the export as used in |
| 134 |
:file:`/etc/nbd-server/config`. |
| 135 |
|
| 136 |
Using AoE: |
| 137 |
.. code:: bash |
| 138 |
|
| 139 |
LABEL Overlay-Boot |
| 140 |
kernel boot/linux |
| 141 |
append initrd=boot/initrd root=overlay:aoe=AOEDEVICE |
| 142 |
|
| 143 |
The boot parameter `root=overlay:aoe=AOEDEVICE` specifies the |
| 144 |
AoE device name below :file:`/dev/etherd` as it was exported by the |
| 145 |
`vbladed` command, for example, `e0.1`. |
| 146 |
|
| 147 |
4. Boot from the Network |
| 148 |
|
| 149 |
Within the network that has access to the PXE server and the |
| 150 |
exported root filesystem image, any network client can now boot the |
| 151 |
system. A test based on QEMU can be done as follows: |
| 152 |
|
| 153 |
.. code:: bash |
| 154 |
|
| 155 |
$ sudo qemu -boot n |