tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* using dd
@ 2003-03-24 19:29 Pappas, Bill
       [not found] ` <"from Bill.Pappas"@stjude.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Pappas, Bill @ 2003-03-24 19:29 UTC (permalink / raw)


I found a great script for cloning a disk, but I was wondering...is there a
way to automate the cloning via crontab?
Here is what I would like to see happen automatically....
1.  From multiuser mode with networking (init 3) goto single user mode.
2.  Mount the disks you need
3.  Perform the clonedisk script shown at MY SCRIPT.
4.  When dome with #3 go back to init 3

The problem I am having is with step 1.  As I dive into single user mode, my
script is killed as are other processes.
Therefoe, I never reach step 2

Any suggestions on how I could automate this? 

MY SCRIPT:

#cat clonedisk.sh
#!/bin/sh -x
#
#The may work only with disks using the same
#geometry e.g the same models.
#
#1. initial steps 
#
#- plug in the destination disk in the drive cage
#- power on the machine
#- with "show dev" you should see the master disk and the destination disk
#- boot from the master disk
#
#2. the cloning
#
#- login and do the following
#
# hwmgr -view devices
#(you should see both disks and the special-device files too)
#
#  Here we begin:
#
#
# Put the machine into single user mode and mount all disks 
init s
echo "Wait for 60 seconds so that this machine can stop all related
processes"
sleep 60
mount -a
sleep 4
#
#
# After booting in single-user (b -fl s)
# make sure that the devicefiles for your destination disk
# exists (ls -l /dev/rdisk)
#
echo "1 - modify root_domain usr_domain var_domain and home_domain"
#
cd /etc/fdmns/root_domain
rm dsk6a
ln -s /dev/disk/dsk5a .
ls -l
#
cd /etc/fdmns/usr_domain
rm dsk6b
ln -s /dev/disk/dsk5b .
ls -l
#
cd /etc/fdmns/var_domain/
rm dsk6g
ln -s /dev/disk/dsk5g .
ls -l
#
cd /etc/fdmns/home_domain/
rm dsk6h
ln -s /dev/disk/dsk5h .
ls -l
#
#
#
echo "modification correct? 5 seconds to go on! CTRL+C will break"
sleep 5

echo "2 - clear the disklabel on the destination disk"

disklabel -z /dev/rdisk/dsk5c
sleep 2

echo "3 - clone the source disk to the destination disk"
echo "this takes time ... please wait ..."
sync ;sync
dd if=/dev/rdisk/dsk6c of=/dev/rdisk/dsk5c bs=1024k

echo "4 - resemble root_domain and usr_domain var_domain home_domain"

# restore the old links!
cd /etc/fdmns/root_domain
rm dsk5a
ln -s /dev/disk/dsk6a .
#
cd /etc/fdmns/usr_domain
rm dsk5b
ln -s /dev/disk/dsk6b .
#
cd /etc/fdmns/var_domain
rm dsk5g
ln -s /dev/disk/dsk6g .
#
cd /etc/fdmns/home_domain
rm dsk5h
ln -s /dev/disk/dsk6h .
#
sleep 2


echo "5 - Halt the system and boot from your cloned disk"

echo "6 - run the script finishclonedd"

init 3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* not using dd
       [not found] ` <"from Bill.Pappas"@stjude.org>
@ 2003-03-25 10:29   ` J.A. Gutierrez
  0 siblings, 0 replies; 2+ messages in thread
From: J.A. Gutierrez @ 2003-03-25 10:29 UTC (permalink / raw)



    Sorry for replying to the list, but since I'm adding questions
    more than giving answers...

On Mon, Mar 24, 2003 at 01:29:09PM -0600, Pappas, Bill wrote:
> I found a great script for cloning a disk, but I was wondering...is there a
> way to automate the cloning via crontab?
> Here is what I would like to see happen automatically....
> 1.  From multiuser mode with networking (init 3) goto single user mode.
> 2.  Mount the disks you need
> 3.  Perform the clonedisk script shown at MY SCRIPT.
> 4.  When dome with #3 go back to init 3
>
> The problem I am having is with step 1.  As I dive into single user mode, my
> script is killed as are other processes.
> Therefoe, I never reach step 2
>
> Any suggestions on how I could automate this?

    I wouldn't use dd in the first place.
    I don't think you can easily automate nothing which requires
    single user. (well, maybe modifying inittab; but anyway,
    if you could hack it, single user won't make dd good for
    cloning the startup disk, since it is still mounted)

    I'd use dump/tar/cpio for that purpose; I have a script
    for linux and solaris; but I still don't know how to do
    some tasks:

    - Read partition table from original disk:

        SunOS: prtvtoc -h ${ORIG}2
        Linux: fdisk -ul $ORIG
        Tru64: disklabel -r ????

    - Create a new partition table

        SunOS: fmthard -s - ${RDEST}2
        Linux: sfdisk $DEST
        Tru64: disklabel -R ????
            (would "disklabel -r $ORIG | disklabel -R $DEST" work?)

    - Setting swap

        SunOS: not needed
        Linux: mkswap `fdisk -l $DEST | awk '/swap$/ {print $1}'`
        Tru64: not needed?

    - Creating boot loader

        SunOS: /usr/sbin/installboot \
               /usr/platform/`uname -i`/lib/fs/ufs/bootblk ${RDEST}0
        Linux: lilo -v -r /new/1 -b $DEST
        Tru64: ????


    Problems:
        I'm not sure about how advfs work; and in my script
        I need to mount the destination filesytems in order to
        copy contents.
        So, if I have, for instance:

        /dev/disk/dsk0a root_domain

        and I need to mount /dev/disk/dsk1a, I guess I should
        create a new domain (mkfdmn /dev/disk/dsk1a root_domain2)
        then a fileset (mkfset root_domain2 root)

        Question: this domain/fileset procedure will modify
        dsk1 or is just at OS level? i.e., if I physically
        disconnect dsk0 and boot from dsk1 (now dsk0), it's
        partitions will be part of "root_domain" or of "root_domain2" ?

        Once cloned, if I remove "root_domain2", dsk1a contents
        will be lost?


    BTW; you can find the script at
    http://giga.cps.unizar.es/~spd/src/system/do_mirror

    I'd like to add Tru64 support, but I'm not sure when I will be
    able to test it (I have a single DS10 host, and by now both
    disks are in use)

-- 
finger spd@shiva.cps.unizar.es for PGP      /
.mailcap tip of the day:                   /             La vida es una carcel
application/ms-tnef; cat '%s' > /dev/null /           con las puertas abiertas
text/x-vcard; cat '%s' > /dev/null       /            (A. Calamaro)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-03-25 10:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-24 19:29 using dd Pappas, Bill
     [not found] ` <"from Bill.Pappas"@stjude.org>
2003-03-25 10:29   ` not " J.A. Gutierrez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox