From 2c7f60267ce5ad29cbc0473c9d26b0682621c3bf Mon Sep 17 00:00:00 2001 From: Ste Vaidis Date: Tue, 20 Aug 2024 09:00:42 +0300 Subject: [PATCH 1/8] Add 0.KVM --- 0.KVM | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 0.KVM diff --git a/0.KVM b/0.KVM new file mode 100644 index 0000000..7834dd9 --- /dev/null +++ b/0.KVM @@ -0,0 +1,7 @@ + + +Convert the existing disk in a new dynamic size disk + +```bash +qemu-img convert -f qcow2 -O qcow2 -o preallocation=off old.qcow2 new.qcow2 +``` From 8c0b418a7f6c624e9117f04dca14049e98bf99be Mon Sep 17 00:00:00 2001 From: Ste Vaidis Date: Tue, 20 Aug 2024 09:00:52 +0300 Subject: [PATCH 2/8] Update 0.KVM.md --- 0.KVM => 0.KVM.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 0.KVM => 0.KVM.md (100%) diff --git a/0.KVM b/0.KVM.md similarity index 100% rename from 0.KVM rename to 0.KVM.md From f9d58dfe00463baabf3c3e7d4419c75147bc951f Mon Sep 17 00:00:00 2001 From: Ste Vaidis Date: Tue, 20 Aug 2024 09:09:05 +0300 Subject: [PATCH 3/8] Update 0.KVM.md --- 0.KVM.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/0.KVM.md b/0.KVM.md index 7834dd9..3a3097c 100644 --- a/0.KVM.md +++ b/0.KVM.md @@ -1,6 +1,33 @@ +# Create +```bash +sudo virt-install \ +--name Rocky_Linux_Dev \ +--ram 4096 \ +--vcpus 4 \ +--os-type linux \ +--os-variant rhel9-unknown \ +--import \ +--disk path=/mnt/KVM/linux.qcow2,format=qcow2 \ +--network bridge=virbr0,model=virtio \ +--graphics vnc,listen=0.0.0.0 +``` -Convert the existing disk in a new dynamic size disk +# Permissions + +```bash +sudo chown -R libvirt-qemu:kvm /media/KVM +sudo chmod 750 /media/KVM +sudo chmod 640 /media/KVM/linux.qcow2 +``` + +Options like noexec, nosuid, or nodev that might be restricting access. + +```bash +mount | grep /media/ste/282d1750-fabe-4bb6-8c14-bba01e67a260 +``` + +# Convert disk in a new dynamic size disk ```bash qemu-img convert -f qcow2 -O qcow2 -o preallocation=off old.qcow2 new.qcow2 From cee76f3d41129b97d526eeecab1de8ba52585e9a Mon Sep 17 00:00:00 2001 From: Ste Vaidis Date: Tue, 20 Aug 2024 09:09:56 +0300 Subject: [PATCH 4/8] Update 0.KVM.md --- 0.KVM.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/0.KVM.md b/0.KVM.md index 3a3097c..46f4b2e 100644 --- a/0.KVM.md +++ b/0.KVM.md @@ -24,7 +24,7 @@ sudo chmod 640 /media/KVM/linux.qcow2 Options like noexec, nosuid, or nodev that might be restricting access. ```bash -mount | grep /media/ste/282d1750-fabe-4bb6-8c14-bba01e67a260 +mount | grep /media/ ``` # Convert disk in a new dynamic size disk From 215d18138a5ce37210cdfcaa38a3362afe63022b Mon Sep 17 00:00:00 2001 From: Ste Vaidis Date: Tue, 20 Aug 2024 09:10:06 +0300 Subject: [PATCH 5/8] Update 0.KVM.md --- 0.KVM.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/0.KVM.md b/0.KVM.md index 46f4b2e..2e42b94 100644 --- a/0.KVM.md +++ b/0.KVM.md @@ -24,7 +24,7 @@ sudo chmod 640 /media/KVM/linux.qcow2 Options like noexec, nosuid, or nodev that might be restricting access. ```bash -mount | grep /media/ +mount | grep /media ``` # Convert disk in a new dynamic size disk From 7af3235e99c26129284f219d8941bf78ed00ea3c Mon Sep 17 00:00:00 2001 From: Ste Vaidis Date: Tue, 20 Aug 2024 09:18:11 +0300 Subject: [PATCH 6/8] Update 0.KVM.md --- 0.KVM.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/0.KVM.md b/0.KVM.md index 2e42b94..8e24868 100644 --- a/0.KVM.md +++ b/0.KVM.md @@ -32,3 +32,17 @@ mount | grep /media ```bash qemu-img convert -f qcow2 -O qcow2 -o preallocation=off old.qcow2 new.qcow2 ``` + +# Free up space + +```bash +dd if=/dev/zero of=/zerofile bs=1M +sync +rm -f /zerofile +sync +shutdown -h now +``` + +```bash +qemu-img convert -O qcow2 /original.qcow2 /compact.qcow2 +``` \ No newline at end of file From 50f1ab42365522ab96aa393f3bc741c7f240e345 Mon Sep 17 00:00:00 2001 From: Ste Vaidis Date: Tue, 20 Aug 2024 13:03:04 +0300 Subject: [PATCH 7/8] Update 0.KVM.md --- 0.KVM.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/0.KVM.md b/0.KVM.md index 8e24868..df5001b 100644 --- a/0.KVM.md +++ b/0.KVM.md @@ -21,7 +21,7 @@ sudo chmod 750 /media/KVM sudo chmod 640 /media/KVM/linux.qcow2 ``` -Options like noexec, nosuid, or nodev that might be restricting access. +Options like `noexec`, `nosuid`, or `nodev` that might be restricting access. ```bash mount | grep /media From e0c6a0ccc8e3a6a56c62dfb1fc14595f50eee409 Mon Sep 17 00:00:00 2001 From: Ste Vaidis Date: Tue, 20 Aug 2024 14:15:18 +0300 Subject: [PATCH 8/8] Update 0.KVM.md --- 0.KVM.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/0.KVM.md b/0.KVM.md index df5001b..0fa9535 100644 --- a/0.KVM.md +++ b/0.KVM.md @@ -13,6 +13,38 @@ sudo virt-install \ --graphics vnc,listen=0.0.0.0 ``` +# Info + +```bash +virsh list # show running +virsh list --all # show all +virsh domstate Rock_Linux_9 # show single status +virsh dominfo Rock_Linux_9 # show single settings +``` + +# Manage + +```bash +virsh start Rock_Linux_9 +virsh reboot Rock_Linux_9 +virsh shutdown Rock_Linux_9 # soft shutdown +virsh destroy Rock_Linux_9 # hard shutdown +virsh suspend Rock_Linux_9 +virsh resume Rock_Linux_9 +virsh save Rock_Linux_9 # save ram to state file +virsh restore Rock_Linux_9 # load ram from state file +virsh snapshot-create Rock_Linux_9 +``` + +# Snapshots +```bash +virsh snapshot-create Rock_Linux_9 +virsh snapshot-list Rock_Linux_9 +virsh snapshot-revert Rock_Linux_9 +virsh snapshot-delete Rock_Linux_9 +virsh snapshot-edit Rock_Linux_9 # Edit snapshots for updating filepath +``` + # Permissions ```bash