Changes between Version 2 and Version 3 of virtual-machines

02/03/12 16:42:48 (7 years ago)
pruth (IP:



  • virtual-machines

    v2 v3  
    6565== Sparse Images == 
     67The astute reader might point out that tarring an individual file is unnecessary and an odd format for ORCA to accept.  However, when used appropriately, this functionality can reduce the time and space necessary to stage and boot a virtual machine to a small fraction of the original.  The key is to store images as [ sparse files].  Sparse files take up less space when uncompressed and can be take less time to be uncompressed.    
     69It is not too difficult to create sparse files but it can be tricky to keep the files sparse while handling them.  Many common tool cannot process a sparse file without eliminating the sparse property (i.e. gzip, bzip2).  Other tools can maintain sparsity but do not by default (i.e. cp, tar).   Further, some operating systems and file systems cannot handle sparse files (i.e. nfs).   
     71== Create a Sparse Image == 
     73This section assumes that you have a working non-sparse image and want to convert it to a sparse image. 
     75Create an appropriately sized sparse file (make sure your operating system and file system support sparse files... don't use nfs): 
     78$ dd if=/dev/zero of=my_sparse_image.img bs=1 count=1 seek=2G 
     81Mount both your sparse image and non-sparse image: 
     84$ mkdir mnt-src 
     85$ mount -o loop my_image.img mnt-src 
     86$ mkdir mnt-dst 
     87$ mount -o loop my_sparse_image.img mnt-dst 
     90Copy all the files from the non-sparse image to the sparse image (use 'cp -a' to preserve permissions and ownership): 
     93$ cp -a mnt-src/* mnt-dst/. 
     96Unmount both images: 
     99$ umount mnt-src 
     100$ umount mnt-dst 
     103You now have a sparse image called my_sparse_image.img.  Don't mess it up by using any tools that remove the sparsity. 
     105Tar the file with -S to preserve sparsity: 
     108$ tar -S -zcvf  my_sparse_image.img.tgz my_sparse_image.img 
     111Note: to use the image with ORCA, must rename the image "filesystem" before tarring: 
     114$ mv my_sparse_image.img filesystem 
     115$ tar -S -zcvf  my_sparse_image.img.tgz filesystem 
    70 {{{ 
    71 $ dd if=/dev/zero of=myimage.img bs=1 count=1 seek=2G 
    72 }}}