Richard W.M. Jones
2018-Oct-15 07:54 UTC
Re: [Libguestfs] Question about mounting QCOW2 files....
[Adding libguestfs mailing list] On Sun, Oct 14, 2018 at 11:53:17AM -0400, Raghuram Devarakonda wrote:> Hi, > > My name is Raghuram Devarakonda and I am a big fan of "nbdkit". I have > successfully used it to prototype (using Python plugin) a complex > project in our company and since then, I have also been trying to > understand and learn "guestfs-tools" as well. I have a question in > this regard and I hope you don't mind my sending mail gratuitously. > > 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. Rich.> Can you please let me know if this is possible? Can I mount a sparse > file using guestfs-tools even though it is not really a disk? > > Thanks in advance, > Raghu-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Raghuram Devarakonda
2018-Oct-15 14:28 UTC
Re: [Libguestfs] Question about mounting QCOW2 files....
On Mon, Oct 15, 2018 at 3:54 AM Richard W.M. Jones <rjones@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? Thanks, Raghu
Richard W.M. Jones
2018-Oct-16 13:28 UTC
Re: [Libguestfs] Question about mounting QCOW2 files....
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@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