LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 05-30-2007, 06:59 PM   #1
alibeheshti
LQ Newbie
 
Registered: May 2007
Posts: 8

Rep: Reputation: 0
How to make an image backup of my HDD?


I need to make an image backup of my HDD,I have a redhat version 9 but I dont know how I can create this image.I need to have such an image backup to be able to restore it in case of any HDD crash.

Thanks
 
Old 05-30-2007, 07:03 PM   #2
jay73
Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
You could consider partimage: it will back up your system to a bunch of compressed files - it should easily fit on a single DVD as partimage, unlike many other solutions, saves only the used space on partitions.

Last edited by jay73; 05-30-2007 at 08:07 PM.
 
Old 05-30-2007, 07:17 PM   #3
alibeheshti
LQ Newbie
 
Registered: May 2007
Posts: 8

Original Poster
Rep: Reputation: 0
how to make an image backup of HDD?

Quote:
Originally Posted by jay73
You could consider partimage: it will back up your system to a bunch of compressed files - it should easily fit on a single DVD as parimage, unlike many other solutions, saves only the used space on partitions.

how I can use patimage ? what are the other solutions than partimage ?
 
Old 05-30-2007, 08:13 PM   #4
jay73
Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
Well, you could also use dd - that is a command which will copy/clone your partitions to the last individual bit. This approach tends to take quite a bit of time for larger partitions, not to mention that you waste a lot of space on your back-up medium because it copies over all the empty space as well.

Then there is the mindi/mondo couple; very reliable and it can be used as an alternative to partimage.

As for partimage, I'll let it speak for itself:

http://www.partimage.org/Main_Page
 
Old 05-30-2007, 09:23 PM   #5
lujan
Member
 
Registered: Sep 2003
Distribution: Ubuntu, Debian Sarge, Mac OS X, FreeBSD
Posts: 45

Rep: Reputation: 16
I use G4U for all my hard disk cloning and recovering needs.
 
Old 05-31-2007, 06:47 PM   #6
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Using dd to zero out unused space can help with compression.

I just tried an experiment where I created a loopback filesystem on test.img. First I added files to the mounted filesystem. Then I used gzip to compress is. Then I deleted most of the files and used gzip again. Because the patterns for the deleted files still exist on the image, the file size was the same.

Next I used dd to create a large zeroed out file using up most of the space in the filesystem. Then I deleted the file and tried compressing again. This time the filesize was a lot less. I knew it would help but I wanted to post real results:

Code:
jschiwal@hpamd64:~>ls -lh test* -d
drwxr-xr-x 18 jschiwal users 4.0K 2007-05-31 18:25 test
-rw-r-----  1 jschiwal users 2.4G 2007-05-31 10:35 test1.img.gz
-rw-r-----  1 jschiwal users 2.4G 2007-05-31 17:29 test2.img.gz
-rw-r-----  1 jschiwal users 303M 2007-05-31 18:30 test3.img.gz
-rw-r-----  1 jschiwal users 4.0G 2007-05-31 09:51 test.img
The filesystem is on test.img. Test1.img.gz is using gzip before the deletions. Test2.img.gz is the gzipped filesystem after deletions. Test3.img.gz is the gzipped filesystem after creating the large file of zero's with the command: "dd if=/dev/zero of=zero bs=1024 count=$((1024*512*31)) && rm zero". I based the count on the result of "df test/".
Before zeroing: 2.4G
After zeroing: 303M.

If I had been using a real partition, I would probably have entered the "sync" command to make sure that the cache was emptied. For such a large file, it may not be necessary.

So zeroing out most of the free space this way can dramatically reduce the size of the final backup image file.

If you use dd, you can pipe the output through gzip or bzip2 to reduce the size of the image. Restoring, you can simply use "zcat backup.img | dd of=/dev/hda1" to restore the hda1 device from a gzipped image.

This sites wiki has a page on using dd that includes backing up partitions.

Technically, you could simply redirect the output of zcat to the device. Remember that in Linux "everything is a file". "zcat backup-hda1-May15-2007.img.gz >/dev/hda1"
or
"gunzip -c backup-hda1-May15-2007.img.gz >/dev/hda1"

----

IMHO image backups are useful mainly for new installs, rather than for periodic backups. When recovering from a fatal drive problem, you can use dd using any rescue disk. If you use a large tool such as partimage, you need to make sure you have a live distro or rescue disk that contains the partimage program.
Also, you it would be easy to script the recovery of several partitions using the dd command. So after booting up with an emergency restore rescue disk, you could just start the script to restore the system to the point where you could start using a more sane backup/restore system.

Last edited by jschiwal; 05-31-2007 at 07:01 PM.
 
Old 06-01-2007, 12:25 AM   #7
Junior Hacker
Senior Member
 
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687

Rep: Reputation: 59
jschiwal

I've got allot of useless partitions, over 60 of them, I was just going to delete them but can't find the time. Nor can I find the time to play with this, but Lord knows I will. This surely seems plausible. I have but just one question, which part of that dd command points to un-allocated sectors in a file system?. Actually, you used a bs of 1024 which is equal to two sectors, and files are written to clusters/blocks, not sectors, so it is not necessary to try and zero out individual sectors when eliminating un-allocated space in an image file, one would chase un-allocated clusters/blocks. In a fragmented file system, what part of that dd command finds un-allocated clusters/blocks/sectors.
It looks to me, that what you achieved, was to make an image of the format information, eliminating anything that could be a file in the data portion of sectors.
 
Old 06-01-2007, 09:08 AM   #8
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,591

Rep: Reputation: 162Reputation: 162
See this post:

http://www.linuxquestions.org/questi...d.php?t=362506
 
Old 06-01-2007, 10:31 AM   #9
linuxlastslonge
Member
 
Registered: Jun 2002
Location: Franklin, IN
Distribution: Debian, CentOS, Mac OS X
Posts: 158

Rep: Reputation: 30
if you *have* to make an image of your system, i'd recommend systemimager. otherwise, i'd recommend tgz'ing up /etc and your /home dir, and call it a day.
 
Old 06-01-2007, 12:13 PM   #10
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
There are tons of possibilities around but a Linux user will never know how much he/she missed out if he/she doesn't use the dd command, which is possibly the simplest, fastest and more reliable around.

Awesomemachine's thread is one of the master pieces on the subject of dd.

I hate to see gold is taken for iron in an offer.
 
  


Reply

Tags
backup


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
How do I make an image of my hdd w/Linux? keithmendez Linux - Software 0 01-20-2005 01:07 PM
how to make mirror image of one hdd to 2 hdd raj_1 General 1 12-02-2004 06:19 PM
How to make mirror image of linux partion to one1 HDD TO 2 HDD raj_1 Linux - General 2 11-04-2004 01:45 AM
HDD image zchoyt Linux - General 3 09-29-2004 10:25 AM
How make disk image and put it on my new hdd jimdaworm Linux - Hardware 5 12-16-2003 11:58 AM


All times are GMT -5. The time now is 01:43 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration