Differences between revisions 5 and 7 (spanning 2 versions)
Revision 5 as of 2021-07-15 01:17:26
Size: 1311
Editor: ThomasChung
Comment:
Revision 7 as of 2021-07-15 01:23:29
Size: 2416
Editor: ThomasChung
Comment: almost done
Deletions are marked like this. Additions are marked like this.
Line 24: Line 24:
{{{#!wiki tip
Line 28: Line 27:
}}}
Line 49: Line 46:
== Copy cloud image to default directory for libvirt == == Copy cloud image to images directory for libvirt ==
Line 54: Line 51:

== Create VM with import option ==

{{{
$ virt-install --import \
--connect qemu:///system \
--autostart \
--name d10c \
--os-variant debian10 \
--memory 2048 \
--vcpus 2 \
--disk /var/lib/libvirt/images/d10c.qcow2,bus=virtio \
--network default
}}}


== Login to VM ==

Make sure the VM is up-n-running
{{{
$ virsh dominfo d10c
Id: 76
Name: d10c
UUID: 5dbcd917-5984-42c2-86c5-75882a1d1216
OS Type: hvm
State: running
CPU(s): 2
CPU time: 12.3s
Max memory: 2097152 KiB
Used memory: 2097152 KiB
Persistent: yes
Autostart: enable
Managed save: no
Security model: apparmor
Security DOI: 0
Security label: libvirt-5dbcd917-5984-42c2-86c5-75882a1d1216 (enforcing)
}}}


Get the IP from the VM
{{{
$ virsh domifaddr d10c
Name MAC address Protocol Address
-------------------------------------------------------------------------------
 vnet11 52:54:00:36:28:f6 ipv4 192.168.122.161/24
}}}

Now, you can login with the password you've reset earlier
{{{
$ ssh d10c
}}}

How to import Cloud Image to Virtual Machines on Debian 10

THIS IS A WORK-IN-PROGRESS.

YOU MAY BE EXPECTED TO SEE A CONSTANT CHANGES FOR NEXT FEW HOURS.

Download the latest Debian 10 cloud image in qcow2 format

$ curl -L -O https://cloud.debian.org/images/cloud/buster/latest/debian-10-genericcloud-amd64.qcow2
$ du -sh *.qcow2
223M    debian-10-genericcloud-amd64.qcow2

Reset root password on cloud image

You can ignore warning

You system might not have install virt-customize

To install virt-customize:

$ sudo apt update
$ sudo apt install libguestfs-tools
$ which virt-customize
/usr/bin/virt-customize

To reset root password with virt-customize:

$ virt-customize -a debian-10-genericcloud-amd64.qcow2 --root-password password:debian
[   0.0] Examining the guest ...
[  22.9] Setting a random seed
virt-customize: warning: random seed could not be set for this type of
guest
[  23.0] Setting the machine ID in /etc/machine-id
[  23.0] Setting passwords
[  26.9] Finishing off

Copy cloud image to images directory for libvirt

$ sudo cp debian-10-genericcloud-amd64.qcow2 /var/lib/libvirt/images/d10c.qcow2

Create VM with import option

$ virt-install --import \
--connect qemu:///system \
--autostart \
--name d10c \
--os-variant debian10 \
--memory 2048 \
--vcpus 2 \
--disk /var/lib/libvirt/images/d10c.qcow2,bus=virtio \
--network default

Login to VM

Make sure the VM is up-n-running

$ virsh dominfo d10c
Id:             76
Name:           d10c
UUID:           5dbcd917-5984-42c2-86c5-75882a1d1216
OS Type:        hvm
State:          running
CPU(s):         2
CPU time:       12.3s
Max memory:     2097152 KiB
Used memory:    2097152 KiB
Persistent:     yes
Autostart:      enable
Managed save:   no
Security model: apparmor
Security DOI:   0
Security label: libvirt-5dbcd917-5984-42c2-86c5-75882a1d1216 (enforcing)

Get the IP from the VM

$ virsh domifaddr d10c
Name       MAC address          Protocol     Address
-------------------------------------------------------------------------------
 vnet11     52:54:00:36:28:f6    ipv4         192.168.122.161/24

Now, you can login with the password you've reset earlier

$ ssh d10c