Hi All: I've been playing around with both anaconda and the live-cd, and I had an idea to kind of merge the two. I took advantage up the RHupdates override on a nfs install, to have anaconda use a squashfs.img that is on the nfs server in /LiveOS/,(this could use a bit of work...) creating the same device name as the the live-cd install is looking for. Once that is done, anaconda uses a patched livecd.py to install to the harddrive. This is more of a proof of concept them prime code.. ;) First I altered fedora.py in installclass, flags.py, bootloader.py, livecd.py, and added a new one called livefs.py, adding them in /RHupdates/ to incorporate my changes with out really having to play with the loader. dmc: I like where you are going with the reboot-less install, looking forward to your progress. Jerry
--- /home/cvsroot/anaconda/installclasses/fedora.py 2007-02-06 10:14:43.000000000 -0600 +++ installclasses/fedora.py 2007-06-19 17:44:46.000000000 -0500 @@ -45,22 +45,12 @@ anaconda.dispatch.skipStep("partition") def getMethod(self, methodstr): + if os.access("/mnt/source/RHupdates/livefs.py", os.R_OK): + import livefs + import livecd + return livecd.LiveCDImageMethod + if methodstr.startswith("livecd://"): import livecd return livecd.LiveCDImageMethod + return BaseInstallClass.getMethod(self, methodstr) def getBackend(self, methodstr): + if os.access("/mnt/source/RHupdates/livefs.py", os.R_OK): + import livecd + return livecd.LiveCDCopyBackend + if methodstr.startswith("livecd://"): import livecd return livecd.LiveCDCopyBackend --- /home/cvsroot/anaconda/flags.py 2006-10-18 16:33:24.000000000 -0500 +++ flags.py 2007-06-17 20:11:23.000000000 -0500 @@ -66,6 +66,7 @@ self.__dict__['flags']['cmdline'] = self.createCmdlineDict() self.__dict__['flags']['useIPv4'] = True self.__dict__['flags']['useIPv6'] = True + self.__dict__['flags']['livefs'] = 0 # for non-physical consoles like some ppc and sgi altix, # we need to preserve the console device and not try to # do things like bogl on them. this preserves what that --- /home/cvsroot/anaconda/bootloader.py 2007-01-16 13:58:13.000000000 -0600 +++ bootloader.py 2007-07-02 15:43:20.000000000 -0500 @@ -37,7 +37,7 @@ return # FIXME: this is a hack... - if flags.livecd: + if flags.livecd or flags.livefs: return if anaconda.id.ksdata: --- /home/cvsroot/anaconda/livecd.py 2007-07-02 14:05:21.000000000 -0500 +++ livecd.py 2007-07-11 20:49:18.000000000 -0500 @@ -86,9 +75,12 @@ class LiveCDImageMethod(installmethod.InstallMethod): def __init__(self, method, rootpath, intf): """@param method livecd://live-block-device""" - installmethod.InstallMethod.__init__(self, method, rootpath, intf) + installmethod.InstallMethod.__init__(self, method, rootpath, intf) self.osimg = method[8:] + if flags.livefs: + log.info("livefs mode - changing os.img") + self.osimg = "/dev/live-osimg" if not stat.S_ISBLK(os.stat(self.osimg)[stat.ST_MODE]): intf.messageWindow(_("Unable to find image"), _("The given location isn't a valid %s " @@ -316,9 +295,72 @@ f.close() # rebuild the initrd(s) - vers = self.kernelVersionList() - for (n, arch, tag) in vers: - packages.recreateInitrd(n, anaconda.rootPath) + if flags.livefs: + log.info("livefs mode - need bootloader") + log.info("livefs mode - need to find kernel") + # guaranteed to only have one kernel installed at this point + + kver = subprocess.Popen(["/usr/bin/ls", "%s/lib/modules/"%anaconda.rootPath], stdout=subprocess.PIPE).communicate()[0].strip() + print "Kernel version is %s"%kver + log.info("Kernel version is %s" %(kver)) + + # create new initramfs + os.system("/usr/sbin/chroot %s /sbin/mkinitrd -v -f /boot/initrd-%s.img %s"%(anaconda.rootPath, kver, kver)) + log.info("livefs mode - rebuild initrd") + # Figure out grub device name + ##HACK + diskDeviceFile="/dev/sda" +# grubDevNumber=int(rootDeviceFile[diskDeviceFile.__len__():]) - 1 +# grubDev="(hd0,%s)"%grubDevNumber + grubDev="(hd0,0)" + osName="Fedora" + + log.info("livefs mode - need to write grub.conf") + # create grub.conf (see above how grubDev is computed) + grub = open(anaconda.rootPath + "/boot/grub/grub.conf", "w") + grub.write("default=0\n") + grub.write("timeout=5\n") + grub.write("splashimage=%s/grub/splash.xpm.gz\n"%grubDev) + grub.write("hiddenmenu\n") + grub.write("title %s (%s)\n"%(osName, kver)) + grub.write(" root %s\n"%grubDev) + #grub.write(" kernel /boot/vmlinuz-%s ro quiet root=UUID=%s\n"%(kver, uuid)) + grub.write(" kernel /vmlinuz-%s ro root=LABEL=%s\n"%(kver, "/")) + grub.write(" initrd /initrd-%s.img\n"%kver) + grub.close() + + os.system("rm -f %s/etc/grub.conf"%anaconda.rootPath) + os.system("ln -s ../boot/grub/grub.conf %s/etc/grub.conf"%anaconda.rootPath) + os.system("cat %s/etc/grub.conf"%anaconda.rootPath) + + + # copy necessary grub files + log.info("livefs mode - need to write MBR") + os.system("cp %s/usr/share/grub/i386-redhat/*stage* %s/boot/grub/"%(anaconda.rootPath, anaconda.rootPath)) + # install grub +# if useMBR: +# grubMbrParam = "(hd0)" +# else: +# grubMbrParam = grubDev +### FIXME hardcode +# f = os.popen("/usr/sbin/chroot %s /sbin/grub --verbose --batch --device-map=/dev/null", "w"%(anaconda.rootPath)) + f = os.popen("/usr/sbin/chroot /mnt/sysimage /sbin/grub --verbose --batch --device-map=/dev/null", "w") + f.write("device (hd0) %s\n"%diskDeviceFile) + f.write("root %s\n"%grubDev) +# f.write("setup --stage2=/boot/grub/stage2 --prefix=/boot/grub (hd0)\n") +# f.write("setup --stage2=/grub/stage2 --prefix=/grub (hd0)\n") + f.write("setup (hd0)\n") + f.write("quit\n") + f.flush() + f.close() + log.info("livefs mode - DONE") + + else: + + # rebuild the initrd(s) + vers = self.kernelVersionList() + for (n, arch, tag) in vers: + packages.recreateInitrd(n, anaconda.rootPath) def writeConfiguration(self): pass livefs.py: #Jerry's anaconda init import os,sys import isys import string import iutil from flags import flags # Lets get some loops isys.makeDevInode("loop1", "/tmp/loop1") isys.makeDevInode("loop2", "/tmp/loop2") isys.makeDevInode("loop3", "/tmp/loop3") isys.makeDevInode("loop4", "/tmp/loop4") # set livefs flag flags.livefs = "1" # Look for squash #imgpath = None #imglist = [ "/mnt/source/LiveOS/squashfs.img", "/mnt/source/squashfs.img" ] #for p in imglist: # if (os.access(p, os.X_OK)): # imgpath = p #if os.access("/mnt/source/LiveOS/squashfs.img", os.R_OK) # imgpath = "/mnt/source/LiveOS/squashfs.img" #if os.access("/mnt/source/squashfs.img", os.R_OK): # imgpath = "/mnt/source/squashfs.img" # found squash HACK hard code.... Got to work on those skills..... # isys.losetup("/tmp/loop3", "%s", readOnly = 1 %imgpath) isys.losetup("/tmp/loop3", "/mnt/source/LiveOS/squashfs.img", readOnly = 1) os.mkdir("/squashfs") isys.mount("/tmp/loop3", "/squashfs", fstype = 'squashfs', readOnly = 1) isys.losetup("/tmp/loop4", "/squashfs/os.img", readOnly = 1) os.system("ln -s /tmp/loop4 /dev/live-osimg") break # Look for ext3 #imgpath = None #imglist = [ "/mnt/source/LiveOS/ext3fs.img", "/mnt/source/ext3fs.img" ] #for p in imglist: # if (os.access(p, os.X_OK)): # imgpath = p # break #if os.access("/mnt/source/LiveOS/ext3fs.img", os.R_OK) # imgpath = "/mnt/source/LiveOS/ext3fs.img" #if os.access("/mnt/source/ext3fs.img", os.R_OK): # imgpath = "/mnt/source/ext3fs.img" # found ext3 for sysroot # isys.losetup("/tmp/loop4", imgpath , readOnly = 1) # isys.losetup("/tmp/loop4", "/mnt/source/ext3fs.img", readOnly = 1) # os.system("ln -s /tmp/loop4 /dev/live-osimg")