LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-06-2005, 01:00 PM   #1
ch4os
LQ Newbie
 
Registered: Nov 2004
Distribution: SuSE 9.2, SLES 9, Gentoo, YDL, OSX
Posts: 15

Rep: Reputation: 0
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
 
Old 01-06-2005, 01:47 PM   #2
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
hi there

i am aware of the disc which contains many tools

www.ultimatebootcd.com

regards
 
Old 01-06-2005, 02:03 PM   #3
m_yates
Senior Member
 
Registered: Aug 2003
Location: Upstate
Distribution: Debian, Mint, Mythbuntu
Posts: 1,249

Rep: Reputation: 101Reputation: 101
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.
 
Old 01-06-2005, 03:13 PM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
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
 
Old 01-06-2005, 05:39 PM   #5
ch4os
LQ Newbie
 
Registered: Nov 2004
Distribution: SuSE 9.2, SLES 9, Gentoo, YDL, OSX
Posts: 15

Original Poster
Rep: Reputation: 0
Talking YOU ALL ROCK!

THANKS A MILLION!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using partition magic to create Linux partition then install EviLBoX Linux - General 5 09-12-2008 05:01 AM
Linux, Partition Magic and Hard Drive Errors philipogletree Linux - Hardware 5 11-22-2005 10:49 AM
Problem Resizing Linux Partition From Partition magic John_Emad SUSE / openSUSE 5 02-16-2005 12:42 PM
Slightly OT : Restoring Drive Image to Resized Partition dlocalized Linux - Newbie 10 11-28-2003 02:36 PM
How do I install slackware on a partition made by partition magic in windows bling bling Slackware 4 06-28-2003 11:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration