• Home
  • About
  • Contact
  • Privacy
  • Terms
  • DCMA
  • Write For Us / Submit
Tech News, Magazine & Review WordPress Theme 2017
  • Tech
    How Drones and 360-Degree Cameras Are Changing Bridal Photoshoots

    How Drones and 360-Degree Cameras Are Changing Bridal Photoshoots

    120+ Best Creative Names for Team at Work

    120+ Best Creative Names for Team at Work

    Can You Repair Printed Circuit Board ?

    Mastering PCB Board Repair Comprehensive Guide

    Breaking Barriers Federal Inmate Texting Service

    Breaking Barriers Federal Inmate Texting Service

    transfer whatsapp from android to iphone

    How to Transfer WhatsApp from Android to iPhone!

    Understanding the Role of Humidity Chambers in Climate Testing

    Understanding the Role of Humidity Chambers in Climate Testing

    Everything You Get to Know About Movember Beard Memes

    Everything You Get to Know About Movember Beard Memes

    Best Book Recommendation Apps

    11 Best Book Recommendation Apps

    How to quickly divide or Split PDF files

    How to Quickly Divide or Split PDF Files

  • Gear
    • All
    • Camera
    • Laptop
    • Smartphone
    The New Galaxy Watch Ultra and Galaxy Ring Are Announced by Samsung

    The New Galaxy Watch Ultra and Galaxy Ring Are Announced by Samsung

    Exploring the Innovative Features of Pear Phones

    Exploring the Innovative Features of Pear Phones

    Latest Smart Home Gadgets for a Connected Life

    Latest Smart Home Gadgets for a Connected Life

    Eco-Friendly Products for Students

    Eco-Friendly Products for Students

    Essential Photography Equipment and Gadgets

    Mastering Your Shots: Essential Photography Equipment and Gadgets

    Level Up Your Game: Must-Have Gaming Gear!

    Level Up Your Game: Must-Have Gaming Gear!

    Trending Tags

    • Best iPhone 7 deals
    • Apple Watch 2
    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • iOS 10
    • iPhone 7
    • Sillicon Valley
  • Gaming
    Master the World of Online Gaming with the Best Gaming VPN

    Master the World of Online Gaming with 3 Best Gaming VPN

    7 Powerful Strategies to Overcome Video Game Addiction and Reclaim Your Life

    7 Powerful Strategies to Overcome Video Game Addiction and Reclaim Your Life

    Powerful Ways Xbox Cloud Gaming is Revolutionizing the Gaming World

    5 Powerful Ways Xbox Cloud Gaming is Revolutionizing the Gaming World

    9 Best Alternative Games Like Kahoot

    9 Best Alternative Games Like Kahoot

    The Top 8 Free Bubble Shooter Games for Endless Entertainment

    The Top 8 Free Bubble Shooter Games for Endless Entertainment

    Cloud Gaming Revolution: How Streaming is Changing the Future of Gaming

    Cloud Gaming Revolution: How Streaming is Changing the Future of Gaming

  • Crypto
    How Drones and 360-Degree Cameras Are Changing Bridal Photoshoots

    How Drones and 360-Degree Cameras Are Changing Bridal Photoshoots

    120+ Best Creative Names for Team at Work

    120+ Best Creative Names for Team at Work

    Can You Repair Printed Circuit Board ?

    Mastering PCB Board Repair Comprehensive Guide

    Breaking Barriers Federal Inmate Texting Service

    Breaking Barriers Federal Inmate Texting Service

    transfer whatsapp from android to iphone

    How to Transfer WhatsApp from Android to iPhone!

    Understanding the Role of Humidity Chambers in Climate Testing

    Understanding the Role of Humidity Chambers in Climate Testing

    Everything You Get to Know About Movember Beard Memes

    Everything You Get to Know About Movember Beard Memes

    Best Book Recommendation Apps

    11 Best Book Recommendation Apps

    How to quickly divide or Split PDF files

    How to Quickly Divide or Split PDF Files

  • Business
    How Drones and 360-Degree Cameras Are Changing Bridal Photoshoots

    How Drones and 360-Degree Cameras Are Changing Bridal Photoshoots

    120+ Best Creative Names for Team at Work

    120+ Best Creative Names for Team at Work

    Can You Repair Printed Circuit Board ?

    Mastering PCB Board Repair Comprehensive Guide

    Breaking Barriers Federal Inmate Texting Service

    Breaking Barriers Federal Inmate Texting Service

    transfer whatsapp from android to iphone

    How to Transfer WhatsApp from Android to iPhone!

    Understanding the Role of Humidity Chambers in Climate Testing

    Understanding the Role of Humidity Chambers in Climate Testing

    Everything You Get to Know About Movember Beard Memes

    Everything You Get to Know About Movember Beard Memes

    Best Book Recommendation Apps

    11 Best Book Recommendation Apps

    How to quickly divide or Split PDF files

    How to Quickly Divide or Split PDF Files

No Result
View All Result
Geeky Insider
  • Tech
    How Drones and 360-Degree Cameras Are Changing Bridal Photoshoots

    How Drones and 360-Degree Cameras Are Changing Bridal Photoshoots

    120+ Best Creative Names for Team at Work

    120+ Best Creative Names for Team at Work

    Can You Repair Printed Circuit Board ?

    Mastering PCB Board Repair Comprehensive Guide

    Breaking Barriers Federal Inmate Texting Service

    Breaking Barriers Federal Inmate Texting Service

    transfer whatsapp from android to iphone

    How to Transfer WhatsApp from Android to iPhone!

    Understanding the Role of Humidity Chambers in Climate Testing

    Understanding the Role of Humidity Chambers in Climate Testing

    Everything You Get to Know About Movember Beard Memes

    Everything You Get to Know About Movember Beard Memes

    Best Book Recommendation Apps

    11 Best Book Recommendation Apps

    How to quickly divide or Split PDF files

    How to Quickly Divide or Split PDF Files

  • Gear
    • All
    • Camera
    • Laptop
    • Smartphone
    The New Galaxy Watch Ultra and Galaxy Ring Are Announced by Samsung

    The New Galaxy Watch Ultra and Galaxy Ring Are Announced by Samsung

    Exploring the Innovative Features of Pear Phones

    Exploring the Innovative Features of Pear Phones

    Latest Smart Home Gadgets for a Connected Life

    Latest Smart Home Gadgets for a Connected Life

    Eco-Friendly Products for Students

    Eco-Friendly Products for Students

    Essential Photography Equipment and Gadgets

    Mastering Your Shots: Essential Photography Equipment and Gadgets

    Level Up Your Game: Must-Have Gaming Gear!

    Level Up Your Game: Must-Have Gaming Gear!

    Trending Tags

    • Best iPhone 7 deals
    • Apple Watch 2
    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • iOS 10
    • iPhone 7
    • Sillicon Valley
  • Gaming
    Master the World of Online Gaming with the Best Gaming VPN

    Master the World of Online Gaming with 3 Best Gaming VPN

    7 Powerful Strategies to Overcome Video Game Addiction and Reclaim Your Life

    7 Powerful Strategies to Overcome Video Game Addiction and Reclaim Your Life

    Powerful Ways Xbox Cloud Gaming is Revolutionizing the Gaming World

    5 Powerful Ways Xbox Cloud Gaming is Revolutionizing the Gaming World

    9 Best Alternative Games Like Kahoot

    9 Best Alternative Games Like Kahoot

    The Top 8 Free Bubble Shooter Games for Endless Entertainment

    The Top 8 Free Bubble Shooter Games for Endless Entertainment

    Cloud Gaming Revolution: How Streaming is Changing the Future of Gaming

    Cloud Gaming Revolution: How Streaming is Changing the Future of Gaming

  • Crypto
    How Drones and 360-Degree Cameras Are Changing Bridal Photoshoots

    How Drones and 360-Degree Cameras Are Changing Bridal Photoshoots

    120+ Best Creative Names for Team at Work

    120+ Best Creative Names for Team at Work

    Can You Repair Printed Circuit Board ?

    Mastering PCB Board Repair Comprehensive Guide

    Breaking Barriers Federal Inmate Texting Service

    Breaking Barriers Federal Inmate Texting Service

    transfer whatsapp from android to iphone

    How to Transfer WhatsApp from Android to iPhone!

    Understanding the Role of Humidity Chambers in Climate Testing

    Understanding the Role of Humidity Chambers in Climate Testing

    Everything You Get to Know About Movember Beard Memes

    Everything You Get to Know About Movember Beard Memes

    Best Book Recommendation Apps

    11 Best Book Recommendation Apps

    How to quickly divide or Split PDF files

    How to Quickly Divide or Split PDF Files

  • Business
    How Drones and 360-Degree Cameras Are Changing Bridal Photoshoots

    How Drones and 360-Degree Cameras Are Changing Bridal Photoshoots

    120+ Best Creative Names for Team at Work

    120+ Best Creative Names for Team at Work

    Can You Repair Printed Circuit Board ?

    Mastering PCB Board Repair Comprehensive Guide

    Breaking Barriers Federal Inmate Texting Service

    Breaking Barriers Federal Inmate Texting Service

    transfer whatsapp from android to iphone

    How to Transfer WhatsApp from Android to iPhone!

    Understanding the Role of Humidity Chambers in Climate Testing

    Understanding the Role of Humidity Chambers in Climate Testing

    Everything You Get to Know About Movember Beard Memes

    Everything You Get to Know About Movember Beard Memes

    Best Book Recommendation Apps

    11 Best Book Recommendation Apps

    How to quickly divide or Split PDF files

    How to Quickly Divide or Split PDF Files

Submit
Geeky Insider
No Result
View All Result

How to Increase a KVM Virtual Machine’s Disk Size

by Staff Writer
October 13, 2022
in How To
Reading Time: 6 mins read
Photo of the internals of hard drives
Share on FacebookShare on Twitter

Shutterstock.com/zentilia

KVM is a virtualization technology that’s integrated into the Linux kernel. You can create virtual machines and interact with KVM using tools such as virsh, virt-manager, and GNOME Boxes.

Running out of disk space is one of the most common VM guest issues. You might have started out with an intentionally small disk while you tested a new VM. Over time you accumulate files until the virtual disk is almost full. Here’s how to resize your disk in-place, without having to copy files to a separate larger drive.

Table of Contents

Toggle
    • READ ALSO
    • How to Activate Iphone With Sim Card
    • How to Quickly Divide or Split PDF Files
  • Shut Down Your VM
  • Find The Disk’s Location
  • Delete VM Snapshots
  • Resizing the Disk
  • Extending the Disk’s Partitions
  • Downsizing a Disk
  • Summary

READ ALSO

transfer whatsapp from android to iphone

How to Transfer WhatsApp from Android to iPhone!

October 6, 2023
How to prevent phishing attacks

How to Prevent Phishing Attacks: Safeguarding Your Digital Identity

May 14, 2023

Shut Down Your VM

Begin by shutting down your virtual machine. You can shutdown within the guest operating system, using the controls in your management UI, or by issuing the virsh shutdown command:

$ sudo virsh list
Id Name State
——————————
– ubuntu22.04 running

$ sudo virsh shutdown ubuntu22.04
Domain ubuntu22.04 is being shutdown

Wait until the VM is powered off. It will disappear from the virsh list output after it shuts down. You can see details of inactive VMs by adding the –all flag:

$ sudo virsh list –all
Id Name State
——————————
– ubuntu22.04 shut off

Find The Disk’s Location

Next you need to identify the path where your VM’s disk is saved. Each VM gets a disk image file that stores the complete content of its filesystem. Several formats can be used including QCOW2, VDI, VMDK, and VHDX.

Most VMs created in a modern KVM environment will have a QCOW2 disk image stored inside the /var/lib/libvirt/images directory. The file’s name will match the name of the VM that’s displayed in the virsh list command’s output.

You can check the path to a VM’s disk by running virsh domblklist:

$ sudo virsh domblklist ubuntu22.04
Target Source
—————————————————–
sdb /var/lib/libvirt/images/ubuntu22.04.qcow2

This confirms the file to resize for this VM is /var/lib/libvirt/images/ubuntu22.04.qcow2.

Delete VM Snapshots

You can’t resize disk images which have snapshots stored against them. You’ll have to delete snapshots before you perform the resize. If you need to keep snapshots, clone the VM first and use the copy to access the snapshotted states. You can then delete the snapshots from the original VM and continue your resize operation.

The virsh snapshot-list command will reveal whether your VM has any snapshots:

$ virsh snapshot-list ubuntu22.04
Name Creation Time State
—————————————————
13-09-2022 2022-09-13 22:36:41 +0100 shutoff

Delete them with the snapshot-delete command. The snapshot to delete is identified using <vm-name> <snapshot-name> syntax.

$ virsh snapshot-delete ubuntu22.04 13-09-2022

Resizing the Disk

The qemu-img command can now be used to resize the disk. Its arguments are the path to the disk image file and the amount of extra capacity to add to the disk.

$ sudo qemu-img resize /var/lib/libvirt/images/ubuntu22.04.qcow2 +16G

The +16G means the disk will become 16 GB larger than its current size. You can use other standard suffixes too such as M for megabytes and T for terabytes. Omitting the + notation instructs QEMU to make the disc a specific size, such as 1T to provide 1 TB of capacity.

The resize process should only take a few seconds. It won’t necessarily have an immediate effect on your host’s total disk usage depending on the image format used.

Extending the Disk’s Partitions

Next boot up your virtual machine and use the guest operating system’s disk management utility to extend the disc’s partition table into the newly allocated free space. Without this step your new capacity won’t be accessible to the operating system.

Linux’s resize2fs command will automatically grow a designated partition to the maximum extent allowed by any available free space:

$ sudo resize2fs /dev/sda

Find the right device to target (/dev/sda in the command above) by running df -h and looking for the filesystem that’s mounted to /:

$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda 32G 17G 15G 53% /

To resize the partition graphically you could use GParted or GNOME Disks in a Linux guest or Disk Management for a Windows machine.

Here’s the Ubuntu 22.04 virtual machine that had its disk resized by 16 GB in the example above. After starting the guest and opening GParted, the 16 GB of free space is visible as an unallocated area at the end of the disk.

image of partitions in gParted

The space is brought into use by right-clicking the existing system partition, selecting “Resize/Move” from GParted’s menu, and growing the partition into the free space at the end. After applying the operation, the partition has a usable capacity of 48 GB as expected.

image of partitions in gParted

Downsizing a Disk

Disk images can be downsized if your VM’s been allocated more storage than it needs. This is a potentially risky operation. Backup your disk before you start the resize so you can recover the situation if data gets deleted:

$ sudo cp /var/lib/libvirt/images/ubuntu22.04.qcow2 ubuntu22.04.qcow2.bak

Next you must adjust the partition table from within the VM so that there’s unallocated free space available on the disk. When you’re resizing a 32 GB disk to 20 GB, you should ensure there’s at least 12 GB of free space at the end of the partition table, for example. Forgetting this step will cause the resize to indiscriminately delete data from the end of the disk, corrupting the partition table and leaving your VM unbootable.

This Windows 10 machine has a 40 GB disk of which only 32 GB is mapped into partitions. The 8 GB unallocated space at the end of the drive means you can safely downsize the disk by up to 8 GB.

image of Windows 10's Disk Management utility

Once you’ve prepared your partitions, you can use qemu-img resize to perform the downsize. Support for this operation must be manually enabled every time by including the –shrink flag with your command. This lets you specify a target size smaller than the disk’s current capacity. You can also -8G syntax to downsize by a predetermined amount.

$ qemu-img resize –shrink /var/lib/libvirt/images/win10.qcow2 -8G

After rebooting the guest, Windows confirms the 8GB free space has been removed from the end of the disk.

image of Windows 10's Disk Management utility

Summary

Disk images used by KVM virtual machines can be resized with the virsh and qemu-img commands. Resizing a disk is reliable and should complete in a matter of seconds but it doesn’t work when VMs have stored snapshots. It’s always a good idea to back up your disk image before you start work.

Some KVM GUIs such as GNOME Boxes include support for resizes, letting you enlarge a disk without using the terminal. However you apply the resize, you must boot up the guest VM afterwards and adjust the partition table to use the space. This allows the operating system to utilize the increased disk capacity.



Source by www.howtogeek.com

Related Posts

How to Use the Text Command Excel
How To

How to Use the Text Command Excel

November 22, 2023
How to Communicate with Beeper Codes
How To

How to Communicate with Beeper Codes

November 4, 2024
transfer whatsapp from android to iphone
Articles

How to Transfer WhatsApp from Android to iPhone!

October 6, 2023
How to prevent phishing attacks
How To

How to Prevent Phishing Attacks: Safeguarding Your Digital Identity

May 14, 2023

Recommended.

Electrical Brain Stimulation Boosts Memory in Seniors, Study Finds

Electrical Brain Stimulation Boosts Memory in Seniors, Study Finds

August 24, 2022
What Type Of Studio Headphones Do Rappers And Producers Use?

What Type Of Studio Headphones Do Rappers And Producers Use?

October 23, 2022

Trending.

No Content Available
  • Home
  • About
  • Contact
  • Privacy
  • Terms
  • DCMA
  • Write For Us / Submit
Contact us for submission queries. editor[at]geekyinsider.com.
No Result
View All Result
  • Home
  • Review
  • Apple
  • Gaming
  • Gadget and Gear
    • Camera
    • Smartphone
  • Microsoft
  • Security