summaryrefslogtreecommitdiffstats
path: root/contrib/cloner/base.cfg
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/cloner/base.cfg')
-rw-r--r--contrib/cloner/base.cfg77
1 files changed, 13 insertions, 64 deletions
diff --git a/contrib/cloner/base.cfg b/contrib/cloner/base.cfg
index d4b1ee6b..2bc45e1d 100644
--- a/contrib/cloner/base.cfg
+++ b/contrib/cloner/base.cfg
@@ -1,7 +1,3 @@
-# this is a livecd config developed by Andrew Brown <ambrown4@ncsu.edu> for saving
-# and loading drive images to NFS locations, all based on kernel arguments. This is
-# for use with livecd creator.
-
lang en_US.UTF-8
keyboard us
timezone US/Eastern
@@ -19,6 +15,7 @@ services --disable sshd
repo --name=todos --baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/9/Everything/i386/os/
repo --name=updatez --baseurl=http://download.fedora.redhat.com/pub/fedora/linux/updates/9/i386/
+repo --name=partimageng --baseurl=file:///usr/src/redhat/RPMS/i386/
text
bootloader --location=mbr
@@ -76,6 +73,9 @@ grub
eject
tree
+# Add libraries for partimage:
+partimage-ng
+
%post
cat > /etc/rc.d/init.d/fedora-live << EOF
@@ -118,6 +118,7 @@ touch /media/.hal-mtab
# PUT CUSOTMIZATIONS HERE
mkdir -p /mnt/nfs
+
cat << EOFpython > /tmp/imaging.py
import subprocess
import sys
@@ -164,6 +165,8 @@ ret = call("mount %s /mnt/nfs" % nfspath)
if ret:
sys.exit("Couldn't mount")
+pimg = "partimage-ng"
+
# Make the directory where we'll save everything
call("mkdir -p %s" % fullpath)
@@ -172,38 +175,9 @@ if action == "save":
call("rm -f -- %s" % os.path.join(fullpath, "*"))
for drivenum, drive in enumerate(drivelist):
- # Save off mbr and the data between mbr and the first partition
- # in case grub stuck a stage 1.5 bootloader there.
- print "Saving mbr..."
- mbrpath = os.path.join(fullpath, "%s.mbr" % drivenum)
- sfdiskpath = os.path.join(fullpath, "%s.sfdisk" % drivenum)
- call("dd if=%s of=%s bs=512 count=63" % (drive, mbrpath))
-
- # Save off extended partition information
- print "Saving extended partition info..."
- call("sfdisk %s -d > %s" % (drive, sfdiskpath))
-
- for partition in os.popen("sfdisk -l %s" % drive, 'r').readlines():
- if not partition.startswith(drive):
- continue
-
- # ex: /dev/sda1
- partdevice = partition.split()[0]
-
- # ex: 1
- partnum = partdevice[len(drive):]
-
- # ex: Linux, Extended, Win95...
- parttype = partition.split()[-1]
-
- # Decide what to do depending on parttype...
- if parttype in ("Empty", "Extended"):
- continue
-
- # for now, everything is dd
- print "Saving %s" % partdevice
- partimagepath = os.path.join(fullpath, "%s.%s" % (drivenum, partnum))
- call("dd if=%s of=%s conv=sync,noerror" % (partdevice, partimagepath))
+ print "Saving %s" % drive
+ imagepath = os.path.join(fullpath, "%s.img" % drivenum)
+ call("%s -i save %s %s" % (pimg, drive, imagepath))
print "Finished saving. Rebooting"
#call("/sbin/shutdown -r now")
@@ -211,34 +185,9 @@ if action == "save":
elif action == "load":
for drivenum, drive in enumerate(drivelist):
- print "Restoring partition info for %s" % drive
-
- mbrpath = os.path.join(fullpath, "%s.mbr" % drivenum)
- sfdiskpath = os.path.join(fullpath, "%s.sfdisk" % drivenum)
-
- call("dd if=%s of=%s" % (mbrpath, drive))
- call("sfdisk %s < %s" % (drive, sfdiskpath))
-
- call("sfdisk %s -R" % drive)
- for partpath in glob(os.path.join(fullpath, "%s.*" % drivenum)):
- # partpath is full path to partition file on nfs mount
- # ex: /export/blade1/0.1
-
- # partfile ex: 0.1
- partfile = os.path.split(partpath)[-1]
-
- # partnum ex: 1
- partnum = partfile.split(".")[-1]
- if partnum in ("mbr", "fdisk") or not partnum.isdigit():
- continue
-
- partition = drive + partnum
- print "Restoring %s" % partition
-
- # Don't exit if dd "fails", dd returns 1 here because device runs
- # out of room even if it fits perfectly apparently
-
- call("dd if=%s of=%s" % (partpath, partition))
+ print "Restoring %s" % drive
+ imagepath = os.path.join(fullpath, "%s.img" % drivenum)
+ call("%s restore %s %s" % (pimg, imagepath, drive))
print "Finished loading image. Rebooting"
#call("/sbin/shutdown -r now")