Booting from another drive
Boot into PROM monitor, and perform the following commands:
setenv SystemPartition scsi(0)disk(2)rdisk(0)partition(8)
setenv OSLoadPartition scsi(0)disk(2)rdisk(0)partition(0)
setenv root dks0d2s0
Then when you load the miniroot in the install process, you
will be pointed to the drive you want(obviously the disk and
root must be set to the correct IDs, not necessarily the above).
Also, if you ever need to do a one-time boot off an alternate
drive, you can boot the PROM monitor and issue the following
command:
boot -f dksc(0,2,8)sash dksc(0,2,0)unix root=dks0d2s0
This is useful if you are installing/configuring multiple systems
using a build disk.
Disk Clone Script (use with extreme
caution it)
This is taken from the google cache (the original page no longer
exists).
Information on the script taken from the original web page
is here followed by the original script (save to file, chmod
+x it and then run it).
The Solution -- SCSI Cloning
The modern SGI models (O2's, OCTANEs, and Origins/Onyx2's) all
feature sled-mounted internal SCSI drives that get their ID
number from the slot that they are placed in. Better yet, with
the exception of the R10K/R12K O2) all the machines have an
available internal slot for a second disk (in the high-end O2
the larger CPU takes up the second disk slot).
With a little scripting it's possible to use the second disk
slot to build a ``clone'' of the system disk in 10-15 minutes.
This cloned disk can be moved to another machine (thus allowing
rapid duplication of a ``lab's worth'' of system disks) or kept
on hand as a backup in case of disk failure.
One of the many advantages to this is better security. The sysadmin
can bring up a single workstation and configure it as necessary
(closing the ``deadly 7'' open accounts, installing tcp wrappers
and ssh, turning off unnecessary services, etc) before it is
placed on the network. Clones of the system then inherit the
secure configuration without going through a ``window of vulnerability''
during the network installation/configuration.
The dupit Script
My cloning script is named "dupit'' (the name borrowed
from a script with a similar function that was in use internally
at SGI). Without options the script makes a copy of the current
system disk (drive 1) on drive two (though the destination drive
can be specified with the -d flag. The script also:
Repartitions the drive so that the swap partition is 256 MB.
The default can be changed by editing the script, or the user
can specify any size in MB using the -s flag.
Turns off networking on the new system (so that the admin can
reconfigure it once the new workstation is brought up. The -c
flag will defeat this and make the cloned disk an exact copy
of the current system disk (useful when making a backup system
disk).
The script runs correctly in both single-user and multi-user
states, though I usually use single user mode to help insure
the duplication (most of which is accomplished using xfsdump)
goes smoothly. When using it to install lab machines, I usually
make a single ``test machine'' with the dupit script installed
at /etc/dupit that is left running in the lab for students and
faculty to use. Once I'm sure the test machine works as designed,
I then use it as a ``master'' to create clone disk(s), which
I can install in other workstations. Bringing up a cloan is
as simple as booting, login in as root and configuring networking.
Since all machines have dupit installed, I can ``rebuild'' a
crashed disk from any working machine in the lab.
The Source
#!/bin/sh
# the magical, mystical dupit script
# All new sh version by D. Southard
# comments to dsouth@nd.edu
# Defaults
KLOANDEV=dks0d2s0
SWAPMB=256
#
# Get the options/parameters to the program
#
while getopts cs:d: i
do
case $i in
c) EXACTCOPY="yes"
;;
s) SWAPMB=${OPTARG}
;;
d) KLOANDEV=${OPTARG}
;;
*) echo "the magical, mystical, dupit script"
echo "all new by Dale Southard <dsouth@nd.edu>"
echo "Usage:"
echo " dupit -c [-s <swap in MB>] [-d <cloan's
dks?d?s?>]"
exit 1
;;
esac
done
#
# Sanity check the destination drive
#
if ! [ -c /dev/rdsk/${KLOANDEV} ] ; then
echo "The destination device must exist <dks?d?s0>"
exit
elif [ ${KLOANDEV} != ${KLOANDEV%s0}s0 ] ; then
echo "The destinaion device must be lun 0 <dks?d?s0>"
exit
fi
umount /dev/dsk/${KLOANDEV} > /dev/null 2>&1
#
# Create the temporary fx script file
#
FXSCRIPT=/var/tmp/fx.script
rm -rf $FXSCRIPT
echo "${KLOANDEV} standard root" >>
$FXSCRIPT
if [ $SWAPMB != "" ] ; then
SWAPBLKS=`expr $SWAPMB \* 2048`
echo "${KLOANDEV%s0}s1 followspart8:${SWAPBLKS} swap"
>> $FXSCRIPT
echo "${KLOANDEV} followspart1:remainder xfs" >>
$FXSCRIPT
fi
#
# Repartition the drive based on the script
#
/usr/bin/fx -x -s $FXSCRIPT
rm -rf $FXSCRIPT
#
# Create the file system and mount it
#
/sbin/mkfs_xfs /dev/rdsk/${KLOANDEV}
if ! [ -d /mnt ] ;then
mkdir /mnt
fi
mount /dev/dsk/${KLOANDEV} /mnt
#
# Dump the source drive to the destination drive
#
hostname `cat /etc/sys_id`
xfsdump -J -l 0 - / | xfsrestore - /mnt
#
# Copy the volume header files.
#
VOLHDR_FILES=`dvhtool -v list | grep -v File | grep
-v Current | grep -v sgilabel | grep -v '^$' | awk '{} {printf
"%s ",$1}'`
for VHFILE in $VOLHDR_FILES; do
rm -rf /var/tmp/$VHFILE
dvhtool -v get $VHFILE /var/tmp/$VHFILE /dev/rdsk/dks0d1vh
dvhtool -v create /var/tmp/$VHFILE $VHFILE /dev/rdsk/${KLOANDEV%s0}vh
rm /var/tmp/$VHFILE
done
#
# If we are making an exact clone, skip the rest
#
if ! [ ${EXACTCOPY} = "yes" ]; then
#
# Turn off networking on the new disk
#
echo "off" > /mnt/etc/config/network
# If your site needs anyting else removed/turned off
# (ssh_host_key, AFS/DFS, etc) this would be a
# good place to do it.
fi
#
# Done.
#
echo " "
echo "You're done. shutdown, move the disk and configure
networking."
exit 0
Adding / Preparing Disks under IRIX
From http://www.uwsg.iu.edu/usail/peripherals/disks/adding/sgi.html
Adding Disks under IRIX
Once the disk has been physically installed and the machine
has been rebooted, the hinv command can be used to check if
it is recognized:
# hinv | grep Disk
Disk drive: unit 5 on SCSI controller 0
Disk drive: unit 1 on SCSI controller 0
Under IRIX, device nodes are in the format /dev/[r]dsk/dksSdDsS,
where S is the disk controller number, D is the SCSI ID of the
disk, and S is the partition number. In our example, we'll be
working with the disk on SCSI ID 5, so we will use /dev/[r]dsk/dks0d5s*.
Labeling the Disk The fx command is used to label and partition
the disk. It should be invoked in expert mode, using the -x
option:
edcert23 2# fx -x
fx version 5.3, Oct 18, 1994
fx: "device-name" = (dksc)
fx: ctlr# = (0)
fx: drive# = (1) 5
...opening dksc(0,5,)
...controller test...OK
Scsi drive type == HP C3724S 5153
fx: Warning: no sgilabel on disk
fx: Warning: can't read sgilabel on disk
creating new sgilabel
----- please choose one (? for help, .. to quit this menu)-----
[exi]t [d]ebug/ [l]abel/
[b]adblock/ [exe]rcise/ [r]epartition/
fx>
Since this is a new disk, fx gives a warning that it
is not yet labeled with an SGI disk label. The label submenu
is used to put a new label on the disk:
----- please choose one (? for help, .. to quit this
menu)-----
[exi]t [d]ebug/ [l]abel/ [a]uto
[b]adblock/ [exe]rcise/ [r]epartition/ [f]ormat
fx> label
----- please choose one (? for help, .. to quit this menu)-----
[sh]ow/ [sy]nc [se]t/ [c]reate/
fx/label> create
----- please choose one (? for help, .. to quit this menu)-----
[p]artitions [s]giinfo [b]ootinfo [d]irectory [a]ll
fx/label/create> all
...creating default bootinfo
...creating default partitions
...creating default sgiinfo
...creating default volume directory
----- please choose one (? for help, .. to quit this menu)-----
[p]artitions [s]giinfo [b]ootinfo [d]irectory [a]ll
fx/label/create> ..
----- please choose one (? for help, .. to quit this menu)-----
[sh]ow/ [sy]nc [se]t/ [c]reate/
fx/label> ..
----- please choose one (? for help, .. to quit this menu)-----
[exi]t [d]ebug/ [l]abel/ [a]uto
[b]adblock/ [exe]rcise/ [r]epartition/ [f]ormat
fx> exit
label info has changed for disk dksc(0,5,). write out changes?
(yes) yes
Partitioning the Disk
To partition the disk, the partition submenu is entered:
fx> repartition
----- partitions-----
part type cyls blocks Megabytes (base+size)
0: efs 4 + 73 2800 + 51100 1 + 25
1: raw 77 + 117 53900 + 81900 26 + 40
8: volhdr 0 + 4 0 + 2800 0 + 1
10: volume 0 + 3363 0 + 2354100 0 + 1149
capacity is 2354660 blocks
----- please choose one (? for help, .. to quit this menu)-----
[ro]otdrive [o]ptiondrive [e]xpert
[u]srrootdrive [re]size
fx/repartition>
To create new partitions, enter expert mode. In this
case, two similar-sized partitions will be created:
fx/repartition> expert
Warning: you will need to re-install all software and restore
user data
from backups after changing the partition layout. Changing
partitions
will cause all data on the drive to be lost. Be sure you have
the drive
backed up if it contains any user data. Continue? yes
Enter .. when done
fx/repartition/expert: change partition = (0) <RETURN>
before: type efs base: 4 cyls, 2800 blks, 1 Mb
len: 73 cyls, 51100 blks, 25 Mb
fx/repartition/expert: partition type = (efs) <RETURN>
fx/repartition/expert: base cyl = (4) <RETURN>
fx/repartition/expert: number of cyls (max 3359) = (73) 1675
after: type efs base: 4 cyls, 2800 blks, 1 Mb
len: 1675 cyls, 1172500 blks, 573 Mb
fx/repartition/expert: change partition = (1) <RETURN>
before: type raw base: 77 cyls, 53900 blks, 26 Mb
len: 117 cyls, 81900 blks, 40 Mb
fx/repartition/expert: partition type = (raw)efs
fx/repartition/expert: base cyl = (77) 1679
fx/repartition/expert: number of cyls (max 1684) = (117) 1684
after: type efs base: 1679 cyls, 1175300 blks, 574 Mb
len: 1684 cyls, 1178800 blks, 576 Mb
fx/repartition/expert: change partition = (6) ..
----- partitions-----
part type cyls blocks Megabytes (base+size)
0: efs 4 + 1675 2800 + 1172500 1 + 573
1: efs 1679 + 1684 1175300 + 1178800 574 + 576
8: volhdr 0 + 4 0 + 2800 0 + 1
10: volume 0 + 3363 0 + 2354100 0 + 1149
capacity is 2354660 blocks
----- please choose one (? for help, .. to quit this menu)-----
[ro]otdrive [o]ptiondrive [e]xpert
[u]srrootdrive [re]size
fx/repartition> ..
----- please choose one (? for help, .. to quit this menu)-----
[exi]t [d]ebug/ [l]abel/ [a]uto
[b]adblock/ [exe]rcise/ [r]epartition/ [f]ormat
fx> exit
label info has changed for disk dksc(0,5,). write out changes?
(yes) <RETURN>
The partition table can also be viewed using the prtvtoc
command:
edcert23 10# prtvtoc /dev/rdsk/dks0d5s0
* /dev/rdsk/dks0d5s0 (bootfile "/unix")
* 512 bytes/sector
* 140 sectors/track
* 5 tracks/cylinder
* 3363 cylinders
* 4 cylinders occupied by header
* 3359 accessible cylinders
*
* No space unallocated to partitions
Partition Type Fs Start: sec (cyl) Size: sec (cyl) Mount Directory
0 efs 2800 ( 4) 1172500 (1675)
1 efs 1175300 (1679) 1178800 (1684)
8 volhdr 0 ( 0) 2800 ( 4)
10 volume 0 ( 0) 2354100 (3363)
Creating New Filesystems
Once the drive has been partitioned and labeled, mkfs is used
to create new filesystems on the partitions, and fsck is used
to check the integrity of the new filesystem:
edcert23 11# mkfs /dev/dsk/dks0d5s0
mkfs_efs: /dev/dsk/dks0d5s0: blocks=1172500 inodes=123264
mkfs_efs: /dev/dsk/dks0d5s0: sectors=140 cgfsize=32561
mkfs_efs: /dev/dsk/dks0d5s0: cgalign=1 ialign=1 ncg=36
mkfs_efs: /dev/dsk/dks0d5s0: firstcg=289 cgisize=856
mkfs_efs: /dev/dsk/dks0d5s0: bitmap blocks=287
edcert23 12# fsck -y /dev/rdsk/dks0d5s0
fsck: checking /dev/rdsk/dks0d5s0
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
FREE INODE COUNT WRONG IN SUPERBLK
FIX? yes
** Phase 5 - Check Free List
2 files 22 blocks 1141358 free
CHECKSUM WRONG IN SUPERBLK
FIX? yes
***** FILE SYSTEM WAS MODIFIED *****
|