Here's the script in it's entirety. There are a few things that
could/should be functionalized I think, and it's ugly code. I've not
commented much of anything yet .
It presumes that THIS device layout exists

0.0.0210(ECKD) at ( 94:     0) is dasda       : active at blocksize: 4096,
216000 blocks, 843 MB
0.0.0280(ECKD) at ( 94:     4) is dasdb       : active at blocksize: 4096,
540000 blocks, 2109 MB
0.0.0201(ECKD) at ( 94:     8) is dasdc       : active at blocksize: 4096,
54000 blocks, 210 MB
0.0.0202(ECKD) at ( 94:    12) is dasdd       : active at blocksize: 4096,
13500 blocks, 52 MB
0.0.0203(ECKD) at ( 94:    16) is dasde       : active at blocksize: 4096,
9000 blocks, 35 MB
0.0.0204(ECKD) at ( 94:    20) is dasdf       : active at blocksize: 4096,
49500 blocks, 193 MB
0.0.0205(ECKD) at ( 94:    24) is dasdg       : active at blocksize: 4096,
702000 blocks, 2742 MB
0.0.0206(ECKD) at ( 94:    28) is dasdh       : active at blocksize: 4096,
61380 blocks, 239 MB
0.0.0207(ECKD) at ( 94:    32) is dasdi       : active at blocksize: 4096,
216000 blocks, 843 MB
0.0.0208(ECKD) at ( 94:    36) is dasdj       : active at blocksize: 4096,
756000 blocks, 2953 MB
0.0.0209(ECKD) at ( 94:    40) is dasdk       : active at blocksize: 4096,
108000 blocks, 421 MB
0.0.0220(ECKD) at ( 94:    44) is dasdl       : active at blocksize: 4096,
432000 blocks, 1687 MB

and is going to end up mounted:

/dev/dasdb1        /
/dev/dasdc1        /mnt
/dev/dasdd1        /mnt/boot
/dev/dasde1        /mnt/root
/dev/dasdf1        /mnt/home
/dev/dasdk1        /mnt/var
/dev/dasdi1        /mnt/tmp
/dev/dasda1        /mnt/work
/dev/dasdg1        /mnt/opt
/dev/dasdj1        /mnt/usr
/dev/dasdh1        /mnt/opt/IBM/WebSphere
/dev/dasdl1        swap


Device 280 is the single volume clone and was used for IPL.  Device 220
(/dev/dasdl) is the swap volume for the single volume clone and becomes the
swap volume for the multi-HFS result.

The create_system script:

usage:  create_system [format|noformat] - noformat will mount the disk on
/mnt without formatting.

fdasd.conf is a file to provide fdasd with automatic information and
contains:  [first,last]
the path to this file is set in the second line of the script as partfile.

The actual code:

#!/bin/bash
format=$1
partfile=/etc/fdasd.conf
function get_dasd_dev
{
 varname=$1
 devicename=$2
 devinfo=`cat /proc/dasd/devices | grep $devicename`
 rc=$?
 if [ $rc != 0 ]; then
   echo "Device "$devicename" not in list of available devices Exiting."
   exit
 else
   diskdev=${devinfo:34:5}
   rc=$?
   if  [ $rc != 0 ]; then
      echo "Dasd Device name not found for linux device "$2
      echo "Unable to set variable "$1." Exiting."
      exit
   else
     export $varname=$diskdev
     echo '$varname1' = $varname ${varname:? null}
   fi
 fi
}
function format_disk
{
  targdev=$1
 if [ $2 = format ]; then
    echo "Formatting disk '"$targdev"' started at "`date`
    dasdfmt -y -p -b 4096 -f /dev/$targdev
    rc=$?
    if [ $rc != 0 ]; then
      echo "Error executing dasdfmt for $targdev - failed with "$rc"
Exiting."
      exit
    fi
    echo "Formatting disk "$targdev" completed at "`date`
  fdasd -a /dev/$targdev  > /dev/null
 rc=$?
  if [ $rc != 0 ]; then
    echo "Error partitioning "$targdev " - fdasd failed with "$rc"
Exiting."
  fi
 echo "About to make file system on /dev/"$targdev"1"
 mkfs.ext3 /dev/$targdev"1" > /dev/null
 #mke2fs /dev/$targdev"1" > /dev/null
   rc=$?
     if [ $rc != 0 ]; then
      echo "Error creating ext2 file system on "$1 "- mke2fs failed with
"$rc" - Exiting."
      exit
     fi
fi
}
function activate_device
{
 chccwdev -e 0.0.$1
 rc=$?
   if [ $rc != 0 ]; then
    echo "Error: chccwdev -e 0.0.$1 failed with $rc - exiting"
    exit
   fi
}
#******************************************************************
#Begin main body of this procedure                                *
#******************************************************************

#activate devices required by running system

activate_device 0201 ; activate_device 0202
activate_device 0203 ; activate_device 0204
activate_device 0205 ; activate_device 0206
activate_device 0207 ; activate_device 0208
activate_device 0209 ; activate_device 0210
activate_device 0220 ; activate_device 0280

#get dev for unit 0201
get_dasd_dev rootfs 0201

#get dev for unit 0202
get_dasd_dev boot 0202

#get dev for unit 0203
get_dasd_dev root 0203

#get dev for unit 0204
get_dasd_dev home 0204

#get dev for unit 0205
get_dasd_dev opt 0205

#get dev for unit 0206
get_dasd_dev websphere 0206

#get dev for unit 0207
get_dasd_dev tmp 0207

#get dev for unit 0208
get_dasd_dev usr 0208

#get dev for unit 0209
get_dasd_dev var 0209

#get dev for unit 0210
get_dasd_dev work 0210

#get dev for unit 0220
get_dasd_dev swap 0220

#get dev for unit 0280
get_dasd_dev golden 0280

#format and patition disk

format_disk $boot   $format   # 75 c
format_disk $root   $format   # 50 c
format_disk $home   $format   # 275 c
format_disk $rootfs $format   # 300 c
format_disk $var    $format   # 600 c
format_disk $tmp    $format   # 1200 c
format_disk $work   $format   # 1200 c
format_disk $opt    $format   # 3900 c
format_disk $usr    $format   # 4200 c

# mount root disk on /mnt
mount "/dev/"$rootfs"1" /mnt
#create mount points for remaining file systems
mkdir /mnt/root /mnt/home /mnt/var /mnt/tmp /mnt/work /mnt/opt /mnt/usr
/mnt/boot

#mount remaining disks
mount "/dev/"$boot"1" /mnt/boot ; mount "/dev/"$root"1" /mnt/root ; mount
"/dev/"$home"1" /mnt/home
mount "/dev/"$var"1"  /mnt/var ; mount  "/dev/"$tmp"1" /mnt/tmp ; mount
"/dev/"$work"1" /mnt/work
mount "/dev/"$opt"1"  /mnt/opt ; mount  "/dev/"$usr"1" /mnt/usr

#create mountpoint for /opt/IBM/WebSphere
mkdir /mnt/opt/IBM /mnt/opt/IBM/WebSphere

#mount WebSphere device

mount -o ro "/dev/"$websphere"1" /mnt/opt/IBM/WebSphere
df
#begin single disk to multi-disk copy

 echo -n "Ready to begin copying single image system to multi-HFS (y/n): "
 read ans
 if [ $ans != "y" ]; then
   exit
 fi

# copy single disk fstab to backup.
cp /etc/fstab /etc/fstab_backup

#cat fstab_backup file through sed to change dasda1 mount point for swap to
dasdl1
# and replace original fstab file.
cat fstab_backup | sed -e "s/dasda1/dasdl1/g" > /etc/fstab

#create initial ram disk reflecting new dasd
mkinitrd

#write boot record and pointers for root volume
zipl

echo "copying single disk clone to target dasd"
cd /
#tar -clpSf - . | (cd /mnt ; tar -xpSf - )
tar -clpSf - . | sh -c ' cd /mnt ; exec tar -xpSf - '
echo "Copy complete"

#!/bin/bash
spaces="                                                   x"
devmax=17
mountmax=24
fstypemax=9
attribmax=20
stripval="mnt/"
stripval2="mnt"
repval=""
root="/"
echo "Creating fstab in /mnt/etc"
cp /mnt/etc/fstab /mnt/etc/fstab_bkup
 echo "# generated fstab `date` during clone process" > /mnt/etc/fstab
 while read Device MountPoint FsType FsOptions junk
 do              # Process one line using the above variables.
    FsOptions="acl,user_xattr"
    if [ $MountPoint != "/" ]; then fs_freq_pass="1 2"
       else
       fs_freq_pass="1 1"
    fi
    if [ $Device = "devpts" ] ; then
       fs_freq_pass="0 0"
       FsOptions="mode=0620,gid=5"
    fi
    if [ $Device = "proc" ] ; then
       fs_freq_pass="0 0"
       FsOptions="defaults"

    fi
    if [ $Device = "sysfs" ] ; then
       fs_freq_pass="0 0"
       FsOptions="noauto"
    fi
    if [ $Device = "tmpfs" ] ; then
       fs_freq_pass="0 0"
       FsOptions="rw"
    fi
    if [ $MountPoint = "/opt/IBM/Websphere" ]; then
       FsOptions="ro,acl"
    fi
    devlength=${#Device}
    pad1=${spaces:0:$devmax-$devlength}
    fslength=${#FsType}
    pad3=${spaces:0:$fstypemax-$fslength}
    attriblength=${#FsOptions}
    pad4=${spaces:0:$attribmax-$attriblength}
    if [ $MountPoint != "/" ]; then
       MountPoint=${MountPoint/$stripval/$repval}
       if [ $MountPoint = "/mnt" ]; then
          MountPoint=${MountPoint/$stripval2/$repval}
       fi
       mountlength=${#MountPoint}
       pad2=${spaces:0:$mountmax-$mountlength}
       echo "$Device $pad1 $MountPoint $pad2 $FsType $pad3 $FsOptions $pad4
$fs_freq_pass" >>/mnt/etc/fstab
    fi
done < /etc/mtab
rawswap=`swapon -s | grep /dev`
cookedswap=${rawswap:0:11}
Device=$cookedswap
MountPoint=swap
FsType=swap
FsOptions="pri=42"
fs_freq_pass="0 0"
devlength=${#Device}
pad1=${spaces:0:$devmax-$devlength}
mountlength=${#MountPoint}
pad2=${spaces:0:$mountmax-$mountlength}
fslength=${#FsType}
pad3=${spaces:0:$fstypemax-$fslength}
attriblength=${#FsOptions}
pad4=${spaces:0:$attribmax-$attriblength}
echo "$Device $pad1 $MountPoint $pad2 $FsType $pad3 $FsOptions $pad4
$fs_freq_pass" >>/mnt/etc/fstab
echo "Chroot to /mnt and run mkinitrd and zipl!"
echo "Then shutown system and IPL device indicated in zipl output"

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to