LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-21-2004, 01:58 AM   #1
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
using dd to backup/restore windows partition


what's the best way to do this???


windows is /dev/hda1

linux is /dev/hda5

swap is /dev/hda6

/home is /dev/hda7


i'm doing this (inside my homefolder) to create the image:

dd if=/dev/hda1 of=backup.img


and then this to restore windows:

dd if=backup.img of=/dev/hda1



it works fine, but the problem is the restore is SUPER SLOW, and it's something i need to do quite often...

how can i speed things up a little???
 
Old 01-21-2004, 09:04 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 12,048

Rep: Reputation: 758Reputation: 758Reputation: 758Reputation: 758Reputation: 758Reputation: 758Reputation: 758
Well dd does a byte for byte backup of the entire partition including free space. And therefore you are restoring byte for byte. Do you really need to do this often? What do you really need to backup?
 
Old 01-21-2004, 09:19 AM   #3
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,677

Rep: Reputation: Disabled
Try this: http://www.partimage.org/.
 
Old 01-21-2004, 10:32 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 12,048

Rep: Reputation: 758Reputation: 758Reputation: 758Reputation: 758Reputation: 758Reputation: 758Reputation: 758
BTW partimage is still experimental for NTFS
 
Old 01-21-2004, 04:23 PM   #5
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Original Poster
Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Quote:
Originally posted by michaelk
Do you really need to do this often? What do you really need to backup?
well, i need to be able to restore the entire windows to like-new whenever needed... sometimes this is needed a few times a day, but it depends... the reason is the usual round of viruses, spyware, adware, porn progz, etc. that the hostile users (cybercafe environment) install...

i've been doing alright with dd, but it's slow speed is causing me trouble cuz clients (the human ones, not the software ones) get fed-up of waiting for restores to finish after hostile user "X" vandalized the whole windows desktop or whatever... lol...

i'm taking a look at partimage, it looks real sweet... probably just what i need... i gotta read-up on it though... thanks a lot for that link...

i'm guessing there's no way to give dd a couple modifiers or something to make it skip free space???

thanks for your help guys, i really appreciate it...
 
Old 01-22-2004, 02:10 AM   #6
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,677

Rep: Reputation: Disabled
You hint at something like the reading of the windows partition is faster than writing it back?!? Should that be the case, then there is something fishy going on, I mean it is all on the same physical volume (hda), isn't it, so it can't be disabled DMA or something.

Ever tried
Code:
sync
as a means to flush all buffers before writing back the windows partition?
 
Old 01-22-2004, 01:55 PM   #7
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Original Poster
Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Quote:
Originally posted by JZL240I-U
You hint at something like the reading of the windows partition is faster than writing it back?!?
ummm... i do??? well, the truth is the time it takes to make the image is not as important to me as the time it takes to restore it... i only create a new image about once a month or so...


Quote:
Originally posted by JZL240I-U
I mean it is all on the same physical volume (hda), isn't it, so it can't be disabled DMA or something.
i think it's been established that what makes dd so slow at this is the fact it restores everything, including blank space...



Quote:
Originally posted by JZL240I-U
Ever tried sync as a means to flush all buffers before writing back the windows partition?
no, i haven't tried it... i just read the man page for sync and i'm not exactly sure that it's something that i really need...


-------------------------------------------
-------------------------------------------




i used to use tar to restore winblows, sorta like this:


CREATE (about once a month, after doing all the usual critical updates and stuff):

tar -cf /home/win32sux/backup.tar /mnt/windows/*


RESTORE (several times per day):

rm -fr /mnt/windows/*

tar -xf /home/win32sux/backup.tar -C /mnt/windows/


this also worked okay and was quite fast (WAY faster than dd), however it had some drawbacks... sometimes it seemed like the windows partition would get screwed-up (perhaps virus, hostile user or whatever) and then linux would have problems accessing the windows partition to copy the fresh files... so i'd have to re-format the windows partition and do the tar -xf again... and then i'd still have to use the winxp rescue cd recovery console thinggy to do a "fixboot" so windows could boot again... this happened a couple times a month and was a major pain...

with dd i never have to use fixboot or anything like that... even if a hostle windows user formats "c:", dd would take care of everything in one step...

i'm wondering if perhaps a "mixture" of the tar method with the dd method might work...

i'm thinking perhaps i can create an image, using dd, of the "boot sector" (is that what it's called?) of the windows partition ONLY (it's like the first 512 bytes or something, right???), and then a tarball of the files and stuff... so restoration would be three steps:

1- re-format fat32 partition

2- dump (using dd) the boot sector image into the partition

3- untar the files to the windows partition


does this sound plausible???
 
Old 01-23-2004, 04:03 AM   #8
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,677

Rep: Reputation: Disabled
Quote:
Originally posted by win32sux
ummm... i do??? well, the truth is the time it takes to make the image is not as important to me as the time it takes to restore it... i only create a new image about once a month or so...
Sorry, my mistake.

Quote:
Originally posted by win32sux
i think it's been established that what makes dd so slow at this is the fact it restores everything, including blank space...
No, not really. Fact is, that dd has some defaults, which do not necessarily fit with your hardware. E.g. you might want to optimize the block size dd is using with regards to the buffer size of your hard disk(s). Also, the physical place of the data on your hard disk determines how fast the access is (hardware specs of the manufacturer can help).

Quote:
Originally posted by win32sux
no, i haven't tried it... i just read the man page for sync and i'm not exactly sure that it's something that i really need...
I suggested sync so that you flush the write-buffers of your system. dd can't achieve peak performance when your buffer-space is cluttered.

Quote:
Originally posted by win32sux
...this also worked okay and was quite fast (WAY faster than dd)...
I'd consider that as proof that the parameters for dd are somehow suboptimal .

Quote:
Originally posted by win32sux
...
1- re-format fat32 partition
2- dump (using dd) the boot sector image into the partition
3- untar the files to the windows partition
does this sound plausible???
Yes. I would still try to get dd working as it should...
 
Old 01-25-2004, 05:08 PM   #9
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Original Poster
Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
okay, you convinced me to use sync...

=)



a few questions:

1 - let's say the windows fat32 partition (/dev/hda1) is 10gb but the used space on it is 5gb... this means that a "tar" of /mnt/windows/* would weigh around 5gb, while a "dd" of /dev/hda1 would weigh 10gb... is this correct???

2 - what's the proper way to create/restore a backup image of the fat32 partition's boot sector only (using linux of course, but in a manner equivalent, or superior to windows xp's recovery console's "fixboot" command)???

3 - i've been googling around about backing-up/restoring fat32 partition images and a lot of folks suggest using "cp -a" (instead of dd)... does this sound like a good idea??? does it take care of the boot sector and stuff or just the files???

4 - "mkfs.vfat -b (sector-of-backup) selects the location of the backup boot sector for FAT32."

http://www.die.net/doc/linux/man/man8/mkfs.vfat.8.html

is this "-b" something i should be using???

5 - how does one optimize dd in relation to the size of the disk's buffer???




ps: these machines have lilo installed on the mbr...
 
Old 01-26-2004, 04:27 AM   #10
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,677

Rep: Reputation: Disabled
Answers to the best of my knowledge:

1. Yes, correct. (Btw. I am supporting the use of dd, since it is low level and so might restore vfat's dirty secrets . And while writing 10 GB instead of 5 GB should be faster, dd doesn't have to restore thousands of file entries in the overhead of the filesystem, so I don't really think that dd just writing sequentially is that much slower since it hasn't to reposition the heads of the hard disk so often.)

2. Like you wrote, I too would use dd.

Re your Post Scriptum: This is a contradiction for a machine with only one HD: Either you use LILO or XP's Fixmbr and the NT Loader. If LILO: Just run /sbin/lilo to freshly install...

3. I don't see a real difference to tar in the use of cp -a (does this create an archive too?). Else the arguments from 1. apply too. Oh yes, tar preserves linux symbolic links ... that necessary for you? I don't think that cp cares much for the boot sector .

4. I don't really know, have never done it...

5. You can specify the blocksize in the dd command (man dd ), which could be fit to the buffer size of your HDs (or their preferred size for "writing packages of data"; if I remember correctly, some devices don't write in a continuous byte stream but in bursts / packages). This is obviously a field for experiments.


BTW: A new installation of Windows should be unfragmented, i.e. much smaller than 10 GB. Why don't you dd just that part and forget about the empty rest??
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to backup and restore a multiple partition hd? jharris1993 Linux - Software 9 03-18-2006 02:41 PM
Windows partition backup/restore golinari Linux - General 6 02-20-2005 03:26 PM
File restore on the windows partition of a dual-boot machine? raindogs Linux - Software 1 10-05-2004 12:19 PM
Need to backup then restore a linux partition stuart Linux - General 5 07-16-2004 08:30 AM
Why can't I restore a partition table backup containing a reiser partition? oldweasel Linux - Software 2 05-23-2004 01:11 AM


All times are GMT -5. The time now is 07:20 PM.

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