Last active
April 27, 2021 14:37
-
-
Save jdmichaud/61ad403636c38719b9873d60d249f11a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| On a Ubuntu 19.04 | |
| ## Install the necessary package: | |
| ``` | |
| sudo apt-get install \ | |
| qemu-kvm \ | |
| libvirt-daemon-system \ | |
| libvirt-clients \ | |
| bridge-utils \ | |
| libosinfo-bin \ | |
| libguestfs-tools | |
| ``` | |
| ## Download the ISO to: | |
| ``` | |
| /var/lib/libvirt/boot | |
| ``` | |
| Do not use a live-cd ISO. Use a proper installation ISO. | |
| ## To manipulate VMs (create/remove) | |
| ``` | |
| sudo virsh list --all | |
| sudo destroy vm-name | |
| sudo undefined vm-name | |
| ``` | |
| Beware, not using `sudo` will show you a different VM list. | |
| ## Install a ubuntu server installation ISO: | |
| ``` | |
| sudo virt-install --name=ubuntu-server-19.10 \ | |
| --memory=16384 --vcpus=8 --cpu host --hvm \ | |
| --os-variant=ubuntu19.10 \ | |
| --location /var/lib/libvirt/boot/ubuntu-19.10-server-amd64.iso \ | |
| --disk /var/lib/libvirt/images/ubuntu-server-19.10.img,size=10,device=disk,bus=virtio \ | |
| --graphics none \ | |
| --network default \ | |
| --extra-args 'console=ttyS0' \ | |
| --unattended profile=jeos,user-password-file=/home/jd/pass | |
| ``` | |
| Edit grub to add a console access: | |
| ``` | |
| sudo virt-edit -d ubuntu-server-19.10 /boot/grub/grub.cfg | |
| ``` | |
| And to the line | |
| ``` | |
| linux ..... | |
| ``` | |
| append: | |
| ``` | |
| linux ..... console=ttyS0,115200n8 text | |
| ``` | |
| When you boot the wait a while and: | |
| ``` | |
| sudo virsh console vm-name | |
| ``` | |
| To permanently change the hostname of your machine (ubuntu) | |
| ``` | |
| sudo hostnamectl set-hostname newNameHere | |
| ``` | |
| To connect using ssh, to get the IP address of your VM: | |
| ``` | |
| virsh net-dhcp-leases default | |
| ``` | |
| Then connect as usual on port 22. | |
| Don't forget to configure PROXY envs and `alias sudo=sudo -E` | |
| ## To forward a port: | |
| https://wiki.libvirt.org/page/Networking#Forwarding_Incoming_Connections | |
| This will involve [fixing your IP address to a static IP](https://aboullaite.me/kvm-qemo-forward-ports-with-iptables/). | |
| Then [configuring a qemu hook to setup iptable forwardning](https://wiki.libvirt.org/page/Networking#Forwarding_Incoming_Connections) | |
| ## To prepare your VM for docker: | |
| Install utils: | |
| ``` | |
| sudo apt-get install \ | |
| curl \ | |
| git | |
| ``` | |
| Install docker: follow https://docs.docker.com/engine/install/ubuntu/ | |
| Docker and proxy: https://docs.docker.com/config/daemon/systemd/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment