Ignore:
Timestamp:
Nov 13, 2007, 5:10:10 AM (17 years ago)
Author:
price
Message:

Prototype fast installer using a special guest.

Rather than poke directly in the boot sector, partition table,
etc, which caused so much pain last week (r231), we just dd
the entire disk. Then we poke at the bits that need to change
(like secrets, the hostname, the root password, the filesystem uuids).
Since this poking is distribution-dependent, we want it to be
supplied by the image, so to make that safe we run it in a VM.

The plan is

  1. source image is dd'd (in the host) to the target image
  2. special copying-installer image is booted, with access to target and to a small image containing its arguments
  3. copying-installer guest reads arguments, mounts target, runs a script with a well-known name in target, passing arguments.

Bits I haven't done yet include

  • frob grub config in the copying-installer image so it boots with init = the copying-installer script (doing this manually for testing)
  • install script into copying-installer, or into my example image, in a sane automated way (they're checked into partial/ here)
  • all the tasks the image's script ought to actually carry out
  • make this all available from remctl and the web pages.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-guest-installer/sipb-xen-guest-installer/files/usr/sbin/sipb-xen-duplicate

    r231 r245  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python2.5
    22
    33import sys
     
    55import shutil
    66import tempfile
    7 from subprocess import call, Popen
     7from subprocess import call, check_call, Popen
    88
    99# TODO:
     
    7272  print 'losetup -d '+destfs
    7373
     74def duplicate_by_vm(source, target, *args):
     75  # source, target should be machine names
     76  prefix = 'd_'
     77  # 1. copy (by dd) source to target
     78  source_device = '/dev/xenvg/' + prefix + source + '_hda'
     79  target_device = '/dev/xenvg/' + prefix + target + '_hda'
     80  #check_call(['/bin/dd', 'bs=1M', 'conv=nocreat',
     81  #            'if='+source_device, 'of='+target_device])
     82  # 2. prepare arguments volume
     83  args_volume = prefix+target+'_args'
     84  args_device = '/dev/xenvg/' + args_volume
     85  check_call(['/sbin/lvcreate', 'xenvg', '--name', args_volume, '--size', '4K'])
     86  file(args_device, 'w').write('\n'.join(args) + '\n')
     87
     88  copier_device = '/dev/xenvg/d_wert_hda'
     89  check_call(['/usr/sbin/xm', 'create', 'sipb-database',
     90              'machine_name='+target,
     91              'disks=' + ' '.join(['phy:'+copier_device+',hda,w',
     92                                   'phy:'+target_device+',hdc,w',
     93                                   'phy:'+args_device+',hdd,w'])])
     94  boot = 'c'
     95
     96  # XXX make this happen! check_call(['/sbin/lvremove', '-f', 'xenvg/'+args_volume])
     97 
     98
    7499if __name__ == '__main__':
    75   duplicate_lv(*sys.argv[1:])
     100  duplicate_by_vm(*sys.argv[1:])
Note: See TracChangeset for help on using the changeset viewer.