[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cobbler
Subject:    Re: [cobbler] How to determine "internal" disk in a Cobbler	snippet/kickstart
From:       "Mann, Owen" <Owen.Mann () interactivedata ! com>
Date:       2012-06-21 13:47:49
Message-ID: E50FE78F81072D408BA2F29BBDDE0DDE268D34AA () swpma1exmail02 ! idco ! intdata ! com
[Download RAW message or body]

That's a good one. I don't know of anything in the SCSI standard that might say \
whether a disk is internal or not. My only thought is use controller or \
enclosure-specific commands to determine if the port or backplane the disk is \
connected to is an external type. The caveats are that you need hardware-specific \
knowledge of what you might expect to find, and the utilities for that (e.g. \
hpacucli/megacli and sg_safte).

Owen Mann, Interactive Data Real Time Services
60 Codman Hill Rd, Boxborough, MA 01719
978-795-3758 owen.mann@interactivedata.com<mailto:owen.mann@interactivedata.com>

From: cobbler-bounces@lists.fedorahosted.org \
[mailto:cobbler-bounces@lists.fedorahosted.org] On Behalf Of Parthasarathy, Balaji \
                (BCS, Cupertino, USA)
Sent: Wednesday, June 20, 2012 8:03 PM
To: cobbler@lists.fedorahosted.org
Subject: [cobbler] How to determine "internal" disk in a Cobbler snippet/kickstart

Hi,
When I install a system using Cobbler using kickstart/snippet, I want to only do the \
partitioning of

1.       Internal only disk

2.       Only one disk, if multiple exist

3.       Handle RAID/non-RAID scenarios

Is there a good/reliable way in Linux (RHEL and Fedora specifically) to determine #1? \
Since we are in the installation environment, some commands (like lsscsi) aren’t \
available. Here’s what I’m using in my snippet currently.

======== BEGIN SNIPPET ============
# Look for any 'scsi' or 'cciss' device; weed out output with partitions of those
# devices (part) and cd/dvd devices (sr); grab the first line of the remaining \
output. # Assumption is first scsi device is "internal" disk. We want to partition \
only # the first internal disk.
ls_output=\$(ls -l /dev/disk/by-path/pci* | grep -i -e scsi -e cciss | grep -v -i -e \
part -e sr | head -n 1)

# If we did not get any proper data for disk devices, just let anaconda do auto \
partitioning # and use all/whatever disks anaconda finds, rather than throw an error.
if [[ -z "$ls_output" ]]
then
  ks_partition_cmd=""
else
  # NOTE: we are parsing a output that looks like this:
  #     lrwxrwxrwx. 1 root root 9 Jun 18 13:01 \
/dev/disk/by-path/pci-0000:0c:00.0-scsi-0:0:0:1 -> ../../sda  device_symlink=\$(echo \
\$ls_output | awk '{print \$11}')

  if [[ ! -z \$(echo \$device_symlink | grep -i sd) ]]
  then
    # The first internal disk is a non-RAID disk.
    # Remove the "../../" prefix in "../../sda"
    first_internal_disk_name=\${device_symlink\#\#*/}
  else
    # The first internal disk is a RAID disk.
    # Remove the "../../" prefix in "../../cciss/c0d0"
    first_internal_disk_name=\$(echo \$device_symlink | awk -F'/' '{print \
\$(NF-1)"/"\$NF}')  fi

  ks_partition_cmd="ignoredisk --only-use=\$first_internal_disk_name"

fi



# Allow anaconda to partition the system as needed
# using just the first disk

cat <<PART_EOF > /tmp/partition_info

autopart
$ks_partition_cmd

PART_EOF
======== END SNIPPET ============


Thanks
Balaji


*******************************************************
This message (including any files transmitted with it) may contain confidential \
and/or proprietary information, is the property of Interactive Data Corporation \
and/or its subsidiaries, and is directed only to the addressee(s). If you are not the \
designated recipient or have reason to believe you received this message in error, \
please delete this message from your system and notify the sender immediately. An \
unintended recipient's disclosure, copying, distribution, or use of this message or \
                any attachments is prohibited and may be unlawful. 
*******************************************************


[Attachment #3 (unknown)]

<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:x="urn:schemas-microsoft-com:office:excel" \
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=Windows-1252">
<meta name="Generator" content="Microsoft Word 14 (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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
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;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{mso-style-priority:34;
	margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:.5in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	color:black;}
span.EmailStyle18
	{mso-style-type:personal;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
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 WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
/* List Definitions */
@list l0
	{mso-list-id:1954481966;
	mso-list-type:hybrid;
	mso-list-template-ids:1993138776 67698703 67698713 67698715 67698703 67698713 \
67698715 67698703 67698713 67698715;} @list l0:level1
	{mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level2
	{mso-level-number-format:alpha-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level3
	{mso-level-number-format:roman-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:right;
	text-indent:-9.0pt;}
@list l0:level4
	{mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level5
	{mso-level-number-format:alpha-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level6
	{mso-level-number-format:roman-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:right;
	text-indent:-9.0pt;}
@list l0:level7
	{mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level8
	{mso-level-number-format:alpha-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;}
@list l0:level9
	{mso-level-number-format:roman-lower;
	mso-level-tab-stop:none;
	mso-level-number-position:right;
	text-indent:-9.0pt;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--></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 lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">That's a good one. I don't know of \
anything in the SCSI standard that might say whether a disk is internal or not. My \
only thought is use controller or enclosure-specific commands to determine if the \
port or  backplane the disk is connected to is an external type. The caveats are that \
you need hardware-specific knowledge of what you might expect to find, and the \
utilities for that (e.g. hpacucli/megacli and sg_safte). <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div>
<p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#1F497D">Owen \
Mann, Interactive Data Real Time Services<br> 60 Codman Hill Rd, Boxborough, MA \
01719<br> 978-795-3758 <a \
href="mailto:owen.mann@interactivedata.com">owen.mann@interactivedata.com</a></span><span \
style="font-size:10.0pt;font-family:&quot;Courier \
New&quot;;color:#1F497D"><o:p></o:p></span></p> </div>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</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:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span \
style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> \
cobbler-bounces@lists.fedorahosted.org \
[mailto:cobbler-bounces@lists.fedorahosted.org] <b>On Behalf Of </b>Parthasarathy, \
Balaji (BCS, Cupertino, USA)<br> <b>Sent:</b> Wednesday, June 20, 2012 8:03 PM<br>
<b>To:</b> cobbler@lists.fedorahosted.org<br>
<b>Subject:</b> [cobbler] How to determine &quot;internal&quot; disk in a Cobbler \
snippet/kickstart<o:p></o:p></span></p> </div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal">When I install a system using Cobbler using kickstart/snippet, I \
want to only do the partitioning of<o:p></o:p></p> <p class="MsoListParagraph" \
style="text-indent:-.25in;mso-list:l0 level1 lfo2"><![if !supportLists]><span \
style="mso-list:Ignore">1.<span style="font:7.0pt &quot;Times New \
Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif]>Internal \
only disk<o:p></o:p></p> <p class="MsoListParagraph" \
style="text-indent:-.25in;mso-list:l0 level1 lfo2"><![if !supportLists]><span \
style="mso-list:Ignore">2.<span style="font:7.0pt &quot;Times New \
Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif]>Only one \
disk, if multiple exist<o:p></o:p></p> <p class="MsoListParagraph" \
style="text-indent:-.25in;mso-list:l0 level1 lfo2"><![if !supportLists]><span \
style="mso-list:Ignore">3.<span style="font:7.0pt &quot;Times New \
Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><![endif]>Handle \
RAID/non-RAID scenarios<o:p></o:p></p> <p class="MsoNormal">&nbsp;<o:p></o:p></p>
<p class="MsoNormal">Is there a good/reliable way in Linux (RHEL and Fedora \
specifically) to determine #1? Since we are in the installation environment, some \
commands (like lsscsi) aren’t available. Here’s what I’m using in my snippet \
currently.<o:p></o:p></p> <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">======== BEGIN SNIPPET ============<o:p></o:p></p>
<p class="MsoNormal"># Look for any 'scsi' or 'cciss' device; weed out output with \
partitions of those <o:p></o:p></p>
<p class="MsoNormal"># devices (part) and cd/dvd devices (sr); grab the first line of \
the remaining output.<o:p></o:p></p> <p class="MsoNormal"># Assumption is first scsi \
device is &quot;internal&quot; disk. We want to partition only<o:p></o:p></p> <p \
class="MsoNormal"># the first internal disk.<o:p></o:p></p> <p \
class="MsoNormal">ls_output=\$(ls -l /dev/disk/by-path/pci* | grep -i -e scsi -e \
cciss | grep -v -i -e part -e sr | head -n 1)<o:p></o:p></p> <p \
class="MsoNormal"><o:p>&nbsp;</o:p></p> <p class="MsoNormal"># If we did not get any \
proper data for disk devices, just let anaconda do auto partitioning<o:p></o:p></p> \
<p class="MsoNormal"># and use all/whatever disks anaconda finds, rather than throw \
an error.<o:p></o:p></p> <p class="MsoNormal">if [[ -z &quot;$ls_output&quot; \
]]<o:p></o:p></p> <p class="MsoNormal">then<o:p></o:p></p>
<p class="MsoNormal">&nbsp; ks_partition_cmd=&quot;&quot;<o:p></o:p></p>
<p class="MsoNormal">else<o:p></o:p></p>
<p class="MsoNormal">&nbsp; # NOTE: we are parsing a output that looks like \
this:<o:p></o:p></p> <p class="MsoNormal">&nbsp; #&nbsp;&nbsp;&nbsp;&nbsp; \
lrwxrwxrwx. 1 root root 9 Jun 18 13:01 \
/dev/disk/by-path/pci-0000:0c:00.0-scsi-0:0:0:1 -&gt; ../../sda<o:p></o:p></p> <p \
class="MsoNormal">&nbsp; device_symlink=\$(echo \$ls_output | awk '{print \
\$11}')<o:p></o:p></p> <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">&nbsp; if [[ ! -z \$(echo \$device_symlink | grep -i sd) \
]]<o:p></o:p></p> <p class="MsoNormal">&nbsp; then<o:p></o:p></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp; # The first internal disk is a non-RAID \
disk.<o:p></o:p></p> <p class="MsoNormal">&nbsp;&nbsp;&nbsp; # Remove the \
&quot;../../&quot; prefix in &quot;../../sda&quot;<o:p></o:p></p> <p \
class="MsoNormal">&nbsp;&nbsp;&nbsp; \
first_internal_disk_name=\${device_symlink\#\#*/}<o:p></o:p></p> <p \
class="MsoNormal">&nbsp; else<o:p></o:p></p> <p class="MsoNormal">&nbsp;&nbsp;&nbsp; \
# The first internal disk is a RAID disk.<o:p></o:p></p> <p \
class="MsoNormal">&nbsp;&nbsp;&nbsp; # Remove the &quot;../../&quot; prefix in \
&quot;../../cciss/c0d0&quot;<o:p></o:p></p> <p class="MsoNormal">&nbsp;&nbsp;&nbsp; \
first_internal_disk_name=\$(echo \$device_symlink | awk -F'/' '{print \
\$(NF-1)&quot;/&quot;\$NF}')<o:p></o:p></p> <p \
class="MsoNormal">&nbsp;fi<o:p></o:p></p> <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">&nbsp; ks_partition_cmd=&quot;ignoredisk \
--only-use=\$first_internal_disk_name&quot;<o:p></o:p></p> <p \
class="MsoNormal"><o:p>&nbsp;</o:p></p> <p class="MsoNormal">fi<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"># Allow anaconda to partition the system as \
needed<o:p></o:p></p> <p class="MsoNormal"># using just the first disk<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">cat &lt;&lt;PART_EOF &gt; /tmp/partition_info<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">autopart<o:p></o:p></p>
<p class="MsoNormal">$ks_partition_cmd<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">PART_EOF<o:p></o:p></p>
<p class="MsoNormal">======== END SNIPPET ============<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Thanks<o:p></o:p></p>
<p class="MsoNormal">Balaji<o:p></o:p></p>
</div>
<font face="monospace"><br>
<br>
*******************************************************<br>
This message (including any files transmitted with it) may contain confidential \
and/or proprietary information, is the property of Interactive Data Corporation \
and/or its subsidiaries, and is directed only to the addressee(s). If you are not the \
designated recipient or have reason to believe you received this message in error, \
please delete this message from your system and notify the sender immediately. An \
unintended recipient's disclosure, copying, distribution, or use of this message or \
                any attachments is prohibited and may be unlawful. <br>
*******************************************************</font></body>
</html>


[Attachment #4 (unknown)]

_______________________________________________
cobbler mailing list
cobbler@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/cobbler


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic