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 ...
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,