Changes between Version 2 and Version 3 of virtual-machines

Show
Ignore:
Timestamp:
02/03/12 16:42:48 (7 years ago)
Author:
pruth (IP: 152.54.9.28)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • virtual-machines

    v2 v3  
    6565== Sparse Images == 
    6666 
     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 [http://en.wikipedia.org/wiki/Sparse_file sparse files].  Sparse files take up less space when uncompressed and can be take less time to be uncompressed.    
     68 
     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).   
     70 
     71== Create a Sparse Image == 
     72 
     73This section assumes that you have a working non-sparse image and want to convert it to a sparse image. 
     74 
     75Create an appropriately sized sparse file (make sure your operating system and file system support sparse files... don't use nfs): 
     76 
     77{{{ 
     78$ dd if=/dev/zero of=my_sparse_image.img bs=1 count=1 seek=2G 
     79}}} 
     80 
     81Mount both your sparse image and non-sparse image: 
     82 
     83{{{ 
     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 
     88}}} 
     89 
     90Copy all the files from the non-sparse image to the sparse image (use 'cp -a' to preserve permissions and ownership): 
     91 
     92{{{ 
     93$ cp -a mnt-src/* mnt-dst/. 
     94}}} 
     95 
     96Unmount both images: 
     97 
     98{{{ 
     99$ umount mnt-src 
     100$ umount mnt-dst 
     101}}} 
     102 
     103You now have a sparse image called my_sparse_image.img.  Don't mess it up by using any tools that remove the sparsity. 
     104 
     105Tar the file with -S to preserve sparsity: 
     106 
     107{{{ 
     108$ tar -S -zcvf  my_sparse_image.img.tgz my_sparse_image.img 
     109}}} 
     110 
     111Note: to use the image with ORCA, must rename the image "filesystem" before tarring: 
     112 
     113{{{ 
     114$ mv my_sparse_image.img filesystem 
     115$ tar -S -zcvf  my_sparse_image.img.tgz filesystem 
     116}}} 
    67117 
    68118 
    69119 
    70 {{{ 
    71 $ dd if=/dev/zero of=myimage.img bs=1 count=1 seek=2G 
    72 }}} 
     120 
     121