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

  • 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 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
  • Using Cisco CME Router with Asterisk as a dial-peer
  • Cisco CME How To Configure SIP Trunk VOIP
  • Virtualbox host Only Network Error Failed to save host network interface parameter - Cannot change gateway IP of host only network
  • Cisco CME and C7200 Router Testing and Learning Environment on Ubuntu 20+ Setup Tutorial Guide
  • Abusive IP ranges blacklist
  • How to Install Any OS on a Physical Drive from Windows Using VMware Workstation (Linux, Windows, BSD)
  • CDN Cloudflare how to set and preserve the real IP of the client without modifying application code on Apache
  • CentOS 7 fix Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was 14: curl#6 -
  • Ubuntu Debian How To Install Recommended Packages Automatically
  • How to set Linux Ubuntu Redhat Debian Command Line http https socks proxy for yum apt