Skip to content

Commit 7b39c1a

Browse files
authored
Merge pull request #2850 from OSInside/device_persistency_selectable_for_install_media
Add rd.kiwi.install.devicepersistency
2 parents 3fb15c5 + 282a4e1 commit 7b39c1a

File tree

3 files changed

+66
-5
lines changed

3 files changed

+66
-5
lines changed

doc/source/concept_and_workflow/customize_the_boot_process.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ the available kernel boot parameters for these modules:
200200
If set to the special value `off`, the dialog will never
201201
timeout.
202202

203+
``rd.kiwi.install.devicepersistency=by-*``
204+
Instructs an OEM installation image to present the list of
205+
available disk devices using the device names as provided
206+
by the specified `by-*` representation. For example
207+
`rd.kiwi.install.devicepersistency=by-path` would show the
208+
by-path device names in the list of available disks.
209+
203210
``rd.kiwi.install.pxe``
204211
Instructs an OEM installation image to lookup the system
205212
image on a remote location specified in `rd.kiwi.install.image`.

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

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,50 @@ function scan_multipath_devices {
1515
systemctl start multipathd
1616
}
1717

18+
function find_disk_entry {
19+
# """
20+
# lookup disk entry by name and echo the
21+
# associated entry parameter (size) when found
22+
# """
23+
local list_items=$1
24+
local search=$2
25+
local count=0
26+
local found=
27+
for entry in ${list_items};do
28+
if [ -n "${found}" ];then
29+
echo "${entry}"
30+
return
31+
fi
32+
if [ $((count % 2)) -eq 0 ];then
33+
if [ "${entry}" = "${search}" ];then
34+
found=1
35+
fi
36+
fi
37+
count=$((count + 1))
38+
done
39+
}
40+
41+
function sort_disk_entries {
42+
# """
43+
# sort the disk entry names
44+
# """
45+
local list_items=$1
46+
local count=0
47+
local device_index=0
48+
local device_array
49+
local list_items_sorted
50+
for entry in ${list_items};do
51+
if [ $((count % 2)) -eq 0 ];then
52+
device_array[${device_index}]=${entry}
53+
device_index=$((device_index + 1))
54+
fi
55+
count=$((count + 1))
56+
done
57+
readarray -td '' list_items_sorted \
58+
< <(printf '%s\0' "${device_array[@]}" | sort -z)
59+
echo "${list_items_sorted[*]}"
60+
}
61+
1862
function get_disk_list {
1963
declare kiwi_oemdevicefilter=${kiwi_oemdevicefilter}
2064
declare kiwi_oemmultipath_scan=${kiwi_oemmultipath_scan}
@@ -29,6 +73,7 @@ function get_disk_list {
2973
local disk_device_by_id
3074
local disk_meta
3175
local list_items
76+
local list_items_sorted
3277
local max_disk
3378
local kiwi_oem_maxdisk
3479
local blk_opts="-p -n -r --sort NAME -o NAME,SIZE,TYPE"
@@ -39,9 +84,13 @@ function get_disk_list {
3984
disk_id=${kiwi_devicepersistency}
4085
fi
4186
max_disk=0
87+
kiwi_install_devicepersistency=$(getarg rd.kiwi.install.devicepersistency=)
4288
kiwi_oemmultipath_scan=$(bool "${kiwi_oemmultipath_scan}")
4389
kiwi_oem_maxdisk=$(getarg rd.kiwi.oem.maxdisk=)
4490
kiwi_oem_installdevice=$(getarg rd.kiwi.oem.installdevice=)
91+
if [ -n "${kiwi_install_devicepersistency}" ];then
92+
disk_id=${kiwi_install_devicepersistency}
93+
fi
4594
if [ -n "${kiwi_oem_maxdisk}" ]; then
4695
max_disk=$(binsize_to_bytesize "${kiwi_oem_maxdisk}") || max_disk=0
4796
fi
@@ -154,7 +203,13 @@ function get_disk_list {
154203
local no_device_text="No device(s) for installation found"
155204
report_and_quit "${no_device_text}"
156205
fi
157-
echo "${list_items}"
206+
207+
# apply final sorting for the used disk_device names
208+
list_items_sorted=$(sort_disk_entries "${list_items}")
209+
for entry in ${list_items_sorted[*]}; do
210+
echo -n "${entry} $(find_disk_entry "${list_items}" "${entry}") "
211+
done
212+
echo
158213
}
159214

160215
function validate_disk_selection {
@@ -207,7 +262,7 @@ function get_selected_disk {
207262
# unattended mode requested with target specifier
208263
# use this device if present
209264
local device
210-
for device in ${device_array[*]}; do
265+
for device in "${device_array[@]}"; do
211266
if [[ ${device} =~ ${kiwi_oemunattended_id} ]];then
212267
echo "${device}"
213268
return
@@ -217,8 +272,7 @@ function get_selected_disk {
217272
else
218273
# manually select from storage list
219274
if ! run_dialog \
220-
--menu "\"Select Installation Disk\"" 20 75 15 \
221-
"$(get_disk_list)"
275+
--menu "\"Select Installation Disk\"" 20 75 15 "${disk_list}"
222276
then
223277
report_and_quit "System installation canceled"
224278
fi

dracut/modules.d/90kiwi-dump/module-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ install() {
2121
declare moddir=${moddir}
2222
declare systemdutildir=${systemdutildir}
2323
inst_multiple \
24-
tr lsblk dd sha256sum head pv kexec basename awk kpartx
24+
tr lsblk dd sha256sum head pv kexec basename awk kpartx sort
2525

2626
inst_hook pre-udev 30 "${moddir}/kiwi-installer-genrules.sh"
2727

0 commit comments

Comments
 (0)