docs: add README

This commit is contained in:
Matthieu Bessat 2023-12-20 00:37:02 +01:00
parent cb910c5186
commit 0fddf32bc5
3 changed files with 48 additions and 4 deletions

42
README.md Normal file
View file

@ -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/

View file

@ -1,11 +1,9 @@
#!/usr/bin/bash #!/usr/bin/bash
qemu-system-x86_64 \ qemu-system-x86_64 \
-accel kvm \ -accel kvm \
-hda ./snapshot_02_working.img.qcow \ -hda ./main.qcow \
-cpu host \ -cpu host \
-m 2048 \ -m 2048 \
-nographic \ -nographic \
-net user,hostfwd=tcp::42022-:22,hostfwd=tcp::42080-:80,hostfwd=tcp::42043-:443 \ -net user,hostfwd=tcp::42022-:22,hostfwd=tcp::42080-:80,hostfwd=tcp::42043-:443 \
-net nic -net nic
# foobaristhebestpassword

View file

@ -4,11 +4,13 @@
mkdir -p machines/machine01.local mkdir -p machines/machine01.local
ln -f -s $(pwd)/files_to_serve/ ./machines/machine01.local/files_to_serve
mkdir machines/machine01.local/tftp_container mkdir machines/machine01.local/tftp_container
wget \ wget \
-O ./machines/machine01.local/tftp_container/netboot.tar.gz \ -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/ 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 ./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 cp ./debian_install_config_default ./machines/machine01.local/tftp_container/debian-installer/amd64/pxelinux.cfg/default