Skip to content

Instantly share code, notes, and snippets.

@jshen28
Created September 12, 2019 06:12
Show Gist options
  • Save jshen28/44b26799820838c38f54b15ff28dd9dd to your computer and use it in GitHub Desktop.
Save jshen28/44b26799820838c38f54b15ff28dd9dd to your computer and use it in GitHub Desktop.
ISO_FILE ?= ubuntu.iso
VM_NAME ?= vm06
PATH_TO_HDD ?= $(PWD)/$(VM_NAME).qcow2
.PHONY: mkiso
run: $(VM_NAME).qcow2
/usr/bin/qemu-system-x86_64 \
-m 1024 \
-vnc 0.0.0.0:41 \
-smp 1 \
-machine type=pc,accel=kvm \
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=fa:16:3e:b3:bf:7f,bus=pci.0,addr=0x3 \
-netdev tap,id=hostnet0,vhost=on \
-drive file=$(PATH_TO_HDD) \
-cdrom $(PWD)/test.iso \
-boot once=d \
-name $(VM_NAME)
$(VM_NAME).qcow2: mkiso
qemu-img create -f qcow2 $@ 30g
mkiso:
mkdir tmp mnt;
mount -o ro $(ISO_FILE) $(PWD)/mnt;
rsync -av $(PWD)/mnt $(PWD)/tmp;
cp $(PWD)/custom.seed $(PWD)/tmp/mnt/preseed/;
cp $(PWD)/isolinux.cfg $(PWD)/tmp/mnt/isolinux/;
mkisofs -r -V "UBUNTUSEED" \
-cache-inodes \
-J -l -b isolinux/isolinux.bin \
-c isolinux/boot.cat -no-emul-boot \
-boot-load-size 4 -boot-info-table \
-input-charset utf-8 -quiet \
-o $(PWD)/test.iso $(PWD)/tmp/mnt;
umount $(PWD)/mnt;
rm -rf $(PWD)/tmp $(PWD)/mnt;
@jshen28
Copy link
Author

jshen28 commented Oct 1, 2019

timeout 10
default install
label install
menu label ^Install Ubuntu Server
kernel /install/vmlinuz
append file=/cdrom/preseed/custom.seed netcfg/choose_interface=ens3 hostname=ubuntu auto=true debian-installer/locale=en_US.UTF-8 localechooser/preferred-locale=en_US.UTF8 debian-installer/country=NL keyboard-configuration/layoutcode=us preseed/interactive=false console-setup/layoutcode=us mirror/country=cn mirror/http/proxy= mirror/http/mirror=cn.archive.ubuntu.com console-setup/ask_detect=false vga=788 netcfg/do_not_use_netplan=true initrd=/install/initrd.gz quiet ---
label hwe-install
menu label ^Install Ubuntu Server with the HWE kernel
kernel /install/hwe-vmlinuz
append file=/cdrom/preseed/hwe-ubuntu-server.seed vga=788 initrd=/install/hwe-initrd.gz quiet ---
label maas
menu label ^Install MAAS Region Controller
kernel /install/vmlinuz
append modules=maas-region-udeb vga=788 initrd=/install/initrd.gz quiet ---

label maasrack
menu label ^Install MAAS Rack Controller
kernel /install/vmlinuz
append modules=maas-rack-udeb vga=788 initrd=/install/initrd.gz quiet ---
label check
menu label ^Check disc for defects
kernel /install/vmlinuz
append MENU=/bin/cdrom-checker-menu vga=788 initrd=/install/initrd.gz quiet ---
label memtest
menu label Test ^memory
kernel /install/mt86plus
label hd
menu label ^Boot from first hard disk
localboot 0x80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment