<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/index.php?action=history&amp;feed=atom&amp;title=User_talk%3AJch%2FHow_to_automate_KVM_creation</id>
	<title>User talk:Jch/How to automate KVM creation - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/index.php?action=history&amp;feed=atom&amp;title=User_talk%3AJch%2FHow_to_automate_KVM_creation"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User_talk:Jch/How_to_automate_KVM_creation&amp;action=history"/>
	<updated>2026-04-26T08:33:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User_talk:Jch/How_to_automate_KVM_creation&amp;diff=10693&amp;oldid=prev</id>
		<title>Jch: Created page with &quot;  The goal is not only to have a working install but to have it at the after setup-alpine stage without human intervention... Tis is the first stages of a work in progress......&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User_talk:Jch/How_to_automate_KVM_creation&amp;diff=10693&amp;oldid=prev"/>
		<updated>2015-04-17T07:03:27Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;  The goal is not only to have a working install but to have it at the after setup-alpine stage without human intervention... Tis is the first stages of a work in progress......&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
The goal is not only to have a working install but to have it at the after setup-alpine stage without human intervention...&lt;br /&gt;
Tis is the first stages of a work in progress...&lt;br /&gt;
&lt;br /&gt;
I want to pass a Block Device and a name as parameters. The block device could be an image file, a LV, a NBD, a hdd, a raid array, whatever.&amp;lt;br/&amp;gt;&lt;br /&gt;
Everything else should be fully automatic according to some config file (stating the http-proxy, the time server, the log server, ...).&lt;br /&gt;
&lt;br /&gt;
The I will just run the script, watch my dhcp logs to discover the new IP assigned (that&amp;#039;s why the name is a parameter), then log in with ssh without password to customize it further but at high level only (will be a robot and not me in fact).&lt;br /&gt;
&lt;br /&gt;
I guess it would be something like emulate boot from usb key with specific overlay already on key... &amp;lt;br/&amp;gt;&lt;br /&gt;
then run setup-disk with proper parameters on the command line to avoid the interactive process (like setup-alpine does)... &amp;lt;br/&amp;gt;&lt;br /&gt;
Methink this could be done from a couple of scripts put in /etc/local.d/. The last.stop one deleting all of them to be clean at next reboot.&amp;lt;br/&amp;gt;&lt;br /&gt;
Let&amp;#039;s start easy ;)&lt;br /&gt;
&lt;br /&gt;
=== How to prepare a img file to emulate an USB key ===&lt;br /&gt;
&lt;br /&gt;
first a working example done in console (accessed trough ssh).&amp;lt;br/&amp;gt;&lt;br /&gt;
Will build a script from it...&lt;br /&gt;
&lt;br /&gt;
First, lets&amp;#039;s prepare somme block device (here an image file but could be something else) &amp;lt;pre&amp;gt;&lt;br /&gt;
apk add qemu-img&lt;br /&gt;
qemu-img create -f raw usbkey.img 512M&lt;br /&gt;
apk del qemu-img&lt;br /&gt;
T=&amp;quot;usbkey.img&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, let&amp;#039;s install AL on this $T &amp;lt;pre&amp;gt;&lt;br /&gt;
apk add multipath-tools syslinux dosfstools&lt;br /&gt;
fdisk $T&lt;br /&gt;
kpartx -av $T&lt;br /&gt;
mkdosfs -F32 /dev/mapper/loop1p1&lt;br /&gt;
dd if=/usr/share/syslinux/mbr.bin of=/dev/mapper/loop1&lt;br /&gt;
syslinux /dev/mapper/loop1p1&lt;br /&gt;
mkdir key&lt;br /&gt;
mount -t vfat /dev/mapper/loop1p1 key&lt;br /&gt;
wget http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.1/releases/x86_64/alpine-mini-3.1.1-x86_64.iso&lt;br /&gt;
mkdir cdrom&lt;br /&gt;
mount alpine-mini-3.1.1-x86_64.iso cdrom&lt;br /&gt;
cd cdrom&lt;br /&gt;
cp -a .alpine-release * ../key/&lt;br /&gt;
cd ..&lt;br /&gt;
umount key&lt;br /&gt;
umount cdrom&lt;br /&gt;
kpartx -d $T&lt;br /&gt;
apk del multipath-tools syslinux dosfstools&lt;br /&gt;
rm alpine-mini-3.1.1-x86_64.iso&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This block device may now be use to boot some KVM for instance like: &amp;lt;pre&amp;gt;&lt;br /&gt;
screen -d -m -S KVM-builder \&lt;br /&gt;
qemu-system-x86_64 -name KVM-usb -enable-kvm -cpu qemu64 -curses \&lt;br /&gt;
-device nec-usb-xhci -drive if=none,id=usbstick,file=$T -device usb-storage,drive=usbstick&lt;br /&gt;
&amp;lt;/pre&amp;gt; This is working fine.&lt;br /&gt;
&lt;br /&gt;
The problem is when adding a HDD to the lot, qemu try to boot from the hdd and does not even try to boot from the usb key. Enabling menu in boot let&amp;#039;s one access the emulated bios which allows to select USB device to boot interactively but this break the goal of fully automated boot :( The stanza is for instance &amp;lt;pre&amp;gt;&lt;br /&gt;
screen -d -m -S KVM-builder \&lt;br /&gt;
qemu-system-x86_64 -name KVM-usb -enable-kvm -cpu qemu64 -curses \&lt;br /&gt;
-device nec-usb-xhci -drive if=none,id=usbstick,file=$T -device usb-storage,drive=usbstick \&lt;br /&gt;
-drive file=$T2 boot menu=on&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
qemu-doc states that very clearly:&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;gt; -boot [order=drives][,once=drives][,menu=on|off][,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_timeout][,strict=on|off]&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;gt;   Specify boot order drives as a string of drive letters. Valid drive letters depend on the target achitecture. The x86 PC uses: a, b (floppy 1 and 2), c (first hard disk), d (first CD-ROM), n-p (Etherboot from network adapter 1-4), hard disk boot is the default&lt;/div&gt;</summary>
		<author><name>Jch</name></author>
	</entry>
</feed>