How To Mount VM Images with Guestmount?
guestmount is a tool used to mount VM images. This VM images can be different formats like qcow, vmdk, vdi etc. In this tutorial we will examine different use cases about
Mount Disk Image
We will start by mounting given image partition to the specified directory. We will provide the image with the
-m option will used to point the partition we want to mount which resides in image. The last parameter to the
guestmount is the local directory we want to mount. In this example we will mount image
sda1 into local directory
$ guestmount -a cirros-0.3.0-i386-disk.img -m /dev/sda1 test2
$ ls test2/
bin boot dev etc home init initrd.img lib linuxrc lost+found mnt old-root opt proc root run sbin sys tmp usr var vmlinuz
Normally guestmount mounts the disk or partition with read-write options if you want to mount readonly use
-r option. We can not write anything to this image which will made safe for modifications.
$ guestmount -r -a cirros-0.3.0-i386-disk.img -m /dev/sda1 test2
Specifying partition is not a must. We can use -i option to automatically look for partition with guestmount.
$ guestmount -a cirros-0.3.0-i386-disk.img -i test2
We can enable SELinux support on disk image with –selinux option.
$ guestmount -a cirros-0.3.0-i386-disk.img -i test2 --selinux
Provide Mount Options
We can specify mount options about image partitions with the
-o option. In this example we will enable to read this partition directory by other users with
$ guestmount -a cirros-0.3.0-i386-disk.img -i test2 -o allow_other