Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 11-14-2007, 10:45 AM   #1
LQ Newbie
Registered: Mar 2007
Location: Auburn, Washington
Distribution: Kubuntu
Posts: 5

Rep: Reputation: 0
Backing up new formatted Windows installation

I usually reformat my WindowsXP drive on Thanksgiving day weekend every year. This time, after spending all that time downloading update after update after update, when I finally get WindowsXP to the current state of unbrokeness that it is supposed to be in, I want to burn the whole hard drive onto a dual layer DVD so that from now on, I will only have to download the updates that come out after this Thanksgiving.

To do this I plan to boot to a live Linux DVD (Ubuntu ultimate edition 1.4) after I install all the windows patches. I assume I would just drag & drop the whole drive or something from within Linux?

Since I have never done anything like this before, I do not know what I am doing. I would appriciate any help or pointers that anyone can give me.
I also have a second question - I have Linux on a 2nd hard drive and when I set that drive up, grub takes care of the duel boot thing very nicely all by itself.

My question is - is there a way to change the operating system boot order on the grub page that comes up when I boot my pc? I seldom use Linux, so I want the windows boot option to be the first in the list so I don't have to baby sit the computer everytime I boot up or else it will boot linux by default.

Old 11-14-2007, 11:10 AM   #2
raghav bharadwaj
LQ Newbie
Registered: Nov 2007
Posts: 2

Rep: Reputation: 0
I'll take your second question. I know it on fedora. Should work on Ubuntu as well. You can find a file called "menu.lst" which contains some boot parametres. You just need to modify things there the way you want your grub to be. Just paste your windows part of it above linux. It would contain some 3-4 lines of code. Also,you can find "menu.lst" inside /dev/boot/grub or something like that. Just search for it inside /dev. You'll find it with some logic.
Old 11-14-2007, 05:32 PM   #3
Registered: Sep 2006
Distribution: Ubuntu 8.04 Hardy Heron LST
Posts: 346

Rep: Reputation: 33
In the terminal type

gksudo gedit /boot/grub/menu.lst

When it comes up look for the line that has

default 0

and change the number to the entry of the windoze entry is. The numbers start from 0 not 1, so count down to the win entry i think it may be about 4 or 5 change the default to that and you will boot up in win every time.
Old 11-14-2007, 06:27 PM   #4
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You can use the dd command to create an image of your windows partition. How large is it? How much space is taken up? You can also pipe the output of dd through gzip or bzip2 to compress it, however if the drive was filled previously, it won't compress very well because the bit patterns of the old files (before reformatting) are still present. One thing you could do is use something like a norton utility to zero the free space on the drive. However there is another (free) way of doing it.

I tried an experiment one time where I filled up a partition with files and then deleted the new files. The partition would not compress well. Next I filled the partition with a file of zero's (using the versatile dd program again) and then deleted these files. This had the effect of zero'ing most of the free space. The difference was dramatic.

You could produce such a file in linux and make several copies of it in windows, until you have very little free space left. Then delete these files.

Here is the command you can use to produce a file consisting of zeros:
dd if=/dev/zero of=zerofile bs=1024 count=$((40*1024))
40960+0 records in
40960+0 records out
41943040 bytes (42 MB) copied, 2.59414 seconds, 16.2 MB/s
[jschiwal@delllap ~]$ ls -lh zerofile
-rw-rw-r-- 1 jschiwal jschiwal 40M Nov 14 17:44 zerofile
I selected a block size of 1024 because that is the block size that utilities such as ls use. The "$((40*1024))" is how you perform arithmatic in bash. Since 1024*1024 is 1 MB, you can change the 40 to what you want and the file will be that many Megabytes in length.

Suppose that your Windows partition is /dev/sda1. Also suppose that you have an external usb drive mounted at /media/backups. Note: If the length of the final backup would be greater than 4 GB, you wouldn't be able to use the FAT32 filesystem to hold the backup.

You could back up an image with:
dd if=/dev/sda1 bs=1024 | gzip - >/media/backups/WindowsXP.img.gz

If the partition is 30GB but you only use 8GB, the final file length will be less than 8GB if you had zeroed out the partition. Otherwise it might be closer to 30GB than 8GB so you wouldn't be able to burn the file to a DVD.

I would prefer using an external drive for a backup than using DVDs.
The filesize needn't be constrained. Even if you formatted the drive using the FAT32 filesystem, you could pipe the backup through the "split" program to break it up into slices. Then you can restore the backup by cat'ing together the slices, using a wildcard in the argument name:
cat WindowsXP.img.gz.* | ...

Suppose that the image backup was small enough to burn to a dvd, and you have the dvd disc mounted at /media/dvd. Then you can restore the backup by reversing order of the commands you used to produce the backup:
cat /media/dvd/WindowsXP.img.gz | gunzip | dd of=/dev/sda1 bs=1024
You could also use the zcat program to expand the image:
zcat /media/dvd/WindowsXP.img.gz | dd of=/dev/sda1 bs=1024
Suppose you saved the image uncompressed to a file on an external drive:
dd if=/dev/sda1 bs=1024 of=/media/backups/WindowsXP.img
You could mount the image file and retrieve individual files:
mkdir /mnt/xpbu
mount -t ntfs /media/backups/WindowsXP.img /mnt/xpbu -o ro,loop
If the Windows partition (/dev/hdd1) is mounted somewhere using the "ntfs-3g" filesystem (read-write), you can simply copy from /mnt/xpbu to your windows system. So if a single dll became corrupted or infected, you could copy just that file from your image backup to your windows system. This is another reason to use an external drive for backups. You can pick up a NetDisk enclosure from Radio Shack for example for around $35 and put in a spare drive yourself. I'm sure on the net, they would be even cheaper.

Last edited by jschiwal; 11-14-2007 at 06:50 PM.
Old 11-14-2007, 11:55 PM   #5
Senior Member
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
I use the dd command for that action.

In the past I have run into trouble sometimes getting the contents of a HD that I was imaging with dd to even fit on another HD, so what I have gotten into the habit of doing is splitting the HD image into 100 Meg chunks with the split command.

Commonly when I am doing this, what I am really doing is recovering a failed HD, and often the system I am recovering from has a bigger HD on it than my workstation has, so as I do the recovery in chunks, I can scroll those chunks off of the HD that is receiving the image onto multiple USB drives that I can plug in as I go.

Here is how I do it, using a Knoppix CD on the machine being imaged.

I plug the target machine into the LAN and boot knoppix. Usually I use Samba for the network connections; my LAN has Windows machines on it too so Samba is available and running, and it is easy to use even though both the target machine and the destination HD are running Linux.

When knoppix is running, from the command line I create a mountpoint for the destination HD:

mkdir /mnt/mntpoint

Then I mount the share on the machine that will be receiving the image. Commonly this is my workstation which is named Dadsbox, and most often I will be using a HD that is in the workstation mostly for scratchpad/scratch data purposes. That is drive sdb and partition sdb1 which is shared with the name "space".

smbmount //dadsbox/space /mnt/mntpoint -o username=jiml,password=mypassword

Then I image the drive to Dadsbox with this command:

dd conv=noerror,sync if=/dev/hda | split -b 100000000 - /mnt/space/sysimg.img

This will write out image files starting with the name sysimg.img.aa, then sysimg.img.ab, and so forth with each being exactly 100,000,000 bytes long. I use the conv=noerror,sync because I am recovering from a bad HD (which I have previously run Spinrite on to bring back as much as I can) so I do not want dd to fail on an I/O error (noerror) and I do want it to fill in any spaces in the data that it can't read (sync).

Also, I am not specifying the blocksize, so the blocksize I get is 512 bytes. This is slow; working with a good HD you would skip the conv=noerror,sync and you would probably specify a bigger blocksize, perhaps 32,768.

On the destination machine, I have a USB drive connected and periodically I will execute a command like this:

cp sysimg.img.a* /media/HD/

which will copy sysimg.img.aa through over to the USB drive. I do it this way rather than send the image straight to the USB drive because this way is faster. The USB drive access is just too slow for me.

When this process is done, I have a large number of 100 Meg files, which I can then zip and store on as many different DVDs as is necessary.

To restore the whole thing (commonly onto a new HD), I run knoppix on the target machine, set up the mountpoint, mount the partition on the machine that has the image, load up my image files, unzip them, and execute this command from Knoppix:

cat /mnt/space/LTRecover.img.* | dd of=/dev/hda

This lays the entire image down onto the target HD. Works very well.

Now if you have a big tape drive, then that is the way to go. But if you are imaging a large HD and don't have a tape drive and don't wish to dedicate another HD to the purpose, this mechanism will get the entire job done, and off onto DVDs.
Old 11-15-2007, 04:30 AM   #6
LQ Newbie
Registered: Mar 2007
Location: Auburn, Washington
Distribution: Kubuntu
Posts: 5

Original Poster
Rep: Reputation: 0
Can't I just drag the contents of the C drive onto the dvd and just burn all the files on the drive to a recordable DVD?

I think the space it took up was 7 gigs last time I reformatted and updated windows. All this typing stuff just makes my head spin.
Old 11-15-2007, 04:59 AM   #7
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,185

Rep: Reputation: 4129Reputation: 4129Reputation: 4129Reputation: 4129Reputation: 4129Reputation: 4129Reputation: 4129Reputation: 4129Reputation: 4129Reputation: 4129Reputation: 4129
dd is not the tool to use for filesystem backups.
Blindly continuing on (or truncating, or zero filling ...) on errors ain't acceptable for a backup. Use a tool that understands the filesystem.
In this case something from ntfsprogs - ntfsclone looks like a good candidate.


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
FC3 installation error: partition has to be formatted ennar Fedora - Installation 6 04-11-2005 01:29 PM
windows formatted hard drive motaguense Linux - Hardware 3 09-15-2004 04:49 PM
partition formatted on each new installation? timsch75 Linux - Newbie 2 03-01-2004 11:28 AM
Formatted my redhat, and can't boot to windows.. PLease help.. Willew Linux - Software 2 02-06-2004 04:42 PM
Installing Linux onto a formatted Windows HD Xith Linux - Newbie 3 12-29-2003 11:41 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:30 AM.

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