On Mon, Oct 15, 2018 at 10:28:25AM -0400, Raghuram Devarakonda wrote:
On Mon, Oct 15, 2018 at 3:54 AM Richard W.M. Jones
<rjones(a)redhat.com> wrote:
>
> [Adding libguestfs mailing list]
>
> On Sun, Oct 14, 2018 at 11:53:17AM -0400, Raghuram Devarakonda wrote:
> > Hi,
> >
> > In our project, we deal with quite large sparse files whose total size
> > runs into several hundred terabytes or even more, though actual
> > allocated size on disk is much smaller. The problem is that such large
> > files present issues for copying around, compression, or even for
> > computing checksums. I am wondering of I can use guestfs-tools to
> > mount a QCOW2 image and then use the image as sparse file. The idea is
> > that actual file on the disk would be compact though to our code,
> > sparse file interface is preserved.
>
> It's not very clear to me exactly what you want, but in general yes
> qcow2 is a good way to handle very large, sparse disk images.
>
> If you can be clearer about exactly what you mean by "mount" then I
> could answer the question better. For example, do you mean "mount a
> filesystem in the qcow2 image"? In which case use guestmount. If you
> mean "attach the qcow2 disk as a local device" then qemu-nbd can do
> this.
We would like to create and write to a large sparse file but would
like to keep the file on disk itself in compact format. So we are not
talking about a file system but a single file. I guess this means
creating qcow2 disk and attach as a local device?
I'm still a little unclear, but most likely:
qemu-nbd -c /dev/nbd0 file.qcow2
qemu-nbd -d /dev/nbd0
The first command will attach file.qcow2 to /dev/nbd0, making it
appear as a normal host device. The second will detach it.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top