LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 12-26-2004, 08:40 PM   #16
tcv
Member
 
Registered: Apr 2003
Location: Billerica, MA
Posts: 114

Original Poster
Rep: Reputation: 15

Are these scripts a part of the System Rescue disk? Or... how would I get them into the iso?
 
Old 12-26-2004, 08:46 PM   #17
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
Those are just a couple of scripts I made to automate the save / restore process. You could save them on the same partition where you plan to save images to. Making changes to a livecd is a whole nother subject.
 
Old 12-26-2004, 09:02 PM   #18
tcv
Member
 
Registered: Apr 2003
Location: Billerica, MA
Posts: 114

Original Poster
Rep: Reputation: 15
Ahh... so, I see how I could do that. I think.

Obviously, I'm quite the newbie.

I suppose I can boot with any Linux live cd on that laptop and create the extra partition, eh?

m
 
Old 12-26-2004, 09:06 PM   #19
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
Quote:
I suppose I can boot with any Linux live cd on that laptop and create the extra partition, eh?
Yes, assuming you have room on the laptop hard drive and windows doesn't occupy all of it now. If so, you can resize it with a live cd which has a nice GUI tool called qtparted or you can do it from the command line.
 
Old 12-27-2004, 06:19 PM   #20
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
I made a couple of scripts which should help to automate things abit where the images are saved and restored to the same size hard drive.
Make the scripts executable and run them as root user like this ...
./save /dev/hda
and
./restore /dev/hda

Note: change the /dev/hda to whatever the drive is called, like /dev/sda or /dev/hdb .....
if you have real important stuff and you don't feel comfortable using these scripts, then don't use them.

If you are going to clone an NTFS partition, you may want to run defrag and scandisk first.

Bootup with the rescue cd and run the save script to save the partitions to images.

Mount the partition where the images are going to be saved to.
For example ....
mount /dev/hda1 /mnt/images -t vfat

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 -z1 -f3 $i /mnt/images/$part
  
  #use this method for command line progress
  #partimage save -B=foo -c -b -d -z1 -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
####

Bootup with the rescue cd and run the restore script to restore partitions from images.

Mount the partition where the images are going to be restored from.
For example ....
mount /dev/hda1 /mnt/images -t vfat

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 != 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
####

Last edited by homey; 12-28-2004 at 11:59 AM.
 
Old 12-27-2004, 08:02 PM   #21
tcv
Member
 
Registered: Apr 2003
Location: Billerica, MA
Posts: 114

Original Poster
Rep: Reputation: 15
OMG! This just isn't right. You shouldn't be doing this for free!
 
Old 12-27-2004, 09:32 PM   #22
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
Bill to follow.
 
Old 12-28-2004, 10:41 AM   #23
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
I did some experimenting on an NTFS 10gig partition and different compression levels. There is a huge difference in time between compression level 0 ( z0 ) and compression level 2 ( z2 ) but the image size is twice as big also. If you have the room to save a large image file, that is a lot faster.

Code:
Comp. level     time used           size of image
z0              7 minutes             2GB and 486M
z1              22 minutes            1GB
z2              74 minutes            1.1GB
Change this line in the save script to the compression level which meets your needs.
partimage save -c -b -d -z2 -f3 $i /mnt/images/$part

Last edited by homey; 12-28-2004 at 11:57 AM.
 
Old 12-28-2004, 10:09 PM   #24
tcv
Member
 
Registered: Apr 2003
Location: Billerica, MA
Posts: 114

Original Poster
Rep: Reputation: 15
Seems to me that z0 would be fine. This is a rotating drive that will see a lot of turn over.

Is 0 no compression?
 
Old 12-28-2004, 10:28 PM   #25
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
Yes, from the command: partimage --help it looks like z0 is no compression. If you have the room, that's the way to go.
 
  


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
backup images of NTFS drives jason2 Linux - Software 1 07-21-2006 06:23 PM
Convert cd images to dvd images rcsuk Debian 2 07-11-2005 10:34 AM
can I backup a root disk and boot from the new backup disk linuxbkp Linux - Enterprise 3 10-15-2004 06:42 PM
Selective backup to CDRW, or other backup methods. trekk Linux - Software 1 11-03-2003 02:46 PM
backup and update the backup file doris Linux - General 4 08-24-2002 07:26 PM


All times are GMT -5. The time now is 11:19 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration