Debian Codegraph @

doc/source/working_with_images/disk_ramdisk_deployment.rst

raw
1 .. _ramdisk_deployment:
2
3 Deploy and Run a System in a Ramdisk
4 ====================================
5
6 .. sidebar:: Abstract
7
8 This page provides further information for handling
9 oem images built with {kiwi} and references the following
10 articles:
11
12 * :ref:`expandable_disk`
13
14 If a machine should run the OS completely in memory without
15 the need for any persistent storage, the approach to deploy
16 the image into a ramdisk serves this purpose.
17
18 .. note:: brd support
19
20 For this functionality to work, brd (Block Ramdisk Driver) must be
21 supported. If brd is available as a kernel module (as opposed to
22 being compiled in the kernel), you must include the driver into the
23 initrd. To do this, create (or edit) the `config.sh` file and add
24 the following command to it:
25
26 .. code:: bash
27
28 echo 'add_drivers+=" brd "' > /etc/dracut.conf.d/10-brd.conf
29
30 {kiwi} allows you to create a bootable ISO image that deploys the image
31 into a ramdisk and activates that image with the following
32 oem type definition:
33
34 .. code:: xml
35
36 <type image="oem" filesystem="ext4" installiso="true" initrd_system="dracut" installboot="install" kernelcmdline="rd.kiwi.ramdisk">
37 <bootloader name="grub2" timeout="1"/>
38 <oemconfig>
39 <oem-skip-verify>true</oem-skip-verify>
40 <oem-unattended>true</oem-unattended>
41 <oem-unattended-id>/dev/ram1</oem-unattended-id>
42 <oem-swap>false</oem-swap>
43 <oem-multipath-scan>false</oem-multipath-scan>
44 <oem-ramdisk-size>2048000</oem-ramdisk-size>
45 </oemconfig>
46 </type>
47
48 The type specification above builds an installation ISO image
49 that deploys the System Image into the specified ramdisk
50 device (`/dev/ram1`). The setup of the ISO image boots with a
51 short boot timeout of 1 second and just runs through the process
52 without asking any questions. In a ramdisk deployment, the
53 optional target verification, swap space, and multipath targets
54 are out of scope and therefore disabled.
55
56 The configured size of the ramdisk via `oem-ramdisk-size` specifies
57 the kB size of the OS disk, and it must be at least of the size of the
58 System Image. The disk size can be configured dynamically with the
59 following value in the kernelcmdline attribute:
60
61 * ramdisk_size=kbyte-value
62
63 An image built with the above setup can be tested in QEMU as
64 follows:
65
66 .. code:: bash
67
68 $ sudo qemu -cdrom \
69 {exc_image_base_name}.x86_64-{exc_image_version}.install.iso \
70 -serial stdio
71
72 .. note:: Enough Main Memory
73
74 The machine, no matter if it's a virtual machine like QEMU
75 or a real machine, must provide enough RAM to hold the image
76 in the ramdisk as well as have enough RAM available to operate
77 the OS and its applications. The {kiwi} build image with the
78 extension .raw provides the System Image that gets deployed
79 into the RAM space. Subtract the size of the System Image
80 from the RAM space the machine offers and make sure the result
81 is still big enough for the use case of the appliance. In
82 the case of a virtual machine, attach enough main memory to fit
83 this calculation. In the case of QEMU, this can be done with
84 the `-m` option.
85
86 Like all other oem {kiwi} images, the ramdisk setup also supports
87 all the deployment methods as explained in :ref:`deployment_methods`.
88 This means it's also possible to dump the ISO image on a USB
89 stick, let the system boot from it, and unplug the stick from
90 the machine because the system was deployed into RAM.
91
92 .. note:: Limitations Of Ramdisk Deployments
93
94 Only standard images that can be booted by a simple root mount
95 and root switch can be used. Usually, {kiwi} calls kexec after deployment
96 such that the correct dracut initrd created for the image will boot
97 the image. In the case of a RAM-only system, kexec does not work because
98 it would lose the ramdisk contents. Thus, the dracut initrd driving
99 the deployment is also the environment to boot the system.
100 There are cases where this environment is not suitable to boot
101 the system.