<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body bgcolor=white lang=EN-US link=blue vlink=purple>

<div class=Section1>

<div>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>If you will have access to the network before and during the
upgrade, you could probably gather the partition/LVM information before the
upgrade, post it somewhere, wget it in the %pre and use it to mount your drives. 
I haven’t tried any of this, but common sense tells me it should be
doable.</span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p></o:p></span></p>

</div>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";
color:windowtext'>From:</span></b><span style='font-size:10.0pt;font-family:
"Tahoma","sans-serif";color:windowtext'> kickstart-list-bounces@redhat.com
[mailto:kickstart-list-bounces@redhat.com] <b>On Behalf Of </b>Matt Rose<br>
<b>Sent:</b> Tuesday, August 25, 2009 11:27 AM<br>
<b>To:</b> Discussion list about Kickstart<br>
<b>Subject:</b> Re: CentOS upgrade - access to chroot in %pre?<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>quick,
non-tested sample code to give you an idea, the following *WILL NOT* work on
your machine, unless you're  really lucky and have your root partition as
the second partition on the first hard drive. <br>
<br>
Even if it does work, it won't really do anything.<br>
<br>
%pre --interpreter /usr/bin/python --erroronfail --log=/tmp/kspre.log<br>
import sys,os,time,shutil,parted,re,subprocess,zipfile<br>
sys.path.append("/usr/lib/anaconda")<br>
import isys,iutil<br>
<br>
### This finds the first hard drive<br>
drive = isys.hardDriveDict().keys()[0]<br>
<br>
### The following will mount the second partition on the first harddrive as
/tmp/sysimage<br>
rootloc = "/tmp/sysimage"<br>
os.makedirs(rootloc)<br>
rootdrive = "/dev/%s2" % drive<br>
isys.mount(rootdrive,rootloc,fstype="ext3")<br>
<br>
###The following does some work to set up a somewhat sane chroot environment<br>
os.system("chmod 644 /dev/null")<br>
isys.mount("/dev","/tmp/sysimage/dev",fstype="tmpfs")<br>
isys.mount("/proc","/tmp/sysimage/proc",fstype="proc")<br>
isys.mount("/selinux","/tmp/sysimage/selinux",fstype="selinuxfs")<br>
<br>
###The following function lets you open up subprocesses in the chroot
environment<br>
def chroot():<br>
    os.chroot(rootloc)<br>
<br>
###The following runs an rpm command to check the release in the chroot<br>
subprocess.Popen("rpm -qa  
*release",preexec_fn=chroot,shell=True,stdout=subprocess.PIPE).stdout.read()<br>
<br>
###Cleanup<br>
isys.umount("/tmp/sysimage/dev")<br>
isys.umount("/tmp/sysimage/proc")<br>
isys.umount("/tmp/sysimage/selinux")<br>
isys.umount("/tmp/sysimage")<br>
<br>
<br>
</span><br>
<br>
<br>
Matt Rose wrote: <o:p></o:p></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Yes,
on upgrade, but it's not easy.  You have to detect and mount the partitions
by hand.  If you know some python, you can include the anaconda libs and
helper functions, but if you're just using sh, you'd have one hell of a %pre
script.<br>
<br>
Matt<br>
</span><br>
Moray Henderson (ICT) wrote: <o:p></o:p></p>

<pre>Hi everyone,<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Is it possible to make the /mnt/sysimage/... chroot available to the %pre script of a CentOS 5.3 upgrade?<o:p></o:p></pre><pre><o:p> </o:p></pre><pre><o:p> </o:p></pre><pre>Moray.<o:p></o:p></pre><pre>"To err is human.  To purr, feline"<o:p></o:p></pre><pre><o:p> </o:p></pre><pre><o:p> </o:p></pre><pre><o:p> </o:p></pre><pre>_______________________________________________<o:p></o:p></pre><pre>Kickstart-list mailing list<o:p></o:p></pre><pre><a
href="mailto:Kickstart-list@redhat.com">Kickstart-list@redhat.com</a><o:p></o:p></pre><pre><a
href="https://www.redhat.com/mailman/listinfo/kickstart-list">https://www.redhat.com/mailman/listinfo/kickstart-list</a><o:p></o:p></pre><pre>  <o:p></o:p></pre></div>

</body>

</html>