summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUGS0
-rw-r--r--LINKS27
-rw-r--r--README100
-rw-r--r--TODOS10
-rwxr-xr-xarchauto.sh116
-rwxr-xr-xcreatevm.sh56
-rw-r--r--tftproot/README1
-rw-r--r--tftproot/boot/i686/.placeholder0
-rw-r--r--tftproot/pxelinux.cfg/01-52-54-00-12-34-5616
9 files changed, 326 insertions, 0 deletions
diff --git a/BUGS b/BUGS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/BUGS
diff --git a/LINKS b/LINKS
new file mode 100644
index 0000000..79aa9a2
--- /dev/null
+++ b/LINKS
@@ -0,0 +1,27 @@
+Links
+-----
+
+https://wiki.archlinux.org/index.php/Archiso
+https://wiki.archlinux.org/index.php/PXE
+https://wiki.archlinux.org/index.php/Archiso_as_pxe_server
+https://kroweer.wordpress.com/2011/09/07/creating-a-custom-arch-linux-live-usb/
+http://pxeknife.erebor.org/
+https://github.com/altercation/archblocks
+https://bbs.archlinux.org/viewtopic.php?id=149597
+https://github.com/jdodds/aif
+https://wiki.archlinux.org/index.php/Autostarting
+https://wiki.archlinux.org/index.php/Automatic_login_to_virtual_console
+https://wiki.archlinux.org/index.php/Official_Arch_Linux_Install_Guide
+https://bbs.archlinux.org/viewtopic.php?id=148790 (text mode boot from archiso)
+http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=How_to_run_OVMF (UEFI BIOS)
+https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/X64/Shell_Full.efi
+https://wiki.archlinux.org/index.php/GRUB2
+http://www.brianparsons.net/Best-Practices-For-Using-Arch-Linux-on-Servers/
+
+Other projects
+--------------
+https://github.com/roman-neuhauser/anarchinst
+
+virt-install for various platforms
+----------------------------------
+https://raymii.org/s/articles/virt-install_introduction_and_copy_paste_distro_install_commands.html
diff --git a/README b/README
new file mode 100644
index 0000000..e242566
--- /dev/null
+++ b/README
@@ -0,0 +1,100 @@
+wget archlinux-2017.08.01-i686.iso
+mkdir cdrom
+mount -o loop archlinux-2017.08.01-i686.iso cdrom
+
+wget -m mirror.archlinux32.org
+
+mv mirror.archlinux32.org mirror
+
+TODO FROM HERE:
+
+
+
+# We mount it and make it accessible over the 'darkhttpd' webserver:
+
+
+TFTP root (for PXE boot)
+---------
+
+# Copy PXE bootstrap files to a TFTP root:
+
+cp archiso/arch/boot/i686/vmlinuz tftproot/boot/i686/
+cp archiso/arch/boot/i686/archiso.img tftproot/boot/i686/
+
+cp /usr/share/syslinux/pxelinux.0 tftproot/
+cp /usr/share/syslinux/linux.c32 tftproot/
+
+Local kernel and RAMdisk (for libvirt direct kernel boot)
+------------------------
+
+cp archiso/arch/boot/i686/vmlinuz .
+cp archiso/arch/boot/i686/archiso.img .
+
+Install Archlinux (PXE and qemu directly)
+-----------------
+
+Create a Qemu image with Archlinux (automatically). The main
+work is done by the 'archauto.sh' script which is given to
+the archiso kernel as script to execute after auto-login:
+
+qemu-img create arch32.img 2G
+
+qemu-system-i386 -drive file=arch32.img,index=0,media=disk,format=raw,if=virtio -net nic \
+ -enable-kvm \
+ -net user,id=net0,net=192.168.130.2/24,host=192.168.130.1,tftp=$PWD/tftproot,bootfile=pxelinux.0 \
+ -m 2048 \
+ -machine accel=kvm -redir tcp:2222::22
+
+# fails somehow to start script
+# 10.0.2.0 network is quite stuborn, how to set explicitely?
+# -nographic -serial mon:stdio \
+
+qemu-system-i386 -drive file=arch32.img,index=0,media=disk,format=raw,if=virtio -net nic \
+ -enable-kvm \
+ -net user,id=net0,net=192.168.130.2/24,host=192.168.130.1 \
+ -m 2048 \
+ -machine accel=kvm -redir tcp:2222::22
+
+Install Archlinux (libvirtd and virt-install)
+-----------------
+
+There are quite some steps here, so they are wrapped into a shell script:
+
+./createvm.sh
+
+TODOs
+-----
+
+# remote install (manually), then follow docu
+# (this gives a rough idea of what should be automatized)
+#passwd
+#systemctl start sshd
+#sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
+
+# automatic installation frameworks for ArchLinux
+# - AIF
+# - ArchBlocks
+# - ArchBang
+# - backpac: snapshots, not really the cfengine philosophy
+# load them after boot of base system or customize the installation medium?
+
+# EFI, later
+# wget 'http://wiki.qemu.org/download/efi-bios.tar.bz2'
+# qemu with efi
+# efi partition etc
+
+# manual minimal installation or "what's needed in a CFengine bootstrap
+# script"?
+# - boot loader
+# - grub2
+# - virtio ramdisk hooks
+# - partitioning
+# - sgdisk scripting (ArchBlocks does it nicely)
+# - RAID, LVM, LUKS and friends
+# - size, swap, filesystem, chunking
+# - file system layout
+
+# via cfengine
+
+# packages net-tools gdisk
+
diff --git a/TODOS b/TODOS
new file mode 100644
index 0000000..c372ef7
--- /dev/null
+++ b/TODOS
@@ -0,0 +1,10 @@
+- SigLevel = Newer, because we have a problem to distribute AUR
+ packages signed (own server for software distribution, but
+ then we hav to fiddle with the keyring of pacman)
+- minimal set of cfengine rules, in a readonly/protected git server,
+ the main point of administration
+- local mirrors, not for speed, but for controlled update
+ => script to keep only the necessary files in sync, not more
+- libvirt or qemu
+- how to change names of machines?
+- how to make clones?
diff --git a/archauto.sh b/archauto.sh
new file mode 100755
index 0000000..20ec948
--- /dev/null
+++ b/archauto.sh
@@ -0,0 +1,116 @@
+#!/bin/bash
+
+# configuration
+
+INSTALL_DRIVE=/dev/vda
+PARTITION_BOOT=1
+PARTITION_ROOT=2
+LABEL_ROOT=ROOT
+MOUNT_PATH=/mnt
+HOST=192.168.130.1
+HTTP_SERVER=http://${HOST}:8080
+IP=192.168.130.2
+NETMASK=255.255.255.0
+PREFIX=24
+HOSTNAME=arch32
+
+# create early SSH access
+
+echo 'root:xx' | chpasswd
+echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
+systemctl start sshd
+
+echo "Partitioning and creating filesystem.."
+
+mknod /dev/vda b 254 0
+mknod /dev/vda1 b 254 1
+mknod /dev/vda2 b 254 2
+
+wipefs -a ${INSTALL_DRIVE}
+
+printf ",128M,L,*\n" | /sbin/sfdisk -f ${INSTALL_DRIVE}
+printf ",,L,*\n" | /sbin/sfdisk -a -f ${INSTALL_DRIVE}
+
+mkfs.ext2 ${INSTALL_DRIVE}${PARTITION_BOOT}
+mkfs.ext4 ${INSTALL_DRIVE}${PARTITION_ROOT}
+
+mount ${INSTALL_DRIVE}${PARTITION_ROOT} ${MOUNT_PATH}
+mkdir ${MOUNT_PATH}/boot
+mount ${INSTALL_DRIVE}${PARTITION_BOOT} ${MOUNT_PATH}/boot
+
+echo "Patching pacman to play locally.."
+
+cat >/etc/pacman.d/mirrorlist <<EOF
+Server = ${HTTP_SERVER}/mirror/\$arch/\$repo
+EOF
+
+echo "Installing keyring for ArchLinux32."
+
+sed -i 's/^SigLevel.*/SigLevel = Never/g' /etc/pacman.conf
+pacman --noconfirm -Syyw archlinux32-keyring
+sed -i 's/^SigLevel.*/SigLevel = Required DatabaseOptional/g' /etc/pacman.conf
+pacman --noconfirm -U /var/cache/pacman/pkg/archlinux32-keyring-*.pkg.tar.xz
+
+echo "Installing minimalistic base system.."
+
+pacstrap ${MOUNT_PATH} filesystem grep findutils coreutils glibc bash pacman \
+ mkinitcpio linux dhcpcd systemd sed systemd-sysvcompat
+
+echo "Patching pacman in chroot to play locally.."
+
+cat >${MOUNT_PATH}/etc/pacman.d/mirrorlist <<EOF
+Server = ${HTTP_SERVER}/mirror/\$arch/\$repo
+EOF
+
+echo "Test if we can update the system inside chroot."
+
+arch-chroot ${MOUNT_PATH} pacman -Syyu
+
+echo "Install /etc/fstab"
+genfstab -L -p ${MOUNT_PATH} > ${MOUNT_PATH}/etc/fstab
+
+echo "Installing boot loader.."
+
+arch-chroot ${MOUNT_PATH} pacman --noconfirm -S grub
+arch-chroot ${MOUNT_PATH} grub-mkconfig -o /boot/grub/grub.cfg
+arch-chroot ${MOUNT_PATH} grub-install --force /dev/vda
+
+echo "Configuring base system.."
+
+sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' ${MOUNT_PATH}/etc/locale.gen
+arch-chroot ${MOUNT_PATH} locale-gen
+echo LANG=en_US.UTF-8 > ${MOUNT_PATH}/etc/locale.conf
+
+ln -fs /usr/share/zoneinfo/Europe/Zurich ${MOUNT_PATH}/etc/localtime
+arch-chroot ${MOUNT_PATH} hwclock --systohc --utc
+
+echo ${HOSTNAME} > ${MOUNT_PATH}/etc/hostname
+
+cat > ${MOUNT_PATH}/etc/systemd/network/25-wired.network <<EOF
+[Match]
+Name=ens3
+
+[Network]
+Address=${IP}/${PREFIX}
+Gateway=${HOST}
+EOF
+
+arch-chroot ${MOUNT_PATH} systemctl enable systemd-networkd
+arch-chroot ${MOUNT_PATH} systemctl enable systemd-resolved
+
+arch-chroot ${MOUNT_PATH} sh -c "echo 'root:xx' | chpasswd"
+
+arch-chroot ${MOUNT_PATH} pacman --noconfirm -S openssh
+echo "PermitRootLogin yes" >>${MOUNT_PATH}/etc/ssh/sshd_config
+arch-chroot ${MOUNT_PATH} systemctl enable sshd
+
+echo "Unmounting.."
+
+umount ${MOUNT_PATH}/boot
+umount ${MOUNT_PATH}
+
+echo "Powering off.."
+
+sleep 10
+
+systemctl poweroff
diff --git a/createvm.sh b/createvm.sh
new file mode 100755
index 0000000..f84e998
--- /dev/null
+++ b/createvm.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+# configuration
+
+NAME=arch32
+HOST=192.168.130.1
+NETMASK=255.255.255.0
+PREFIX=24
+CLIENT=192.168.130.2
+
+vm_is_running() {
+ if [ "$(virsh domstate $1 2>/dev/null)" == "running" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+wait_for_vm_to_stop() {
+ while vm_is_running $1; do
+ sleep 1
+ done
+}
+
+mount -o loop,ro archlinux-2017.08.01-i686.iso archiso
+
+cp archiso/arch/boot/i686/vmlinuz .
+cp archiso/arch/boot/i686/archiso.img .
+
+darkhttpd . --port 8080 &
+
+virt-install --name ${NAME} -r 2048 --vcpus=1 --os-type=linux --os-variant=virtio26 \
+ --disk pool=default,size=2,format=qcow2 --network bridge=br0,model=virtio \
+ --vnc --vncport=5901 --noreboot \
+ --boot kernel=vmlinuz,initrd=archiso.img,kernel_args="archisobasedir=archiso/arch archiso_http_srv=http://${HOST}:8080/ script=http://${HOST}:8080/archauto.sh ip=${CLIENT}:::${NETMASK}:arch32::off nomodeset i915.modeset=0" &
+# --noautoconsole
+sleep 5
+
+virsh start ${NAME}
+
+sleep 5
+
+wait_for_vm_to_stop ${NAME}
+
+virsh dumpxml ${NAME} > ${NAME}.xml
+
+xmlstarlet ed -d '/domain/os/kernel' ${NAME}.xml | xmlstarlet ed -d '/domain/os/initrd' | xmlstarlet ed -d '/domain/os/cmdline' > ${NAME}-new.xml
+
+virsh define ${NAME}-new.xml
+
+virsh start ${NAME}
+
+rm -f ${NAME}-new.xml ${NAME}.xml
+
+pkill darkhttpd
+umount archiso
diff --git a/tftproot/README b/tftproot/README
new file mode 100644
index 0000000..da0f89a
--- /dev/null
+++ b/tftproot/README
@@ -0,0 +1 @@
+The root of the TFTP server (embedded or real/standalone)
diff --git a/tftproot/boot/i686/.placeholder b/tftproot/boot/i686/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tftproot/boot/i686/.placeholder
diff --git a/tftproot/pxelinux.cfg/01-52-54-00-12-34-56 b/tftproot/pxelinux.cfg/01-52-54-00-12-34-56
new file mode 100644
index 0000000..4605ffa
--- /dev/null
+++ b/tftproot/pxelinux.cfg/01-52-54-00-12-34-56
@@ -0,0 +1,16 @@
+SAY Archlinux32 automatic installation..
+TIMEOUT 10
+
+DEFAULT arch32
+
+SERIAL 0 9600 0x303
+
+LABEL arch32
+TEXT HELP
+Install Arch Linux (32-bit) automatically
+ENDTEXT
+MENU LABEL Boot Arch Linux (32-bit)
+LINUX boot/i686/vmlinuz
+INITRD boot/i686/archiso.img
+APPEND archisobasedir=archiso/arch archisobasedir=archiso/arch archiso_http_srv=http://192.168.130.1:8080/ script=http://192.168.130.1:8080/archauto.sh ip=192.168.130.2:::255.255.255.0:arch32::off nomodeset i915.modeset=0 console=ttyS0,9600n8
+IPAPPEND 3