<p>Another idea: use Packer, like this example <em><a href="https://ketzacoatl.github.io/posts/2017-06-02-build-alpine-vagrant-box-with-packer.html" rel="nofollow noreferrer">Using Packer to Build Alpine Linux Box for Vagrant</a></em></p>

CC BY-SA 4.0
2024-07-17T18:59:25.007Z
2024-07-17T18:59:25.007Z
mikequentel
<p>I want to create a custom Alpine Linux image. I want to take the Virtual ISO version (<a href="https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/x86_64/alpine-virt-3.20.1-x86_64.iso" rel="nofollow noreferrer">https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/x86_64/alpine-virt-3.20.1-x86_64.iso</a>) extend it with some packages and do some configuration stuff. Then I want to &quot;repack&quot; the achieved state in a new ISO, which then can be used for another VM, for example in vSphere.</p>
<p>I want to enable community repo, install the open-vm-tools package, add to automatic service start (so it gets booted on startup) and enable the network adapter. Basically what I would be doing when executing &quot;setup-alpine&quot;. Manually executed, this all works fine. The problem starts when I want to create a new iso out of the current start.</p>
<p>If I understand correctly, what I want to achieve can be done with: mkimage (short documentation on how to use it: <a href="https://wiki.alpinelinux.org/wiki/How_to_make_a_custom_ISO_image_with_mkimage" rel="nofollow noreferrer">https://wiki.alpinelinux.org/wiki/How_to_make_a_custom_ISO_image_with_mkimage</a>).</p>
<p>Sometimes I end up with a created iso, sometimes I don't. When the process resulted with an iso, most of the time they were relatively big ~900MB. The origin is only ~60MB. But none of them are working. When creating a new VM with that iso (e. g. in vSphere) it ends with criticial error: OS not found, etc. I guess I am doing something wrong when it comes to the creation of the mkimg.custom-alpine.sh and the corresponding genapkovl file.</p>
<p><strong>What did I do</strong></p>
<ol>
<li>Creation of a local VM with the Virtual Alpine iso</li>
<li>After startup --&gt; &quot;setup-alpine&quot; + reboot</li>
<li>Activation of community repos in /etc/apk/repositories</li>
<li>apk upgrade &amp;&amp; apk update</li>
<li>apk add open-vm-tools</li>
<li>rc-update add open-vm-tools boot</li>
<li>after reboot, everything works as desired</li>
<li>starting the mkimage tutorial</li>
<li>installing all packages, adding user and permissions, creating key, checking out aports, and so on</li>
</ol>
<p>Then the script part starts. Setting</p>
<pre><code>export PROFILENAME=custom-alpine
</code></pre>
<p>My mkimg.custom-alpine.sh looks like this</p>
<pre><code>#!/bin/sh

profile_custom_alpine() {
    profile_standard
    kernel_cmdline=&quot;unionfs_size=512M console=tty0 console=ttyS0,115200&quot;
    syslinux_serial=&quot;0 115200&quot;
    kernel_addons=&quot;zfs&quot;
    apks=&quot;$apks alpine-base open-vm-tools&quot;

    local _k _a
    for _k in $kernel_flavors; do
        apks=&quot;$apks linux-$_k&quot;
        for _a in $kernel_addons; do
            apks=&quot;$apks $_a-$_k&quot;
        done
    done
    apks=&quot;$apks linux-firmware&quot;
    apkovl=&quot;aports/scripts/genapkovl-custom-alpine.sh&quot;
}
</code></pre>
<p>For the genapkovl file I used the genapkovl-dhcp.sh as suggested and just added the information for open-vm-tools at the relevant parts.</p>
<p>Then I am creating the actual iso like described with:</p>
<pre><code>sh aports/scripts/mkimage.sh --tag edge \
    --outdir ~/iso \
    --arch x86_64 \
    --repository https://dl-cdn.alpinelinux.org/alpine/edge/main \
    --profile $PROFILENAME
</code></pre>
<p>Sometimes it works, sometimes it doesn't. But it never resulted in a &quot;working&quot; ISO. So I am assuming I am doing something wrong or I misunderstood something.</p>
<p>Any help?</p>

CC BY-SA 4.0
2024-07-17T08:27:02.350Z
Got it now. For other users that may encounter this problem one day: **xorriso** and this manual: [https://www.skreutz.com/posts/unattended-installation-of-alpine-linux/](https://www.skreutz.com/posts/unattended-installation-of-alpine-linux/) helped very much
Bernte
<images><powershell><vmware><alpine>
Creating a custom alpine iso - including open-vm-tools
Bernte
# Creating a custom alpine iso - including open-vm-tools

(Asked by: username_0 on 2024-07-10)

I want to create a custom Alpine Linux image. I want to take the Virtual ISO version (https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/x86_64/alpine-virt-3.20.1-x86_64.iso) extend it with some packages and do some configuration stuff. Then I want to "repack" the achieved state in a new ISO, which then can be used for another VM, for example in vSphere.
I want to enable community repo, install the open-vm-tools package, add to automatic service start (so it gets booted on startup) and enable the network adapter. Basically what I would be doing when executing "setup-alpine". Manually executed, this all works fine. The problem starts when I want to create a new iso out of the current start.
If I understand correctly, what I want to achieve can be done with: mkimage (short documentation on how to use it: https://wiki.alpinelinux.org/wiki/How_to_make_a_custom_ISO_image_with_mkimage).
Sometimes I end up with a created iso, sometimes I don't. When the process resulted with an iso, most of the time they were relatively big ~900MB. The origin is only ~60MB. But none of them are working. When creating a new VM with that iso (e. g. in vSphere) it ends with criticial error: OS not found, etc. I guess I am doing something wrong when it comes to the creation of the mkimg.custom-alpine.sh and the corresponding genapkovl file.
What did I do

Creation of a local VM with the Virtual Alpine iso
After startup --> "setup-alpine" + reboot
Activation of community repos in /etc/apk/repositories
apk upgrade && apk update
apk add open-vm-tools
rc-update add open-vm-tools boot
after reboot, everything works as desired
starting the mkimage tutorial
installing all packages, adding user and permissions, creating key, checking out aports, and so on

Then the script part starts. Setting
export PROFILENAME=custom-alpine

My mkimg.custom-alpine.sh looks like this
#!/bin/sh

profile_custom_alpine() {
    profile_standard
    kernel_cmdline="unionfs_size=512M console=tty0 console=ttyS0,115200"
    syslinux_serial="0 115200"
    kernel_addons="zfs"
    apks="$apks alpine-base open-vm-tools"

    local _k _a
    for _k in $kernel_flavors; do
        apks="$apks linux-$_k"
        for _a in $kernel_addons; do
            apks="$apks $_a-$_k"
        done
    done
    apks="$apks linux-firmware"
    apkovl="aports/scripts/genapkovl-custom-alpine.sh"
}

For the genapkovl file I used the genapkovl-dhcp.sh as suggested and just added the information for open-vm-tools at the relevant parts.
Then I am creating the actual iso like described with:
sh aports/scripts/mkimage.sh --tag edge \
    --outdir ~/iso \
    --arch x86_64 \
    --repository https://dl-cdn.alpinelinux.org/alpine/edge/main \
    --profile $PROFILENAME

Sometimes it works, sometimes it doesn't. But it never resulted in a "working" ISO. So I am assuming I am doing something wrong or I misunderstood something.
Any help?

**Tags:** images, powershell, vmware, alpine

> **Comments:**
> **username_0**: Got it now. For other users that may encounter this problem one day: **xorriso** and this manual: [https://www.skreutz.com/posts/unattended-installation-of-alpine-linux/](https://www.skreutz.com/posts/unattended-installation-of-alpine-linux/) helped very much  

---

## 1 answers

### Answer by username_1 on 2024-07-17. Score: 0

Another idea: use Packer, like this example *[Using Packer to Build Alpine Linux Box for Vagrant](https://ketzacoatl.github.io/posts/2017-06-02-build-alpine-vagrant-box-with-packer.html)*


---

