from Hacker News

Ask HN: Cloud-Localds Alternative for macOS?

by ingvul on 2/8/22, 10:43 PM with 2 comments

I'm using qemu to build Ubuntu server VMs on my mac, and I want to use cloud-init to configure the VM. Everything works fine but there is one command I cannot run on my mac:

    cloud-localds -v --network-config=network.cfg ubuntu.img cloud_init.cfg

I haven't found anything similar to cloud-localds available on Mac. So, it seems that in order to boot my Ubuntu VM I first need to boot another VM to run cloud-localds... a bit frustrating. Do you know how can I achieve the same as the command line above but in MacOS?
  • by ComradePhil on 2/8/22, 11:23 PM

    You can install Docker Desktop and then try running it via Docker.

    To do so,

        # Run the following once
        mkdir cloud-image-utils
        cd cloud-image-utils
        echo FROM ubuntu > Dockerfile
        echo RUN apt update >> Dockerfile
        echo RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends cloud-image-utils >> Dockerfile
        docker build -t cloud-image-utils .
        
        # Now, you will be able to run cloud-localds by running the following
        docker run -v $(pwd):/mnt cloud-image-utils cloud-localds -v --network-config=/mnt/network.cfg /mnt/ubuntu.img /mnt/cloud_init.cfg
    
    You can create an alias for the command above to make it easier to use.
  • by ipveesix on 2/10/22, 2:07 AM

    cloud-localds also works on MacOS with a little patch. After all, it's a bash script.

        brew install cdrtools
        wget -O cloud-localds https://github.com/canonical/cloud-utils/raw/main/bin/cloud-localds
        sed -i 's/genisoimage/mkisofs/g' cloud-localds
        chmod +x cloud-localds