From 0fddf32bc5dd7d4b8f2551c54aac003809564287 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Wed, 20 Dec 2023 00:37:02 +0100 Subject: [PATCH] docs: add README --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ run_usernet.sh | 4 +--- setup_workspace.sh | 6 +++++- 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4d405d8 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# Debian vm auto setup + +Install a debian headless virtual-machine from scratch with netboot in a QEMU environment + +## requirements + +- QEMU + KVM +- tmux +- bash +- python3 (for http server) +- telnet or netcat (to transmit logs) + +## Getting started + +``` +./setup_workspace.sh +cd machines/machine01.local/ +./install_machine.sh +``` + +then on a client, connect to ssh via the port forwarding (in user mode network) +``` +ssh -o StrictHostKeyChecking=no -p 42022 root@localhost +``` + +## troubleshooting + +kill qemu: pkill -f qemu-system-x86_64 + +## TODO + +- find a better way to kill qemu + +## preseed file + +Change this line to add initial packages. + +`d-i pkgsel/include string binfmt-support debian-keyring openssh-server qemu-user-static` + +## inspiration + +https://sigmaris.info/blog/2019/04/automating-debian-install-qemu/ diff --git a/run_usernet.sh b/run_usernet.sh index 3e8e28f..f2a6482 100755 --- a/run_usernet.sh +++ b/run_usernet.sh @@ -1,11 +1,9 @@ #!/usr/bin/bash qemu-system-x86_64 \ -accel kvm \ - -hda ./snapshot_02_working.img.qcow \ + -hda ./main.qcow \ -cpu host \ -m 2048 \ -nographic \ -net user,hostfwd=tcp::42022-:22,hostfwd=tcp::42080-:80,hostfwd=tcp::42043-:443 \ -net nic - -# foobaristhebestpassword diff --git a/setup_workspace.sh b/setup_workspace.sh index a102611..6e79ebf 100755 --- a/setup_workspace.sh +++ b/setup_workspace.sh @@ -4,11 +4,13 @@ mkdir -p machines/machine01.local +ln -f -s $(pwd)/files_to_serve/ ./machines/machine01.local/files_to_serve + mkdir machines/machine01.local/tftp_container wget \ -O ./machines/machine01.local/tftp_container/netboot.tar.gz \ - https://ftp.debian.org/debian/dists/bookworm/main/installer-amd64/20230607/images/netboot/netboot.tar.gz + https://deb.debian.org/debian/dists/bookworm/main/installer-amd64/20230607/images/netboot/netboot.tar.gz tar -xzvf ./machines/machine01.local/tftp_container/netboot.tar.gz -C ./machines/machine01.local/tftp_container/ @@ -17,4 +19,6 @@ qemu-img create -f qcow2 ./machines/machine01.local/main.qcow 5G cp ./install_machine.sh ./machines/machine01.local/ +cp ./run_usernet.sh ./machines/machine01.local/run.sh + cp ./debian_install_config_default ./machines/machine01.local/tftp_container/debian-installer/amd64/pxelinux.cfg/default