[et-mgmt-tools] Manually creating a sparse file

David Lutterkort dlutter at redhat.com
Fri Apr 6 23:49:34 UTC 2007


On Fri, 2007-04-06 at 16:21 -0400, Caetano, Greg wrote:
> I would like to manually create a VM sparse file that I can use fdisk to
> partition then copy a running root partition into the loopback sparse
> file.
> 
> How would I manually generate the proper vm sparse file?

virt-install creates a sparse file by default for file-backed guests; if
you have qemu-img, that can do the same thing. 

Or you can use your favorite scripting language as long as it can seek
in a file. Here's what that would look like in ruby:

        File::open("/tmp/s.txt", "w") do |file| 
          file.seek(1024*1024*1024)
          file.print("\000")
        end

That creates a 1GB sparse file /tmp/s.txt

David





More information about the et-mgmt-tools mailing list