Difference between revisions of "Virt-resize"

From wikieduonline
Jump to navigation Jump to search
 
(34 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Draft}}
+
{{lc}}
 +
<code>virt-resize</code> - Resize a virtual machine disk https://linux.die.net/man/1/virt-resize
  
 +
== Example ==
  
== Example ==
+
Reference: http://wiki.docking.org/index.php/To_resize_a_virtual_drive
<code>cp my_machine.qcow2 my_machine-ORIGIN.qcow2</code>
 
<code>virt-resize --expand /dev/sda4 my_machine-ORIGIN.qcow2 my_machine.qcow2</code>
 
<pre>
 
virt-resize --expand /dev/sda4 my_machine-ORIGIN.qcow2 my_machine.qcow2
 
[  0.0] Examining my_machine.qcow
 
**********
 
  
Summary of changes:
+
Overview: <code>[[qemu-img resize]]</code> -> <code>[[virt-resize]]</code> -> (Check [[virt-filesystems]]) -> <code>[[lvextend|lvextend --resizefs]]</code>
  
/dev/sda1: This partition will be left alone.
 
  
/dev/sda2: This partition will be left alone.
+
0) Backup
 +
:::<code>[[cp]] my_machine.qcow2 my_machine-ORIGIN.qcow2</code> (<code>[[progress -m]]</code> to track status)
  
/dev/sda3: This partition will be left alone.
+
1) [[qemu-img resize]] image_name.qcow2 +3G
  
/dev/sda4: This partition will be resized from 99.3G to 299.3G. The LVM PV
+
2) Resize:
on /dev/sda4 will be expanded using the 'pvresize' method.
+
::: <code>[[virt-resize --expand]] /dev/sda4 my_machine-ORIGIN.qcow2 my_machine-DESTINATION.qcow2</code>
  
**********
+
3) Verify name of your devices you can use:
[   5.2] Setting up initial partition table on my_machine.qcow2
+
::: <code>[[virt-filesystems]] --partitions --long -a VM_NAME.qcow2</code>
[ 17.5] Copying /dev/sda1
 
[  17.5] Copying /dev/sda2
 
[  18.0] Copying /dev/sda3
 
100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
 
[ 258.7] Expanding /dev/sda4 using the 'pvresize' method
 
  
Resize operation completed with no errors. Before deleting the old disk,
+
  4) [[lvextend --resizefs]] or [[fdisk]]
carefully check that the resized disk boots and works correctly.
 
  
</pre>
+
5) Start your machine: <code>[[virsh start]] VM_NAME</code> and discard your backups if everything is working properly.
  
Use: <code>[[virt-filesystems]]</code> to check image after executing <code>[[virt-resize]]</code>
 
  
 +
* [[Virt resize execution examples]]
  
 
== Virt-resize execution with errors ==
 
== Virt-resize execution with errors ==
Line 63: Line 53:
  
 
=== partition not found in the source disk image ===
 
=== partition not found in the source disk image ===
<pre>
 
libguestfs: trace: lvs = []
 
libguestfs: trace: canonical_device_name "/dev/vdb1"
 
libguestfs: trace: canonical_device_name = "/dev/sdb1"
 
virt-resize: error: /dev/sdb1: partition not found in the source disk image
 
(this error came from '--expand' option on the command line).  Try running
 
this command: [[virt-filesystems]] --partitions --long -a
 
VM_NAME.qcow2
 
  
</pre>
+
libguestfs: trace: lvs = []
 +
libguestfs: trace: canonical_device_name "/dev/vdb1"
 +
libguestfs: trace: canonical_device_name = "/dev/sdb1"
 +
virt-resize: error: /dev/sdb1: partition not found in the source disk image
 +
(this error came from '--expand' option on the command line).  Try running
 +
this command: [[virt-filesystems]] --partitions --long -a
 +
VM_NAME.qcow2
 +
 
 +
=== No such file or directory ===
 +
virt-resize --expand /dev/sda1 IMAGE.qcow2 IMAGE-DST.qcow2
 +
[  0.0] Examining IMAGE.qcow2
 +
virt-resize: error: libguestfs error: IMAGE-DST.qcow2: No such file or directory
 +
 +
If reporting bugs, run virt-resize with debugging enabled and include the
 +
complete output:
 +
 +
  virt-resize -v -x [...]
  
 
== Related commands ==
 
== Related commands ==
Line 78: Line 76:
 
* <code>[[lvextend|lvextend --resizefs]]</code>
 
* <code>[[lvextend|lvextend --resizefs]]</code>
 
* <code>[[virt-filesystems]]</code>
 
* <code>[[virt-filesystems]]</code>
 +
* <code>[[virt-df]]</code>
 +
* <code>[[virsh blockresize]]</code>
 +
* <code>--LV-expand</code> option from [[virt-resize]]
  
 
== Activities ==
 
== Activities ==
 
* [[Extend LVM on qcow2 images]]
 
* [[Extend LVM on qcow2 images]]
 +
* [[Kubernetes PVC resize: kubectl patch pvc]]
  
 
== See also ==
 
== See also ==
 +
* {{virt-resize}}
 
* {{KVM}}
 
* {{KVM}}
 
* {{virt}}
 
* {{virt}}
  
 
[[Category:KVM]]
 
[[Category:KVM]]

Latest revision as of 06:29, 23 November 2022

virt-resize - Resize a virtual machine disk https://linux.die.net/man/1/virt-resize

Example[edit]

Reference: http://wiki.docking.org/index.php/To_resize_a_virtual_drive

Overview: qemu-img resize -> virt-resize -> (Check virt-filesystems) -> lvextend --resizefs


0) Backup 
cp my_machine.qcow2 my_machine-ORIGIN.qcow2 (progress -m to track status)
1) qemu-img resize image_name.qcow2 +3G
2) Resize:
virt-resize --expand /dev/sda4 my_machine-ORIGIN.qcow2 my_machine-DESTINATION.qcow2
3) Verify name of your devices you can use:
virt-filesystems --partitions --long -a VM_NAME.qcow2
4) lvextend --resizefs or fdisk
5) Start your machine: virsh start VM_NAME and discard your backups if everything is working properly.


Virt-resize execution with errors[edit]

Failed to get "write" lock[edit]

virt-resize: error: libguestfs error: guestfs_launch failed.
This usually means the libguestfs appliance failed to start or crashed.
Do:
  export LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1
and run the command again.  For further information, read:
  http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs
You can also run 'libguestfs-test-tool' and post the *complete* output
into a bug report or message to the libguestfs mailing list.

If reporting bugs, run virt-resize with debugging enabled and include the
complete output:

  virt-resize -v -x [...]


After debugging: 
 qemu-system-x86_64: -drive file=/path/to/image/VM_NAME.qcow2,cache=unsafe,id=hd1,if=none: 
 Failed to get "write" lock
 Is another process using the image?

partition not found in the source disk image[edit]

libguestfs: trace: lvs = []
libguestfs: trace: canonical_device_name "/dev/vdb1"
libguestfs: trace: canonical_device_name = "/dev/sdb1"
virt-resize: error: /dev/sdb1: partition not found in the source disk image
(this error came from '--expand' option on the command line).  Try running
this command: virt-filesystems --partitions --long -a
VM_NAME.qcow2

No such file or directory[edit]

virt-resize --expand /dev/sda1 IMAGE.qcow2 IMAGE-DST.qcow2
[   0.0] Examining IMAGE.qcow2
virt-resize: error: libguestfs error: IMAGE-DST.qcow2: No such file or directory

If reporting bugs, run virt-resize with debugging enabled and include the
complete output:

 virt-resize -v -x [...]

Related commands[edit]

Activities[edit]

See also[edit]

Advertising: