libguestfs tools howto guide for mounting partitions and managing virtual machine images

libguestfs tools howto guide for managing virtual machine images.

libguestfs-tools aka guestfs tools has a lot of tools that make this very easy for you.  You can easily mount partitons from an image with some of the commands below.

To mount a partition
#mount the kvmuser102821.img image and the /dev/sda1 partition from it to the local directory "mount"
guestmount -a kvmuser102821.img -m /dev/sda1 mount
 



To list partition info on the image:
virt-df image.img

Filesystem                           1K-blocks       Used  Available  Use%
kvmuser102821.img:/dev/sda1           20641404     768404   18824476    4%

 



To resize (expand) an image:

#first create the destination disk of the size you want:
qemu-img create -f qcow2 kvmuser102821.img-60G 60G
Formatting 'kvmuser102821.img-60G', fmt=qcow2 size=64424509440 encryption=off cluster_size=65536

virt-resize --resize /dev/sda1=60G kvmuser102821.img kvmuser102821.img-60G

Examining kvmuser102821.img ...
 100% ⟦▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓⟧ --:--
virt-resize: error: There is a deficit of 2260992 bytes (2.2M).  You
need to make the target disk larger by at least this amount or adjust
your resizing requests.

If reporting bugs, run virt-resize with the '-d' option and include the
complete output.

#try again by increasing the target slightly in this case to 60.1G
qemu-img create -f qcow2 kvmuser102821.img-60G 60.1G
Formatting 'kvmuser102821.img-60G', fmt=qcow2 size=64531883622 encryption=off cluster_size=65536
 virt-resize --resize /dev/sda1=60G kvmuser102821.img kvmuser102821.img-60G
Examining kvmuser102821.img ...


Tags:

libguestfs, howto, managing, virtual, imageslibguestfs, images, mount, partition, kvmuser, img, dev, sda, directory, quot, guestmount, info, virt, df, filesystem, resize, expand, destination, disk, qemu, qcow, formatting, fmt, encryption, cluster_size, examining, deficit, bytes, larger, adjust, resizing, requests, reporting, output, increasing,

Latest Articles

  • Convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/413. convert-im6.q16: no images defined `pts-time.jpg' @ error/convert.c/ConvertImageCommand/3258. solution ImageMagick P
  • Apache PHP sending expires header solution cannot use cache with CDN
  • How to install virt-manager in Mint 22/Ubuntu 22
  • Infiniband Guide
  • python mysql install error: /bin/sh: 1: mysql_config: not found /bin/sh: 1: mariadb_config: not found /bin/sh: 1: mysql_config: not found mysql_config --version
  • FreePBX 17 How To Add a Trunk
  • Docker Container Onboot Policy - How to make sure a container is always running
  • FreePBX 17 How To Add Phones / Extensions and Register
  • Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes. solution
  • Cisco How To Use a Third Party SIP Phone (eg. Avaya, 3CX)
  • Cisco Unified Communication Manager (CUCM) - How To Add Phones
  • pptp / pptpd not working in DD-WRT iptables / router
  • systemd-journald high memory usage solution
  • How to Install FreePBX 17 in Linux Debian Ubuntu Mint Guide
  • How To Install Cisco's CUCM (Cisco Unified Communication Manager) 12 Guide
  • Linux Ubuntu Redhat How To Extract Images from PDF
  • Linux and Windows Dual Boot Issue NIC Won't work After Booting Windows
  • Cisco CME How To Enable ACD hunt groups
  • How to install gns3 on Linux Ubuntu Mint
  • How to convert audio for Asterisk .wav format