-def duplicate_lv(source, dest):
- '''OBSOLETE: duplicate boot record, filesystem from LV source to LV dest
-
- source, dest should be device filenames.
-
- Now we just dd. Doesn't support resizing, but it's easier,
- especially if we allow the partition table to vary between images.
- '''
- # XXX this is very specific to what the etch sipb-xen-make-iso installer does.
- # XXXX also, it's specific to four gigs.
- # step 1: copy the MBR
- call(['dd', 'if='+source, 'bs=512', 'count=63', 'of='+dest])
- # step 2: fix up partition table
- # XX actually do this; this is our opportunity to resize the filesystem
- # step 3: make the filesystem, and copy its contents in
- sourcefs = losetup(source, 32256)
- destfs = losetup(dest, 32256)
- call(['mkfs.ext3', '-b', '4096', destfs, '987989'])
- tmptree = tempfile.mkdtemp('', 'auto-install.dup.', '/tmp')#yes, args backward
- os.mkdir(tmptree+"/source")
- call(['mount', '-t', 'ext3', '-o', 'ro', sourcefs, tmptree+"/source"])
- os.mkdir(tmptree+"/dest")
- call(['mount', '-t', 'ext3', destfs, tmptree+"/dest"])
- call(['cp', '-aT', tmptree+"/source", tmptree+"/dest"])
- # step 4: twiddle what we want to twiddle
- # XX do this
- # step 5: make the swap area
- swapfs = losetup(dest, 4046870016)
- call(['mkswap', swapfs, str(240943)])
- # call(['losetup', '-d', swapfs])
- print 'losetup -d '+swapfs
- # step 6: clean up.
- # XX actually unmount etc (leaving it is for debugging)
- print 'umount '+tmptree+'/source'
- call(['umount', tmptree+"/dest"]) # needed to flush writes
- print 'losetup -d '+sourcefs
- print 'losetup -d '+destfs
-
-def frob_copy(target, *args):