How to determine "internal" disk dynamically in kickstart/cheetah snippet

Parthasarathy, Balaji (BCS, Cupertino, USA) balaji.parthasarathy at hp.com
Wed Jun 20 23:54:53 UTC 2012


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/kickstart-list/attachments/20120620/c74bd1cc/attachment.htm>


More information about the Kickstart-list mailing list