Mann, Owen | 21 Jun 2012 15:47
Favicon

Re: How to determine "internal" disk in a Cobbler snippet/kickstart

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 <at> interactivedata.com

 

From: cobbler-bounces <at> lists.fedorahosted.org [mailto:cobbler-bounces <at> lists.fedorahosted.org] On Behalf Of Parthasarathy, Balaji (BCS, Cupertino, USA)
Sent: Wednesday, June 20, 2012 8:03 PM
To: cobbler <at> 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.
*******************************************************
_______________________________________________
cobbler mailing list
cobbler <at> lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/cobbler

Gmane