2,187
edits
m (→Add Disk: Typo fix) |
(→Create Server (no GUI): Updated) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 43: | Line 43: | ||
=== Create Server (no GUI) === | === Create Server (no GUI) === | ||
Update | Update <code>location</code> path to reflect where your install ISO is located, and the <code>disk</code> path for where VM disk files are intended to be. | ||
The <code>--extra-args "console=ttyS0"</code> option allows a local console to be accessed from the host machine (to allow OS install etc before the VM is on a network), though note that it can't be used with <code>--cdrom</code>, so <code>--location</code> has been used instead. | The <code>--extra-args "console=ttyS0"</code> option allows a local console to be accessed from the host machine (to allow OS install etc before the VM is on a network), though note that it can't be used with <code>--cdrom</code>, so <code>--location</code> has been used instead. Note that where installing Ubuntu guests v22.04 and upwards the kernel and initrd paths on the ISO need to be specified with the ISO location. | ||
<pre> | <pre> | ||
virt-install \ | virt-install \ | ||
--virt-type=kvm \ | --virt-type=kvm \ | ||
--name | --name ubuntu22-vm \ | ||
--ram | --ram 2048 \ | ||
--vcpus=1 \ | --vcpus=1 \ | ||
--os-variant=ubuntu16.04 \ | --os-variant=ubuntu16.04 \ | ||
--network=bridge=br0,model=virtio \ | --network=bridge=br0,model=virtio \ | ||
--graphics none \ | --graphics none \ | ||
--disk path=/mnt/md0/kvm/vm/ | --disk path=/mnt/md0/kvm/vm/ubuntu22-vm.img,size=20,bus=virtio \ | ||
--extra-args "console=ttyS0" \ | --extra-args "console=ttyS0" \ | ||
--location | --location ubuntu-22.04-live-server-amd64.iso,kernel=casper/vmlinuz,initrd=casper/initrd | ||
</pre> | </pre> | ||
You should be presented with the console of the VM as it installs, however if you lose connection etc, connect to the console of the server using <code>virsh console <server-name></code>. Make sure you set a static IP and install SSH during setup (select '''OpenSSH server''' during ''Software selection'' section). Once installation is completed, SSH to the server and setup normal console access (as the instructions in the section below). Its highly recommended that you follow the steps below to ensure that Console access is available via the KVM host if needed. | You should be presented with the console of the VM as it installs, however if you lose connection etc, connect to the console of the server using <code>virsh console <server-name></code>. Make sure you set a static IP and install SSH during setup (select '''OpenSSH server''' during ''Software selection'' section). Once installation is completed, SSH to the server and setup normal console access (as the instructions in the section below). Its highly recommended that you follow the steps below to ensure that Console access is available via the KVM host if needed. | ||
==== Eject CD-ROM ==== | |||
If you need to eject the CD-ROM towards the end o the installation process, first identify the disk target name (eg hda, hdb, etc) then eject | |||
virsh edit server-name | |||
virsh change-media server-name hda --eject | |||
==== Console Access ==== | ==== Console Access ==== | ||
Line 83: | Line 88: | ||
--cdrom=/mnt/md0/kvm/iso/ubuntu-16.04.3-desktop-amd64.iso \ | --cdrom=/mnt/md0/kvm/iso/ubuntu-16.04.3-desktop-amd64.iso \ | ||
--network=bridge=br0,model=virtio \ | --network=bridge=br0,model=virtio \ | ||
--graphics vnc \ | --graphics vnc,listen=0.0.0.0 \ | ||
--disk path=/mnt/md0/kvm/vm/ubuntu-desktop.img,size=40,bus=virtio | --disk path=/mnt/md0/kvm/vm/ubuntu-desktop.img,size=40,bus=virtio | ||
</pre> | </pre> | ||
Once the command has got as far as <code>Waiting for installation to complete.</code> you need to connect to the VNC console session, to find the port number to connect on query the config from | Once the command has got as far as <code>Waiting for installation to complete.</code> you need to connect to the VNC console session, to find the port number to connect on query the config from ''another'' SSH session connected to the host (typically VNC uses ports starting from 5900 upwards). Cancelling the command causes the VM/domain to power off, which you won't want to happen until you've completed setup of the VM. | ||
virsh dumpxml ubuntu-desktop | grep vnc | virsh dumpxml ubuntu-desktop | grep vnc | ||
Line 144: | Line 149: | ||
To disable issue | To disable issue | ||
virsh autostart vm-name --disable | virsh autostart vm-name --disable | ||
To see what machines are/aren't set to start automatically | |||
virsh list --all --autostart | |||
virsh list --all --no-autostart | |||
[[Category:KVM]] | [[Category:KVM]] |