LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Partition Magic / Mirroring / Image / Copying a Whole Drive? (https://www.linuxquestions.org/questions/linux-newbie-8/partition-magic-mirroring-image-copying-a-whole-drive-274650/)

ch4os 01-06-2005 01:00 PM

Partition Magic / Mirroring / Image / Copying a Whole Drive?
 
Greetings,

Im rolling out an linux workstations, on some old p2's, with slow cd drives.
I've got the master install just about complete, and wanted to know what command or util I can use to mirror the drives so I don't have to install on all 10 wkstations??

I use to use partition magic on windows boxes... just pop in a slave drive, and mirror the master to it, then put the mirrored in the pc, and off we go...

Is there an easy way to copy the Whole Drive (as they are all the same) bit by bit?

SuSE 9.2

Thanks

masand 01-06-2005 01:47 PM

hi there

i am aware of the disc which contains many tools

www.ultimatebootcd.com

regards

m_yates 01-06-2005 02:03 PM

The command you want is "dd". If you plug in a slave drive (hdb) and want to copy everything from the master to it (hda). Just do:
Code:

dd if=/dev/hda of=/dev/hdb
Thsi assumes the drives are the same size. More details here: http://www.rajeevnet.com/hacks_hints...s_cloning.html

If you want to change partition sizes at the same time you image the disk, there is commercial software called migrate easy: http://www.acronis.com/homecomputing...s/migrateeasy/ it is $40 US. You create a bootable CD that can be used to copy one hard drive to another and supports linux partitions as well as windows.

homey 01-06-2005 03:13 PM

Here's how I make a drive clone using partimage on system rescue cd or the knoppix cd.

1. Setup the operating systems and boot loader
2. Put a formatted partition on a second drive. Make the scripts executable with the command:
chmod +x save and chmod +x restore. Copy these scripts the the second drive. For example: /dev/hdb1
3. Boot up with system rescue cd and run the command:
mount /dev/hdb1 /mnt/images -t ext3
4. Run the save script with the command:./save /dev/hda
5. After you have saved the images, remove the master drive ( the one which has the operating system on it )
6. Install a new master drive /dev/hda Note: make sure it is detected properly in the bios.
7. Run the restore script with the command:./restore /dev/hda

here is the save script
Code:

#!/bin/bash
##### This saves the MBR / Partition Table
##### and all partitions using partimage
##### example:  ./save /dev/hda

##############################################
#  Ensure that root is running the script.
#
WHOAMI=`/usr/bin/whoami`
if [ $WHOAMI != "root" ]; then
        echo
        echo "You must be root to run this!"
        echo
      exit 1
fi
##############################################

usage()
{
        echo "Usage: $0 /dev/hd#"
        exit 1;
}

test "$1" || usage

if ! [ -e $1 ]; then
    echo "$1 does not exist. Exiting."
    exit 1
fi

if [ -e $1 ]; then
  #Save the MBR with partition table
  mbrfile=`echo -e $1 | awk -F"/" '{print $3}'`;
  dd if=$1 of=/mnt/images/mbr_$mbrfile bs=512 count=1
  clear
 
  for i in `/sbin/sfdisk -l $1 | \
  grep -e "^[/dev]" | awk '{print $1}'`;
 
do
  a=`/sbin/sfdisk -s $i 2> /dev/null`
  test=$(($a + 0))
  stuff=`echo -e $i | sed -e 's/.\{8\}//'`;
  check=`sfdisk -c $1 $stuff`
 
if [ $check != 5 -a $check != 82 -a $test != 0 ];then

  part=`echo -e $i | awk -F"/" '{print $3}'`;
  #Save the partitions
  #use this method for GUI progress
  partimage save -c -b -d -z0 -f3 $i /mnt/images/$part
 
  #use this method for command line progress
  #partimage save -B=foo -c -b -d -z0 -f3 $i /mnt/images/$part
  clear
fi 
done
echo

else
    exit 1
fi

clear
echo "The save operation is complete"
echo "The images have been saved in /mnt/images/"
echo
exit 0


Here is the restore script
Code:

#!/bin/bash
##### This retores the MBR / Partition Table
##### and all partitions using partimage
##### example:  ./restore /dev/hda

##############################################
#  Ensure that root is running the script.
#
WHOAMI=`/usr/bin/whoami`
if [ $WHOAMI != "root" ]; then
        echo
        echo "You must be root to run this!"
        echo
      exit 1
fi
##############################################
usage()
{
        echo "Usage: $0 /dev/hd#"
        exit 1;
}

test "$1" || usage

if ! [ -e $1 ]; then
    echo "$1 does not exist. Exiting."
    exit 1
fi

if [ -e $1 ]; then
clear
echo
echo "********************************************************************"
echo "    Caution!!!    This program will erase your hard drive"
echo
echo -n "                Do you want to proceed (Y/N)?"
read answer
if test "$answer" != "Y" -a "$answer" != "y";
then exit 0;
fi
#
clear
  mbrfile=`echo -e $1 | awk -F"/" '{print $3}'`;
  #Erase the old boot sector
  dd if=/dev/zero of=$1 bs=512 count=1
 
  #Restore the MBR with partition table
  dd if=/mnt/images/mbr_$mbrfile of=$1 bs=512 count=1
  clear
 
  for i in `/sbin/sfdisk -l $1 | \
  grep -e "^[/dev]" | awk '{print $1}'`;
 
do
  a=`/sbin/sfdisk -s $i 2> /dev/null`
  test=$(($a + 0))
  stuff=`echo -e $i | sed -e 's/.\{8\}//'`;
  check=`sfdisk -c $1 $stuff`
 
if [ $check = 82 ];then
  #setup the swap partition
  /sbin/mkswap $i
 
elif [ $check != 5 -a $check != 82 -a $test != 0 ];then

  part=`echo -e $i | awk -F"/" '{print $3}'`;
  #Restore the partitions
  #use this method for GUI progress
  partimage restore -b -f3 $i /mnt/images/$part.000
 
  #use this method for command line progress
  #partimage restore -B=foo -b -f3 $i /mnt/images/$part.000
  clear
fi
done
echo
else
    exit 1
fi

clear
echo "The restore operation is complete"
echo "The partitions have been restored from /mnt/images/"
echo
exit 0


ch4os 01-06-2005 05:39 PM

YOU ALL ROCK!
 
THANKS A MILLION!


All times are GMT -5. The time now is 10:02 AM.