Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support install disk overwrite per cmdline #2398

Merged
merged 2 commits into from
Nov 28, 2023

Conversation

schaefi
Copy link
Collaborator

@schaefi schaefi commented Nov 22, 2023

Allow install disk overwrite from cmdline

Add rd.kiwi.oem.installdevice=DEVICE. Configures the disk device that should be used in an OEM installation. This oerwrites any other oem device setting, e.g device filter or maxdisk and just continues the installation on the given device. However, the device must exist and must be a block special.

@schaefi schaefi requested a review from davidcassany November 22, 2023 14:55
@schaefi schaefi self-assigned this Nov 22, 2023
@schaefi schaefi requested a review from e-minguez November 23, 2023 08:53
@schaefi
Copy link
Collaborator Author

schaefi commented Nov 23, 2023

cool, thanks for the review. As this is initrd code I'm always a bit concerned and therefore I also like to have two people approving. @davidcassany could you have a short look if you see something problematic ? I think we are good though. Thanks

@schaefi schaefi force-pushed the support_install_disk_overwrite_per_cmdline branch from 5da1083 to 6f6db25 Compare November 23, 2023 10:15
Copy link
Collaborator

@davidcassany davidcassany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Just a comment regarding the current logic. From lines

if [ -z "${kiwi_oemunattended_id}" ];then
# unattended mode requested but no target specifier,
# thus use first device from list
echo "${device_array[0]}"
else
# unattended mode requested with target specifier
# use this device if present
local device
for device in ${device_array[*]}; do
if [[ ${device} =~ ${kiwi_oemunattended_id} ]];then
echo "${device}"
return
fi
done
fi

I understand that oem-unattended-id element from the XML will always have precedence over rd.kiwi.oem.installdevice , I am not sure this is intended. In general, my expectation as a user would be that runtime choices in kernel command parameters overwrite buildtime choices coming from the XML, so that the same image build turns to be usable in a wider range of use cases.

Note this is arguable, as setting oem-unattended-id in XML already assumes a great knowledge of the deployment environment before.

@davidcassany
Copy link
Collaborator

Looks great 👍

Add rd.kiwi.oem.installdevice=DEVICE. Configures the disk device
that should be used in an OEM installation. This overwrites any
other oem device setting, e.g device filter or maxdisk and just
continues the installation on the given device. However, the
device must exist and must be a block special.
This Fixes jira#PED-7180
@schaefi schaefi force-pushed the support_install_disk_overwrite_per_cmdline branch from 9d72f19 to 9d8c14b Compare November 23, 2023 11:31
@schaefi
Copy link
Collaborator Author

schaefi commented Nov 23, 2023

I'm going to submit a Staging kiwi including this change. Our integration testing will rebuild and we can do some in depth tests with the image from here:

@schaefi
Copy link
Collaborator Author

schaefi commented Nov 24, 2023

my tests were successful. I tested:

  • normal operation, no regression found
  • with rd.kiwi.oem.installdevice=/dev/foo ends with expected error message on the console
  • with rd.kiwi.oem.installdevice=/dev/sda installs like in normal case because my qemu disk appears as /dev/sda
  • with rd.kiwi.oem.installdevice=/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001 installs like in normal case because ata-QEMU_HARDDISK_QM00001 -> ../../sda

If you have more specific tests in my mind just try them with the proposed integration test. Thanks

@e-minguez
Copy link

my tests were successful. I tested:

  • normal operation, no regression found
  • with rd.kiwi.oem.installdevice=/dev/foo ends with expected error message on the console
  • with rd.kiwi.oem.installdevice=/dev/sda installs like in normal case because my qemu disk appears as /dev/sda
  • with rd.kiwi.oem.installdevice=/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001 installs like in normal case because ata-QEMU_HARDDISK_QM00001 -> ../../sda

If you have more specific tests in my mind just try them with the proposed integration test. Thanks

Just in case it would be nice to test installing it into a 'second' hard disk such as /dev/sdb to verify that it doesn't use the default one :) Thanks!

@schaefi
Copy link
Collaborator Author

schaefi commented Nov 24, 2023

Just in case it would be nice to test installing it into a 'second' hard disk such as /dev/sdb to verify that it doesn't use the default one :) Thanks!

yep good idea. I did this as follows

qemu-img create mydisk_a 20g
qemu-img create mydisk_b 20g

kvm -cdrom kiwi-test-image-disk.x86_64-1.42.1-Build62.13.install.iso -hda mydisk_a -hdb mydisk_b -boot d

and on the cmdline:

rd.kiwi.oem.installdevice=/dev/sdb

then after halt

kvm -hda mydisk_b
  • and it boots with the system deployed to the second disk
  • the device switch via hda and hdb does not impact the system boot as the UUID of the deployed root device did not change, so it's still safe to deploy a target using its unix node name even if that is not a persistent device name

So I think it does what we wanted it to do :)

@schaefi schaefi merged commit d4316b3 into master Nov 28, 2023
10 checks passed
@schaefi schaefi deleted the support_install_disk_overwrite_per_cmdline branch November 28, 2023 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants