alpinelinux / alpine-make-vm-image

Make customized Alpine Linux disk image for virtual machines
MIT License
300 stars 101 forks source link

Automate Alpine Linux installation #31

Closed khaaliid closed 2 years ago

khaaliid commented 2 years ago

I am trying to achieve unattended Alpine Linux installation. I went through the Alpine automatic installation guide but when I follow this guide there are many manual interventions are needed during the installation! one during writing the root user name, another time when creating the answer file (setup-alpine -c answerfileName), editing the answer file, calling the actual installation command (setup-alpine -f answerfileName) and reset the root password. Is there any way to include the answer file inside the ISO image and select the root user by default before starting the installation and set its password as well after the installation is done (something similar to the kickstart file in the Centos distro) ?

Like in CentOS we can provide kickstart file like below in isolinux.cfg

label MyMENU2
  menu label ^Deploy Manager Node
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=MYISO inst.ks=hd:LABEL=MYISO:/ks/ks1.cfg quiet

Similar way can we provide path to answer file in isolinux.cfg ?

jirutka commented 2 years ago

You don’t have to use the setup-alpine script to install and configure Alpine. It’s just a helper script to simplify common tasks during initial system configuration, it’s not necessary. Tbh, I can’t even remember the last time I used it myself. Why would you use it with alpine-make-vm-image?

This tool is designed for creating customized images for virtual machines – you provide a shell script to configure whatever you need during the build of the image and then just boot it on a hypervisor. Any instance-specific settings, such as hostname, admin user account, SSH key, networking etc. should be handled by some “contextualization tool” for the virtualization platform in hand (e.g. one-context for OpenNebula or tiny-cloud for public “clouds”). Setting the root password is a bad practice (for security reasons), better to use an SSH key, but these tools usually support even that.

brandonros commented 1 year ago

I wanted to use this library as a quick way to generate a VirtualBox .VDI (or whatever format is supports after whatever conversion process as per https://docs.oracle.com/en/virtualization/virtualbox/6.0/user/vdidetails.html) Alpine Linux image I could boot.

Basically a makeshift https://www.osboxes.org/ for Alpine.

sudo ./alpine-make-vm-image alpine.qcow2 -s 32G --image-format qcow2
qemu-img convert -O vdi alpine.qcow2 alpine.vdi

I had to do this because something about passing qemu-img vdi on its own just hung forever. Probably not worth us researching.

It's able to boot in VirtualBox (as expected), but you're saying there's no default user or password set whatsoever?

Ah, I see, it's root with no password for a default user. Thanks.

Not quite sure the purpose of my comment other than to back up the original user saying "that's what I assumed this library did without much extra configuration/maybe you could consider expanding this library to do the behavior described more easily".