Create multiple disks with Kiwi

38 views
Skip to first unread message

Dan Collins

unread,
Feb 16, 2023, 11:50:28 AM2/16/23
to kiwi
Hi All,

I am new to using Kiwi to build appliances. I am trying to create an appliance with a second disk. Using the partitions tag, I can create another partition on a disk (/dev/sda3), but I would instead like to instead create another disk completely (/dev/sdb). 

I am using vmx & vmdk, and trying to output to an ovf file with SUSE as the OS. I want Kiwi to output a second vmdk file for my second disk. I know this behavior is possible using Packer, but I am not sure how to do it using Kiwi. Intuition tells me that I would achieve this by adding another systemdisk tag, but that fails to parse.

Here is a snippet of my kiwi config file for context:

<preferences profiles="ovf">
    <type image="vmx" filesystem="ext4" format="vmdk" primary="true">
        <bootloader name="grub2"/>
        <machine memory="16384" guestOS="suse" ovftype="vmware">
            <vmdisk id="0" controller="lsilogic"/>
            <vmnic driver="VMXNET3" interface="0" mode="bridged"/>
            <vmconfig-entry>numvcpus = "4"</vmconfig-entry>
            <vmconfig-entry>cpuid.coresPerSocket = "2"</vmconfig-entry>
        </machine>
        <size additive="true" unit="G">400</size>
        <systemdisk name="SystemDisk">
            <volume name="swap" freespace="8192M"/>
        </systemdisk>
    </type>
</preferences>

I am using Kiwi version 9.24.43.

Marcus Schäfer

unread,
Feb 17, 2023, 3:47:54 AM2/17/23
to kiwi-...@googlegroups.com
Hi,

> I am new to using Kiwi to build appliances. I am trying to create an
> appliance with a second disk. Using the partitions tag, I can create
> another partition on a disk (/dev/sda3), but I would instead like to
> instead create another disk completely (/dev/sdb).

If I understood you correctly you would like to create two disk images,
one for your first disk (e.g /dev/sda) and one for your second
disk (e.g /dev/sdb).

In kiwi this would mean two build processes for each of them which
you can combine in one image description using profiles. The basic
layout in XML speak would be like this:

<image ...>
<profiles>
<profile name="MyDiskA" description="Your /dev/sda disk image"/>
<profile name="MyDiskB" description="Your /dev/sdb disk image"/>
</profiles>

<preferences>
<!-- common preferences used for all profiles -->
</preferences

<preferences profiles="MyDiskA">
<!-- preferences settings only for MyDiskA -->
</preferences

<preferences profiles="MyDiskB">
<!-- preferences settings only for MyDiskB -->
</preferences

...more
</image>

You would then have two build processes in kiwi to build your
disk images, e.g:

kiwi-ng --profile MyDiskA system build ... --target-dir /tmp/MyDiskA
kiwi-ng --profile MyDiskB system build ... --target-dir /tmp/MyDiskB

As you now have two disk images you can deploy them on your target
devices (/dev/sda, /dev/sdb).

At this point I was wondering if these two images on the two disks
are somehow connected to each other and if that maybe impacts the way
you need to build them. From what you explained so far I can't tell

Hope this information helps a bit

Regards,
Marcus
--
Public Key available via: https://keybase.io/marcus_schaefer/key.asc
keybase search marcus_schaefer
-------------------------------------------------------
Marcus Schäfer Brunnenweg 18
Tel: +49 7562 905437 D-88260 Argenbühl
Germany
-------------------------------------------------------
signature.asc

Dan Collins

unread,
Feb 17, 2023, 11:33:28 AM2/17/23
to kiwi
Hi Marcus,

Thank you for the reply. To clarify one thing, I would like the second disk to be completely empty. It is intended to be used as spare virtual disk. I am under the impression that if I do it this way, MyDiskB will have an OS installed on it. If this is true, is there any way to avoid this?

-Dan

Dan Collins

unread,
Feb 17, 2023, 11:38:13 AM2/17/23
to kiwi
Oh, and one more thing, the second disk should be included in the vmx file that is created by Kiwi.

-Dan

Marcus Schäfer

unread,
Feb 21, 2023, 8:34:05 AM2/21/23
to kiwi-...@googlegroups.com
Hi,

> Thank you for the reply. To clarify one thing, I would like the second
> disk to be completely empty. It is intended to be used as spare virtual
> disk. I am under the impression that if I do it this way, MyDiskB will
> have an OS installed on it. If this is true, is there any way to avoid
> this

You are right. Ok so you want to add an empty disk to your OVF image

> Oh, and one more thing, the second disk should be included in the vmx
> file that is created by Kiwi.

Got it.

So kiwi itself does not implement attaching periphery devices
because this is implemented by other tools already. In your case
the OVF tool (cot) should be able to do what you are after.

imho your image build workflow could look like this:

1. Run kiwi to build the main OS image (as ovf)

kiwi-ng system build ...

2. Create an empty extra disk

qemu-img create MyDiskB 100G
qemu-img convert -f raw -O vmdk MyDiskB MyDiskB.vmdk

3. Add the disk to your image

cot add-disk ...

Also see: https://cot.readthedocs.io/en/latest/usage_add_disk.html

In general with kiwi we try to allow an easy integration into
a possible chain of actions but try to avoid duplication as much
as possible.

Let me know if this helps with your use cases.

Thanks
signature.asc

Dan Collins

unread,
Mar 15, 2023, 5:11:56 PM3/15/23
to kiwi
Thank you for your detailed response. I was able to accomplish this using an outside tool like how you described, rather than using a built-in function of Kiwi.

-Dan

Marcus Schäfer

unread,
Mar 16, 2023, 5:03:42 AM3/16/23
to kiwi-...@googlegroups.com
Hi Dan,

> Thank you for your detailed response. I was able to accomplish this
> using an outside tool like how you described, rather than using a
> built-in function of Kiwi.

Great, happy you found a solution :)
signature.asc
Reply all
Reply to author
Forward
0 new messages