Skip to content

Commit 10c15bb

Browse files
authored
Merge pull request #2771 from OSInside/allow_ramdisk_size_as_oem_option
Added <oem-ramdisk-size> element
2 parents 2e417b8 + c010b50 commit 10c15bb

File tree

8 files changed

+118
-23
lines changed

8 files changed

+118
-23
lines changed

build-tests/x86/tumbleweed/test-image-agama/appliance.kiwi

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
<contact>[email protected]</contact>
77
<specification>Agama RamDisk Installer ISO</specification>
88
</description>
9+
<profiles>
10+
<profile name="PXE" description="Small Agama instance for remote installation"/>
11+
<profile name="ISO" description="Standard Agama instance for local installation"/>
12+
</profiles>
913
<preferences>
1014
<version>1.0.1</version>
1115
<packagemanager>zypper</packagemanager>
@@ -16,14 +20,31 @@
1620
<rpm-check-signatures>false</rpm-check-signatures>
1721
<bootsplash-theme>bgrt</bootsplash-theme>
1822
<bootloader-theme>openSUSE</bootloader-theme>
19-
<type image="oem" filesystem="btrfs" fsmountoptions="compress=zstd:15" firmware="uefi" installiso="true" installpxe="true" installboot="install" kernelcmdline="rd.kiwi.ramdisk ramdisk_size=3145728 rd.kiwi.install.pass.bootparam" volid="agama">
23+
</preferences>
24+
<preferences profiles="PXE">
25+
<type image="oem" filesystem="btrfs" fsmountoptions="compress=zstd:15" firmware="uefi" installpxe="true" kernelcmdline="rd.kiwi.ramdisk rd.kiwi.install.pass.bootparam">
26+
<bootloader name="custom"/>
27+
<oemconfig>
28+
<oem-skip-verify>true</oem-skip-verify>
29+
<oem-unattended>true</oem-unattended>
30+
<oem-unattended-id>/dev/ram1</oem-unattended-id>
31+
<oem-swap>false</oem-swap>
32+
<oem-multipath-scan>false</oem-multipath-scan>
33+
<oem-ramdisk-size>3145728</oem-ramdisk-size>
34+
</oemconfig>
35+
<size unit="M">2500</size>
36+
</type>
37+
</preferences>
38+
<preferences profiles="ISO">
39+
<type image="oem" filesystem="btrfs" fsmountoptions="compress=zstd:15" firmware="uefi" installiso="true" installboot="install" kernelcmdline="rd.kiwi.ramdisk rd.kiwi.install.pass.bootparam" volid="agama">
2040
<bootloader name="grub2" timeout="1"/>
2141
<oemconfig>
2242
<oem-skip-verify>true</oem-skip-verify>
2343
<oem-unattended>true</oem-unattended>
2444
<oem-unattended-id>/dev/ram1</oem-unattended-id>
2545
<oem-swap>false</oem-swap>
2646
<oem-multipath-scan>false</oem-multipath-scan>
47+
<oem-ramdisk-size>3145728</oem-ramdisk-size>
2748
</oemconfig>
2849
<size unit="M">2500</size>
2950
</type>
@@ -35,20 +56,28 @@
3556
<repository type="rpm-md">
3657
<source path="obsrepositories:/"/>
3758
</repository>
59+
<packages type="image" profiles="PXE">
60+
<!-- specific packages for Agama remote install -->
61+
<package name="kernel-default"/>
62+
</packages>
63+
<packages type="image" profiles="ISO">
64+
<!-- specific packages for agama ISO workload -->
65+
<package name="kernel-default"/>
66+
<package name="grub2-branding-openSUSE" arch="aarch64,x86_64"/>
67+
<package name="grub2"/>
68+
<package name="grub2-arm64-efi" arch="aarch64"/>
69+
<package name="grub2-x86_64-efi" arch="x86_64"/>
70+
<package name="grub2-i386-pc" arch="x86_64"/>
71+
<package name="shim" arch="aarch64,x86_64"/>
72+
</packages>
3873
<packages type="image">
74+
<!-- general system packages for agama workload -->
3975
<package name="avahi"/>
4076
<package name="bind-utils"/>
4177
<package name="patterns-openSUSE-base"/>
4278
<package name="systemd"/>
43-
<package name="grub2-branding-openSUSE" arch="aarch64,x86_64"/>
4479
<package name="iputils"/>
4580
<package name="vim"/>
46-
<package name="vim-data"/>
47-
<package name="grub2"/>
48-
<package name="grub2-arm64-efi" arch="aarch64"/>
49-
<package name="grub2-x86_64-efi" arch="x86_64"/>
50-
<package name="grub2-i386-pc" arch="x86_64"/>
51-
<package name="syslinux" arch="x86_64"/>
5281
<package name="fontconfig"/>
5382
<package name="fonts-config"/>
5483
<package name="adobe-sourcecodepro-fonts"/>
@@ -59,19 +88,15 @@
5988
<package name="bash-completion"/>
6089
<package name="dhcp-client"/>
6190
<package name="which"/>
62-
<package name="kernel-default"/>
63-
<!-- the firmware files not referenced by any kernel driver are removed from the image -->
6491
<package name="kernel-firmware"/>
6592
<package name="adaptec-firmware"/>
6693
<package name="atmel-firmware"/>
6794
<package name="bluez-firmware"/>
6895
<package name="ipw-firmware"/>
6996
<package name="mpt-firmware"/>
7097
<package name="zd1211-firmware"/>
71-
<package name="systemd-zram-service"/> <!--- needed for zram -->
72-
<package name="shim" arch="aarch64,x86_64"/>
98+
<package name="systemd-zram-service"/>
7399
<package name="timezone"/>
74-
<package name="dracut-kiwi-live"/>
75100
<package name="blog" arch="s390x" />
76101
<package name="libblogger2" arch="s390x" />
77102
<package name="xauth"/>
@@ -90,7 +115,6 @@
90115
<package name="icewm-lite"/>
91116
<package name="xinit"/>
92117
<package name="psmisc"/>
93-
<package name="joe"/>
94118
<package name="checkmedia"/>
95119
<package name="spice-vdagent"/>
96120
<package name="libtss2-tcti-device0"/>
@@ -99,7 +123,6 @@
99123
<package name="dracut-kiwi-oem-dump"/>
100124
</packages>
101125
<packages type="delete">
102-
<package name="vim-data"/>
103126
<package name="alsa"/>
104127
<package name="alsa-utils"/>
105128
<package name="alsa-ucm-conf"/>

doc/source/working_with_images/disk_ramdisk_deployment.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ oem type definition:
2020

2121
.. code:: xml
2222
23-
<type image="oem" filesystem="ext4" installiso="true" initrd_system="dracut" installboot="install" kernelcmdline="rd.kiwi.ramdisk ramdisk_size=2048000">
23+
<type image="oem" filesystem="ext4" installiso="true" initrd_system="dracut" installboot="install" kernelcmdline="rd.kiwi.ramdisk">
2424
<bootloader name="grub2" timeout="1"/>
2525
<oemconfig>
2626
<oem-skip-verify>true</oem-skip-verify>
2727
<oem-unattended>true</oem-unattended>
2828
<oem-unattended-id>/dev/ram1</oem-unattended-id>
2929
<oem-swap>false</oem-swap>
3030
<oem-multipath-scan>false</oem-multipath-scan>
31+
<oem-ramdisk-size>2048000</oem-ramdisk-size>
3132
</oemconfig>
3233
</type>
3334
@@ -39,12 +40,12 @@ without asking any questions. In a ramdisk deployment the
3940
optional target verification, swap space and multipath targets
4041
are out of scope and therefore disabled.
4142

42-
The configured size of the ramdisk specifies the size of the
43-
OS disk and must be at least of the size of the System Image.
44-
The disk size can be configured with the following value in
45-
the kernelcmdline attribute:
43+
The configured size of the ramdisk via `oem-ramdisk-size` specifies
44+
the kB size of the OS disk and it must be at least of the size of the
45+
System Image. The disk size can be configured dynamically with the
46+
following value in the kernelcmdline attribute:
4647

47-
* ramdisk_size=kbyte-value"
48+
* ramdisk_size=kbyte-value
4849

4950
An image built with the above setup can be tested in QEMU as
5051
follows:

dracut/modules.d/90kiwi-dump/kiwi-dump-image.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function get_disk_list {
2222
declare kiwi_install_volid=${kiwi_install_volid}
2323
declare kiwi_oemunattended=${kiwi_oemunattended}
2424
declare kiwi_oemunattended_id=${kiwi_oemunattended_id}
25+
declare kiwi_oemramdisksize=${kiwi_oemramdisksize}
2526
local disk_id="by-id"
2627
local disk_size
2728
local disk_device
@@ -48,8 +49,14 @@ function get_disk_list {
4849
# target should be a ramdisk on request. Thus actively
4950
# load the ramdisk block driver and support custom sizes
5051
local rd_size
52+
local custom_rd_size
5153
local modfile=/etc/modprobe.d/99-brd.conf
52-
rd_size=$(getarg ramdisk_size=)
54+
custom_rd_size=$(getarg ramdisk_size=)
55+
if [ -n "${custom_rd_size}" ];then
56+
rd_size="${custom_rd_size}"
57+
elif [ -n "${kiwi_oemramdisksize}" ];then
58+
rd_size="${kiwi_oemramdisksize}"
59+
fi
5360
mkdir -p /etc/modprobe.d
5461
if [ -n "${rd_size}" ];then
5562
echo "options brd rd_size=${rd_size}" > ${modfile}

kiwi/schema/kiwi.rnc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,23 @@ div {
491491
}
492492
}
493493

494+
#==========================================
495+
# common element <oem-ramdisk-size>
496+
#
497+
div {
498+
k.oem-ramdisk-size.content = text
499+
k.oem-ramdisk-size.attlist = empty
500+
k.oem-ramdisk-size =
501+
## For oemboot driven images: specify the size of the ramdisk
502+
## The value is taken into account if the deployment of the
503+
## image happens into a ramdisk. The value can be overwritten
504+
## with the kernel boot parameter: ramdisk_size
505+
element oem-ramdisk-size {
506+
k.oem-ramdisk-size.attlist,
507+
k.oem-ramdisk-size.content
508+
}
509+
}
510+
494511
#==========================================
495512
# common element <oem-device-filter>
496513
#
@@ -3462,6 +3479,7 @@ div {
34623479
k.oem-bootwait? &
34633480
k.oem-resize? &
34643481
k.oem-resize-once? &
3482+
k.oem-ramdisk-size? &
34653483
k.oem-device-filter? &
34663484
k.oem-nic-filter? &
34673485
k.oem-inplace-recovery? &

kiwi/schema/kiwi.rng

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,29 @@ operation happens only once and then never again</a:documentation>
806806
</element>
807807
</define>
808808
</div>
809+
<!--
810+
==========================================
811+
common element <oem-ramdisk-size>
812+
813+
-->
814+
<div>
815+
<define name="k.oem-ramdisk-size.content">
816+
<text/>
817+
</define>
818+
<define name="k.oem-ramdisk-size.attlist">
819+
<empty/>
820+
</define>
821+
<define name="k.oem-ramdisk-size">
822+
<element name="oem-ramdisk-size">
823+
<a:documentation>For oemboot driven images: specify the size of the ramdisk
824+
The value is taken into account if the deployment of the
825+
image happens into a ramdisk. The value can be overwritten
826+
with the kernel boot parameter: ramdisk_size</a:documentation>
827+
<ref name="k.oem-ramdisk-size.attlist"/>
828+
<ref name="k.oem-ramdisk-size.content"/>
829+
</element>
830+
</define>
831+
</div>
809832
<!--
810833
==========================================
811834
common element <oem-device-filter>
@@ -5174,6 +5197,9 @@ and setup the system disk.</a:documentation>
51745197
<optional>
51755198
<ref name="k.oem-resize-once"/>
51765199
</optional>
5200+
<optional>
5201+
<ref name="k.oem-ramdisk-size"/>
5202+
</optional>
51775203
<optional>
51785204
<ref name="k.oem-device-filter"/>
51795205
</optional>

kiwi/system/profile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ def _oemconfig_to_profile(self):
134134
self._text(oemconfig.get_oem_resize_once())
135135
self.dot_profile['kiwi_oempartition_install'] = \
136136
self._text(oemconfig.get_oem_partition_install())
137+
self.dot_profile['kiwi_oemramdisksize'] = \
138+
self._text(oemconfig.get_oem_ramdisk_size())
137139
self.dot_profile['kiwi_oemdevicefilter'] = \
138140
self._text(oemconfig.get_oem_device_filter())
139141
self.dot_profile['kiwi_oemtitle'] = \

kiwi/xml_parse.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8001,7 +8001,7 @@ class oemconfig(GeneratedsSuper):
80018001
which are used to repartition and setup the system disk."""
80028002
subclass = None
80038003
superclass = None
8004-
def __init__(self, oem_boot_title=None, oem_bootwait=None, oem_resize=None, oem_resize_once=None, oem_device_filter=None, oem_nic_filter=None, oem_inplace_recovery=None, oem_kiwi_initrd=None, oem_multipath_scan=None, oem_vmcp_parmfile=None, oem_partition_install=None, oem_reboot=None, oem_reboot_interactive=None, oem_recovery=None, oem_recoveryID=None, oem_recovery_part_size=None, oem_shutdown=None, oem_shutdown_interactive=None, oem_silent_boot=None, oem_silent_install=None, oem_silent_verify=None, oem_skip_verify=None, oem_swap=None, oem_swapsize=None, oem_swapname=None, oem_systemsize=None, oem_unattended=None, oem_unattended_id=None):
8004+
def __init__(self, oem_boot_title=None, oem_bootwait=None, oem_resize=None, oem_resize_once=None, oem_ramdisk_size=None, oem_device_filter=None, oem_nic_filter=None, oem_inplace_recovery=None, oem_kiwi_initrd=None, oem_multipath_scan=None, oem_vmcp_parmfile=None, oem_partition_install=None, oem_reboot=None, oem_reboot_interactive=None, oem_recovery=None, oem_recoveryID=None, oem_recovery_part_size=None, oem_shutdown=None, oem_shutdown_interactive=None, oem_silent_boot=None, oem_silent_install=None, oem_silent_verify=None, oem_skip_verify=None, oem_swap=None, oem_swapsize=None, oem_swapname=None, oem_systemsize=None, oem_unattended=None, oem_unattended_id=None):
80058005
self.original_tagname_ = None
80068006
if oem_boot_title is None:
80078007
self.oem_boot_title = []
@@ -8019,6 +8019,10 @@ def __init__(self, oem_boot_title=None, oem_bootwait=None, oem_resize=None, oem_
80198019
self.oem_resize_once = []
80208020
else:
80218021
self.oem_resize_once = oem_resize_once
8022+
if oem_ramdisk_size is None:
8023+
self.oem_ramdisk_size = []
8024+
else:
8025+
self.oem_ramdisk_size = oem_ramdisk_size
80228026
if oem_device_filter is None:
80238027
self.oem_device_filter = []
80248028
else:
@@ -8146,6 +8150,11 @@ def set_oem_resize_once(self, oem_resize_once): self.oem_resize_once = oem_resiz
81468150
def add_oem_resize_once(self, value): self.oem_resize_once.append(value)
81478151
def insert_oem_resize_once_at(self, index, value): self.oem_resize_once.insert(index, value)
81488152
def replace_oem_resize_once_at(self, index, value): self.oem_resize_once[index] = value
8153+
def get_oem_ramdisk_size(self): return self.oem_ramdisk_size
8154+
def set_oem_ramdisk_size(self, oem_ramdisk_size): self.oem_ramdisk_size = oem_ramdisk_size
8155+
def add_oem_ramdisk_size(self, value): self.oem_ramdisk_size.append(value)
8156+
def insert_oem_ramdisk_size_at(self, index, value): self.oem_ramdisk_size.insert(index, value)
8157+
def replace_oem_ramdisk_size_at(self, index, value): self.oem_ramdisk_size[index] = value
81498158
def get_oem_device_filter(self): return self.oem_device_filter
81508159
def set_oem_device_filter(self, oem_device_filter): self.oem_device_filter = oem_device_filter
81518160
def add_oem_device_filter(self, value): self.oem_device_filter.append(value)
@@ -8272,6 +8281,7 @@ def hasContent_(self):
82728281
self.oem_bootwait or
82738282
self.oem_resize or
82748283
self.oem_resize_once or
8284+
self.oem_ramdisk_size or
82758285
self.oem_device_filter or
82768286
self.oem_nic_filter or
82778287
self.oem_inplace_recovery or
@@ -8340,6 +8350,9 @@ def exportChildren(self, outfile, level, namespaceprefix_='', name_='oemconfig',
83408350
for oem_resize_once_ in self.oem_resize_once:
83418351
showIndent(outfile, level, pretty_print)
83428352
outfile.write('<oem-resize-once>%s</oem-resize-once>%s' % (self.gds_format_boolean(oem_resize_once_, input_name='oem-resize-once'), eol_))
8353+
for oem_ramdisk_size_ in self.oem_ramdisk_size:
8354+
showIndent(outfile, level, pretty_print)
8355+
outfile.write('<oem-ramdisk-size>%s</oem-ramdisk-size>%s' % (self.gds_encode(self.gds_format_string(quote_xml(oem_ramdisk_size_), input_name='oem-ramdisk-size')), eol_))
83438356
for oem_device_filter_ in self.oem_device_filter:
83448357
showIndent(outfile, level, pretty_print)
83458358
outfile.write('<oem-device-filter>%s</oem-device-filter>%s' % (self.gds_encode(self.gds_format_string(quote_xml(oem_device_filter_), input_name='oem-device-filter')), eol_))
@@ -8456,6 +8469,10 @@ def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
84568469
raise_parse_error(child_, 'requires boolean')
84578470
ival_ = self.gds_validate_boolean(ival_, node, 'oem_resize_once')
84588471
self.oem_resize_once.append(ival_)
8472+
elif nodeName_ == 'oem-ramdisk-size':
8473+
oem_ramdisk_size_ = child_.text
8474+
oem_ramdisk_size_ = self.gds_validate_string(oem_ramdisk_size_, node, 'oem_ramdisk_size')
8475+
self.oem_ramdisk_size.append(oem_ramdisk_size_)
84598476
elif nodeName_ == 'oem-device-filter':
84608477
oem_device_filter_ = child_.text
84618478
oem_device_filter_ = self.gds_validate_string(oem_device_filter_, node, 'oem_device_filter')

test/unit/system/profile_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def test_create_oem(self, mock_which):
110110
'kiwi_lvm': 'true',
111111
'kiwi_lvmgroup': 'systemVG',
112112
'kiwi_oembootwait': None,
113+
'kiwi_oemramdisksize': None,
113114
'kiwi_oemdevicefilter': None,
114115
'kiwi_oemnicfilter': None,
115116
'kiwi_oemkboot': None,

0 commit comments

Comments
 (0)