[Casper] disk identifiers

Miles Leacy miles.leacy at themacadmin.com
Tue Dec 30 08:39:01 PST 2008


I've tapped many resources, and it seems that Apple simply doesn't make the
"boot-time bus scan order" (for lack of a better term) available to the
public.  So, not to be thwarted, I've come up with the following script.  It
checks each disk sequentially, starting with disk0, to see if it is an
internal disk.  When two internal disks are found, it creates a mirror from
those disks.
#!/bin/sh
#
##### HEADER BEGINS #####
# scr_sys_createServerMirror.sh
#
# Created 20081230 by Miles A. Leacy IV
# miles.leacy at themacadmin.com
# Modified 20081230 by Miles A. Leacy IV
# Copyright 2008 Miles A. Leacy IV
#
# This script may be copied and distributed freely as long as this header
remains intact.
#
# This script is provided "as is".  The author offers no warranty or
guarantee of any kind.
# Use of this script is at your own risk.  The author takes no
responsibility for loss of use,
# loss of data, loss of job, loss of socks, the onset of armageddon, or any
other negative effects.
#
# Test thoroughly in a lab environment before use on production systems.
# When you think it's ok, test again.  When you're certain it's ok, test
twice more.
#
# This script creates a mirrored RAID volume from the first two internal
disks found.
# It is intended for use on Xserves with two or more identical internal
disks.
# Run as a "before" script when imaging with Casper.
#
##### HEADER ENDS #####

i=0
diskcount=0

while [ $diskcount -lt 3 ]; do
if [ `diskutil info disk$diskcount | grep Internal | grep -c Yes` -gt 0 ]
;then
if [ $i -eq 0 ] ; then
 raiddisk1=disk$diskcount
fi
 if [ $i -eq 1 ] ; then
raiddisk2=disk$diskcount
fi
 let i++
fi
let diskcount++
done

diskutil createRAID mirror Server\ HD JHFS+ $raiddisk1 $raiddisk2






----------
Miles A. Leacy IV

 Certified System Administrator 10.4
 Certified Technical Coordinator 10.5
 Certified Trainer
Certified Casper Administrator
----------
voice: 1-347-277-7321
miles.leacy at themacadmin.com
www.themacadmin.com




On Fri, Dec 19, 2008 at 5:37 PM, Miles Leacy <miles.leacy at themacadmin.com>wrote:

> Thanks for the links!  These will be most helpful.
> I never would have thought of these things myself except that I'm currently
> in charge of Mac servers for one of the world's biggest media companies.  We
> deploy Xserves like some small to mid-size companies deploy desktop Macs,
> and I want to go into the data centers as infrequently as possible.
>
> I've been booting various Macs from various devices with various other
> devices attached today, and this completely un-scientific test has told me
> that I have yet to see "disk0" be assigned to anything other than an
> internal hard drive.  I am going to operate under the assumption that disks
> 0, 1 & 2 will be the internal HDDs for now, though I hate being uncertain.  Computers
> do exactly what you tell them to do, so you should be certain of what you
> tell them.
>
> ----------
> Miles A. Leacy IV
>
>  Certified System Administrator 10.4
>  Certified Technical Coordinator 10.5
>  Certified Trainer
> Certified Casper Administrator
> ----------
> voice: 1-347-277-7321
> miles.leacy at themacadmin.com
> www.themacadmin.com
>
>
>
>
> On Fri, Dec 19, 2008 at 5:21 PM, Steve Wood <swood at integerdallas.com>wrote:
>
>>  Wow, that's a pretty cool idea there.  I wish I had thought of it.  Of
>> course, I have 4 servers to worry about and they are all 10 feet from my
>> office.
>>
>> I'm not sure if you need to be a Self Servicing account, or a service
>> provider (i.e. GSX access) to see this URL, but this is how you can set the
>> drive on an Xserve G5:
>>
>> http://support.apple.com/kb/TA26930?locale=en_US
>>
>> And, I wasn't able to find the same thing for Intel, but I did find this
>> link in a TUAW article (
>> http://www.tuaw.com/2008/11/24/apple-xserve-field-guide/):
>>
>> http://help.apple.com/server/guide/desktop.html
>>
>> Cool thing is, that guide is also available on the iPhone (look at the
>> TUAW article for info).
>>
>> Using the guide, go to Startup then Other Methods and it explains how to
>> set the startup method.  You could use this to tell the server to ignore the
>> normal boot up procedures.
>>
>> I also found this article on AFP548 about setting up headless:
>>
>> http://www.afp548.com/articles/system/headlessg5.html
>>
>> *
>> Steve Wood
>> Director of IT
>> *swood at integerdallas.com
>>
>> The Integer Group | 1999 Bryan St. | Ste. 1700 | Dallas, TX 75201
>> T 214.758.6813 | F 214.758.6901 | C 940.312.2475
>>
>>
>>
>> ------------------------------
>> *From: *Miles Leacy <miles.leacy at themacadmin.com>
>> *Date: *Fri, 19 Dec 2008 16:26:20 -0500
>> *To: *Thomas Larkin <tlarki at kckps.org>
>> *Cc: *"casper at list.jamfsoftware.com" <casper at list.jamfsoftware.com>
>> *Subject: *Re: [Casper] disk identifiers
>>
>> Ok, here's the scenario...
>>
>> All Xserves are purchased with three 80GB SATA drives.  I want to have
>> zero-touch server deployment.  The boot drive is to be a RAID 1 called
>> "Server HD".
>>
>> In order to make this happen, I plan to:
>> 1. Set up a prestage
>> 2. Boot from a USB flash drive containing a restore image that runs Casper
>> Imaging automatically.
>> 3. Deploy a configuration with a "before" script that uses diskutil to
>> create a RAID 1 from two of the three internal drives.
>>
>> The script uses the command:
>> diskutil createRAID mirror Server\ HD JHFS+ disk0 disk1
>>
>> In order for this to work, I need to know that I can count on the USB
>> drive never being assigned the disk identifiers "disk0" or "disk1".  Or at
>> least know what the rules governing disk identifier assignment are so I can
>> adjust the script accordingly.  I know what drives will be attached at first
>> boot, so once I know those rules, I can have a reliable script.
>>
>> In case you're saying to yourself "He said there are three drives.  What's
>> he doing with the third one?", I'm keeping that as a hot spare to rebuild
>> the mirror in case one of the other disks fail.
>>
>> I'm considering how to automate that too.  The basic logic so far is:
>> 1. On every15, a policy runs a script that checks for a degraded mirror.
>> 2. If a degraded mirror is found, the script issues a custom trigger which
>> runs a policy that deploys an empty receipt that is the criteria for
>> membership in a "Failed Mirror" smart group.  The same policy includes a
>> "diskutil repairMirror" script that checks itself for success.  If
>> successful, a third policy is triggered by custom trigger.
>> 3. The third policy deploys an empty receipt which is criteria for
>> membership in a "Repaired Mirror" smart group.
>> 4. Notification is sent on joining either of the two smart groups above.
>>
>> This way, I don't get woken up at 2AM for a degraded mirror.  I get an
>> email the next day and I have the bad drive replaced, which becomes the new
>> hot spare.  None of this has been tested yet,  I've just sketched the logic
>> on a legal pad so far.
>>
>> One other hitch I've found in the zero-touch scenario is getting the
>> machines to boot from USB rather than the factory-installed OS.  I suppose I
>> could have my reseller erase the internal drives before shipping.  I don't
>> have a better idea on that.  Even using netboot requires attaching a
>> keyboard and holding the "N" key.  With blank hard drives and a bootable USB
>> key, you're truly zero-touch (other than having part of the rackmount
>> procedure be "insert USB drive").  I'll leave the USB drives attached as
>> restore & diagnostics boot drives.
>>
>> ----------
>> Miles A. Leacy IV
>>
>>  Certified System Administrator 10.4
>>  Certified Technical Coordinator 10.5
>>  Certified Trainer
>> Certified Casper Administrator
>> ----------
>> voice: 1-347-277-7321
>> miles.leacy at themacadmin.com
>> www.themacadmin.com <http://www.themacadmin.com>
>>
>>
>>
>>
>> On Fri, Dec 19, 2008 at 3:34 PM, Thomas Larkin <tlarki at kckps.org> wrote:
>>
>>
>>
>>
>>  I would assume it reads it from EFI (firmware) and then by bus for
>> internals and externals just get the next available when plugged in.  You
>> could always try looping your scripts
>>
>>
>>
>>  like
>>
>>
>>
>>  for i in /usr/sbin/diskutil list
>>
>>
>>
>>  if $i = something
>>
>>
>>  then do something
>>
>>
>>  else exit
>>
>>
>>  fi
>>
>>
>>
>>  to give a really rough example...
>>
>>
>> ___________________________
>> Thomas Larkin
>> TIS Department
>> KCKPS USD500
>> tlarki at kckps.org
>> blackberry:  913-449-7589
>> office:  913-627-0351
>>
>>
>>
>>
>>
>> >>> "Miles Leacy" <miles.leacy at themacadmin.com> 12/19/08 11:33 AM >>>
>> Hey all,
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>  I know that disk identifiers (disk0, disk1, etc) are assigned in the
>> order in which the disks were attached.  For example, if you boot a Mac with
>> a single internal drive, that drive will be disk0.  Once booted, you can
>> insert an optical disk, and the optical disk will be called disk1.  If you
>> later plug in a USB disk, the USB disk will be disk2.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>  I'm trying to find out the order in which disk identifiers are assigned
>> at boot time.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>  For example, if you have an Xserve with three internal hard disks, an
>> optical disk inserted, and a USB drive attached, can you count on the
>> internal disks having the disk0, disk1, and disk2 identifiers?  What
>> identifiers would the optical and USB disks get?
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>  I'm guessing there's an order of precedence by bus, but is this
>> documented somewhere?  I've been flipping through Mac OS X Internals by Amit
>> Singh and haven't found the answer yet.  most of the comments I've found by
>> googling assume that disk identifier assignment is a form of voodoo.  This
>> is a computer, not a witches' brew, so there has to be a set of rules that
>> govern disk identifier assignment, and I'm hoping someone on the list knows
>> what those rules are.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>  I ask because I want to implement some diskutil scripts, but I need to
>> know whether my assumption that SATA (or at least internal hard) disks
>> always get the lowest disk identifiers at boot is true.
>>
>>
>>
>>
>>
>>  ----------
>> Miles A. Leacy IV
>>
>>  Certified System Administrator 10.4
>>  Certified Technical Coordinator 10.5
>>  Certified Trainer
>> Certified Casper Administrator
>> ----------
>> voice: 1-347-277-7321
>> miles.leacy at themacadmin.com
>> www.themacadmin.com <http://www.themacadmin.com>
>>
>>
>>
>>
>>
>>
>>
>>
>> ------------------------------
>> _______________________________________________
>> Casper mailing list
>> Casper at list.jamfsoftware.com
>> http://list.jamfsoftware.com/mailman/listinfo/casper
>>
>>
>> ------------------------------
>> --
>>
>> The information contained in this email transmission is solely for the addressee(s) named above and is privileged and/or confidential.  If the reader of this message is not the intended recipient or the person responsible to deliver it to the intended recipient; he or she is prohibited from reading or disclosing the information contained in this transmission.  Any examination, use, dissemination, distribution, or copying of this communication is strictly prohibited.  Please contact us immediately by telephone for instructions if you have received this communication in error: (214) 758-6800
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.jamfsoftware.com/pipermail/casper/attachments/20081230/e70271ee/attachment.htm 


More information about the Casper mailing list