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

  • Cloned VM/Server/Computer in Linux won't boot and goes to initramfs busybox Solution
  • How To Add Windows 7 8 10 11 to GRUB Boot List Dual Booting
  • How to configure OpenDKIM on Linux with Postfix and setup bind zonefile
  • Debian Ubuntu 10/11/12 Linux how to get tftpd-hpa server setup tutorial
  • efibootmgr: option requires an argument -- 'd' efibootmgr version 15 grub-install.real: error: efibootmgr failed to register the boot entry: Operation not permitted.
  • Apache Error Won't start SSL Cert Issue Solution Unable to configure verify locations for client authentication SSL Library Error: 151441510 error:0906D066:PEM routines:PEM_read_bio:bad end line SSL Library Error: 185090057 error:0B084009:x509 certif
  • Linux Debian Mint Ubuntu Bridge br0 gets random IP
  • redis requirements
  • How to kill a docker swarm
  • docker swarm silly issues
  • isc-dhcp-server dhcpd how to get longer lease
  • nvidia cannot resume from sleep Comm: nvidia-sleep.sh Tainted: Linux Ubuntu Mint Debian
  • zfs and LUKS how to recover in Linux
  • [error] (28)No space left on device: Cannot create SSLMutex Apache Solution Linux CentOS Ubuntu Debian Mint
  • Save money on bandwidth by disabling reflective rpc queries in Linux CentOS RHEL Ubuntu Debian
  • How to access a disk with bad superblock Linux Ubuntu Debian Redhat CentOS ext3 ext4
  • ImageMagick error convert solution - convert-im6.q16: cache resources exhausted
  • PTY allocation request failed on channel 0 solution
  • docker error not supported as upperdir failed to start daemon: error initializing graphdriver: driver not supported
  • Migrated Linux Ubuntu Mint not starting services due to broken /var/run and dbus - Failed to connect to bus: No such file or directory solution