In the last post we have seen how to transfer files using guestfs-tools to mount an image to transfer files. In this method we are using a native client called qemu-nbd to transfer files. Make sure qemu-utils have been installed if not run
After installing first run
This command loads the nbd module and instructs the kernel we will manage upto eight partitions. To mount first we need to connect the image to the qemu network device block driver.
Now check the partitions of the device /dev/nbd0
this command will list the partitions in the image. Now we can mount the image using the mount command.
to unmount the image run
With this command you can modify your contents in your image. If you are mounting a linux distro image make sure you are modifying only the home folder and nothing elsee other wise it will corrupt your image.
apt-get install qemu-utils
After installing first run
sudo modprobe nbd max_part=8
This command loads the nbd module and instructs the kernel we will manage upto eight partitions. To mount first we need to connect the image to the qemu network device block driver.
sudo qemu-nbd --connect=/dev/nbd0 hq.qcow2
Now check the partitions of the device /dev/nbd0
sudo fdisk /dev/nbd0 -l
this command will list the partitions in the image. Now we can mount the image using the mount command.
sudo mount /dev/nbd0p1 /mnt
to unmount the image run
sudo umount /mnt
sudo qemu-nbd --disconnect /dev/nbd0
With this command you can modify your contents in your image. If you are mounting a linux distro image make sure you are modifying only the home folder and nothing elsee other wise it will corrupt your image.