Wiped out WindowsXP

Asked by John Wilson

I have a desktop with two hard drives.
I reinstalled Ubuntu from the live CD, must have muddled up master and slave and I fear I overwrote Windows drive.
I did a sudo fdisk -l and here is the output:
john@john-desktop:~$ sudo fdisk -l
Password:

Disk /dev/hda: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot Start End Blocks Id System
/dev/hda1 * 1 9789 78630111 83 Linux
/dev/hda2 9790 9964 1405687+ 5 Extended
/dev/hda5 9790 9964 1405656 82 Linux swap / Solaris

Disk /dev/hdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot Start End Blocks Id System
/dev/hdb1 * 1 9553 76734441 83 Linux
/dev/hdb2 9554 9729 1413720 5 Extended
/dev/hdb5 9554 9729 1413688+ 82 Linux swap / Solaris

Disk /dev/sda: 1024 MB, 1024966656 bytes
32 heads, 63 sectors/track, 993 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes

   Device Boot Start End Blocks Id System
/dev/sda1 1 992 999813+ b W95 FAT32

Firstly have I identified the problem correctly?
Secondly how do I reinstall Windows without wiping out Ubuntu? Should I physically disconnect the Ubuntu drive?
Thirdly how do I reinstall grub?
Help,
John

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Jim Hutchinson
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Jim Hutchinson (jphutch) said :
#1

1) Yep, looks like windows is gone.

2) Since it looks like ubuntu is using the whole drive (on both) there is no way to not destroy one of them. You might be able to repartition and move but I think that might might not be worth it. You can disconnect the ubuntu drive you want to keep but it isn't necessary (unless you fear human error). Just boot your windows CD and make sure the primary drive is the one you want to install it on.

3) To reinstall grub you can check my how to (http://nococomp.com/?p=8) it also has links to some other sources. The main problem will be getting grub on the primary boot drive and then getting the menu entries to correctly identify the windows and ubuntu partitions. I've noticed that when ubuntu is not the primary drive but booted it acts like the primary drive and then grub gets set up wrong. If that happens you can post your /boot/grub/menu.lst file and we can work it out.

Revision history for this message
John Wilson (jwilsondmartin) said :
#2

Jim
Thank you for your help.
I reinstalled Windows on my slave drive while my master drive with Ubuntu was unpowered.
When I booted up I can run Ubuntu, but with other operating systems there is Ubuntu on /dev/hdb1.
When I try and start it I get Error 17: Cannot mount selected partition.

I followd the Fixing GRUB errors article with the same result.

When I try and view /boot/grub/menu.1st with less or sudo less I get told there is no such file or directory.
When I sudo gedit /boot/grub/menu.1st I get a blank file

How do I fix it or should I open the box and swap the two drives around?
John

Revision history for this message
Jim Hutchinson (jphutch) said :
#3

You can swap the drives or change the order in the BIOS it may or may not solve the problem. If not, can you boot ubuntu with both drives connected? If so, open a terminal and type

sudo fdisk -l

Copy and paste the output.

Then type

cat /boot/grub/menu.lst

Copy and paste the output.

If you can't boot ubuntu try using a live CD and doing the same. Make sure you are actually looking at the HD with the second command above. It's been a while since I messed with a live CD and I can't remember.

Revision history for this message
John Wilson (jwilsondmartin) said :
#4

Hi Jim,
Thank you for your prompt reply.
Rather than trying to change the drives I am pasting the outpurts:

For sudo fdisk -l it is:
Disk /dev/hda: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot Start End Blocks Id System
/dev/hda1 * 1 9789 78630111 83 Linux
/dev/hda2 9790 9964 1405687+ 5 Extended
/dev/hda5 9790 9964 1405656 82 Linux swap /
Solaris

Disk /dev/hdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot Start End Blocks Id System
/dev/hdb1 * 1 9553 76734441 7 HPFS/NTFS
/dev/hdb2 9554 9729 1413720 5 Extended
/dev/hdb5 9554 9729 1413688+ 82 Linux swap /
Solaris

The second one is a bit disconcerting:
john@john-desktop:~$ cat /boot/grub/menu.1st
cat: /boot/grub/menu.1st: No such file or directory

What next?
John

On Sun, 2007-23-09 at 13:56 +0000, Jim Hutchinson wrote:
> Your question #13737 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/13737
>
> Status: Open => Answered
>
> Jim Hutchinson proposed the following answer:
> You can swap the drives or change the order in the BIOS it may or may
> not solve the problem. If not, can you boot ubuntu with both drives
> connected? If so, open a terminal and type
>
> sudo fdisk -l
>
> Copy and paste the output.
>
> Then type
>
> cat /boot/grub/menu.lst
>
> Copy and paste the output.
>
> If you can't boot ubuntu try using a live CD and doing the same. Make
> sure you are actually looking at the HD with the second command above.
> It's been a while since I messed with a live CD and I can't remember.

Revision history for this message
Jim Hutchinson (jphutch) said :
#5

On the /boot/grub/menu.lst it looks like you have .1st (the number one rather than a small letter L) and that may be the reason for that error.

Without seeing the menu.lst file I can't say for sure what it happening. Most likely it's looking for files it needs for booting in the wrong place or grub is installed in the wrong place. If grub loads but it won't boot ubuntu it's probably pointed at the wrong drive (or what has happed to me is that the at boot the drive actually changes from hda to hdb or vice versa and I had to point to what seemed like the wrong drive).

In short, the menu.lst for ubuntu should be pointing to hda1, However, with UUIDs now it's hard to know what the drive is so it might be worth backing up menu.lst and changing the UUIDs to read /dev/hda1. We can put the right UUID back once we know it's working.

One thought. Windows in on the secondary drive currently and often it doesn't like that. It may work just fine there or it may be worth changing that drive via the BIOS to be the primary drive. That will of course change how grub and such works also so make that decision first and then figure out what drives to point menu.lst to. UUIDs are supposed to make this less of an issue but I haven't seen it so much in my own case.

Revision history for this message
John Wilson (jwilsondmartin) said :
#6

Hi Jim,
Sorry for my stupid typo.
Here is the menu.lst file:
john@john-desktop:~$ cat /boot/grub/menu.lst
# menu.lst - See: grub(8), info grub, update-grub(8)
# grub-install(8), grub-floppy(8),
# grub-md5-crypt, /usr/share/doc/grub
# and /usr/share/doc/grub-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from
0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default
entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not change this entry to 'saved'
or your
# array will desync and will not let you boot your system.
default 0

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the
default entry
# (normally the first entry defined).
timeout 10

## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
#hiddenmenu

# Pretty colours
#color cyan/blue white/blue

## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive
editing
# control (menu entry editor and command-line) and entries protected by
the
# command 'lock'
# e.g. password topsecret
# password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title Windows 95/98/NT/2000
# root (hd0,0)
# makeactive
# chainloader +1
#
# title Linux
# root (hd0,1)
# kernel /vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below

## DO NOT UNCOMMENT THEM, Just edit them to your needs

## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
## kopt_2_6_8=root=/dev/hdc1 ro
## kopt_2_6_8_2_686=root=/dev/hdc2 ro
# kopt=root=UUID=efac66d5-ef28-4f3d-a45d-eed3b146f103 ro

## Setup crashdump menu entries
## e.g. crashdump=1
# crashdump=0

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd0,0)

## should update-grub create alternative automagic boot options
## e.g. alternative=true
## alternative=false
# alternative=true

## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
## lockalternative=false
# lockalternative=false

## additional options to use with the default boot option, but not with
the
## alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=quiet splash

## should update-grub lock old automagic boot options
## e.g. lockold=false
## lockold=true
# lockold=false

## Xen hypervisor options to use with the default Xen boot option
# xenhopt=

## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
## altoptions=(recovery) single
# altoptions=(recovery mode) single

## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
## howmany=7
# howmany=all

## should update-grub create memtest86 boot option
## e.g. memtest86=true
## memtest86=false
# memtest86=true

## should update-grub adjust the value of the default booted system
## can be true or false
# updatedefaultentry=false

## ## End Default Options ##

title Ubuntu, kernel 2.6.20-16-generic
root (hd0,0)
kernel /boot/vmlinuz-2.6.20-16-generic
root=UUID=efac66d5-ef28-4f3d-a45d-eed3b146f103 ro quiet splash
initrd /boot/initrd.img-2.6.20-16-generic
quiet
savedefault

title Ubuntu, kernel 2.6.20-16-generic (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.20-16-generic
root=UUID=efac66d5-ef28-4f3d-a45d-eed3b146f103 ro single
initrd /boot/initrd.img-2.6.20-16-generic

title Ubuntu, kernel 2.6.20-15-generic
root (hd0,0)
kernel /boot/vmlinuz-2.6.20-15-generic
root=UUID=efac66d5-ef28-4f3d-a45d-eed3b146f103 ro quiet splash
initrd /boot/initrd.img-2.6.20-15-generic
quiet
savedefault

title Ubuntu, kernel 2.6.20-15-generic (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.20-15-generic
root=UUID=efac66d5-ef28-4f3d-a45d-eed3b146f103 ro single
initrd /boot/initrd.img-2.6.20-15-generic

title Ubuntu, memtest86+
root (hd0,0)
kernel /boot/memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the
Debian
# ones.
title Other operating systems:
root

# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/hdb1.
title Ubuntu, kernel 2.6.20-16-generic (on /dev/hdb1)
root (hd1,0)
kernel /boot/vmlinuz-2.6.20-16-generic
root=UUID=58846459-588f-44fc-961d-2c1cc99bb9c0 ro quiet splash
initrd /boot/initrd.img-2.6.20-16-generic
savedefault
boot

# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/hdb1.
title Ubuntu, kernel 2.6.20-16-generic (recovery mode)
(on /dev/hdb1)
root (hd1,0)
kernel /boot/vmlinuz-2.6.20-16-generic
root=UUID=58846459-588f-44fc-961d-2c1cc99bb9c0 ro single
initrd /boot/initrd.img-2.6.20-16-generic
savedefault
boot

# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/hdb1.
title Ubuntu, kernel 2.6.20-15-generic (on /dev/hdb1)
root (hd1,0)
kernel /boot/vmlinuz-2.6.20-15-generic
root=UUID=58846459-588f-44fc-961d-2c1cc99bb9c0 ro quiet splash
initrd /boot/initrd.img-2.6.20-15-generic
savedefault
boot

# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/hdb1.
title Ubuntu, kernel 2.6.20-15-generic (recovery mode)
(on /dev/hdb1)
root (hd1,0)
kernel /boot/vmlinuz-2.6.20-15-generic
root=UUID=58846459-588f-44fc-961d-2c1cc99bb9c0 ro single
initrd /boot/initrd.img-2.6.20-15-generic
savedefault
boot

# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/hdb1.
title Ubuntu, memtest86+ (on /dev/hdb1)
root (hd1,0)
kernel /boot/memtest86+.bin
savedefault
boot

Where do I start to edit it?
John

On Sun, 2007-23-09 at 23:58 +0000, Jim Hutchinson wrote:
> Your question #13737 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/13737
>
> Status: Open => Answered
>
> Jim Hutchinson proposed the following answer:
> On the /boot/grub/menu.lst it looks like you have .1st (the number one
> rather than a small letter L) and that may be the reason for that error.
>
> Without seeing the menu.lst file I can't say for sure what it happening.
> Most likely it's looking for files it needs for booting in the wrong
> place or grub is installed in the wrong place. If grub loads but it
> won't boot ubuntu it's probably pointed at the wrong drive (or what has
> happed to me is that the at boot the drive actually changes from hda to
> hdb or vice versa and I had to point to what seemed like the wrong
> drive).
>
> In short, the menu.lst for ubuntu should be pointing to hda1, However,
> with UUIDs now it's hard to know what the drive is so it might be worth
> backing up menu.lst and changing the UUIDs to read /dev/hda1. We can put
> the right UUID back once we know it's working.
>
> One thought. Windows in on the secondary drive currently and often it
> doesn't like that. It may work just fine there or it may be worth
> changing that drive via the BIOS to be the primary drive. That will of
> course change how grub and such works also so make that decision first
> and then figure out what drives to point menu.lst to. UUIDs are supposed
> to make this less of an issue but I haven't seen it so much in my own
> case.

Revision history for this message
Jim Hutchinson (jphutch) said :
#7

Well, this part

# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/hdb1.
title Ubuntu, kernel 2.6.20-16-generic (on /dev/hdb1)
root (hd1,0)
kernel /boot/vmlinuz-2.6.20-16-generic
root=UUID=58846459-588f-44fc-961d-2c1cc99bb9c0 ro quiet splash
initrd /boot/initrd.img-2.6.20-16-generic
savedefault
boot

seems to be problematic since it's pointing to an ubuntu install on a windows partition (fdisk said hdb1 was NTFS).

I think the easiest way to begin would be to reinstall grub and let it try and sort this out. It should find the windows partition and set it up right or at least give you an entry that we can edit. As it is, windows doesn't exist in that menu.lst file.

To reinstall grub you can use my little how to (http://nococomp.com/?p=8). It also contains links to some other documents on grub. After you reinstall grub post back and let me know if that solved the problems or if we still need to edit.

Revision history for this message
John Wilson (jwilsondmartin) said :
#8

I have reinstalled GRUB but the boot up menu looks the same.
How do we edit?
John

Revision history for this message
Jim Hutchinson (jphutch) said :
#9

That's odd. No wait, it's not. We only set up grub again but didn't generate a new menu. I'm trying to find out how to generate a new menu.lst file but so far no luck.

The manual way is to open the file

gksudo gedit /boot/grub/menu.lst

and delete all the entries that are after

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title Other operating systems:
root

Then add the proper entry for windows

#windows on hdb1
title Windows XP
root (hd1,0)
savedefault
makeactive
chainloader +1

The only thing I'm not sure about is if anything will go goofy with windows being on the second drive. Try that and see if it works. If not, let me know what happens and the errors if any.

Revision history for this message
John Wilson (jwilsondmartin) said :
#10

Hi Jim,
I edited the file so that the last bit looks like this:
### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title Other operating systems:
root

#windows on hdb1
title Windows XP
root (hd1,0)
savedefault
makeactive
chainloader +1

When I restart and choose the Windows XP option I get the message Starting up but it fails to load.
Is something missing or is Windows not liking where it is?
In which case would it be quicker just to reinstall everything properly. I have things backed up.
Regards,
John

Revision history for this message
Jim Hutchinson (jphutch) said :
#11

Whether or not to reinstall is your call. I find installing windows a pain so i try to avoid it. However, if fixing it is even more of a pain then installing seems a good option.

Is the starting up message from grub or from windows? If grub then we may not have it set right. If windows then there could be problems with the windows install. You could also use the windows boot cd to repair it. Doing that will overwrite grub so you will have to install grub again but could fix the problem.

Revision history for this message
John Wilson (jwilsondmartin) said :
#12

Hi Jim,
The start up message was from grub and I have reinstalled both OS in the right places and things are going much better.
Thank you for all your help, I learnt quite a lot
John

Revision history for this message
John Wilson (jwilsondmartin) said :
#13

Hi Jim,
When I reinstalled Windows and Ubuntu I found that my WindowsXP was assigned to Drive E:.
I am having trouble installing my Windows Palm software to Drive E:, in short I cannot.
I could rename Drive E: to Drive C: and reinstall my windows based programs that I am still using but would this mess up GRUB? How would I need to edit it from the live Ubuntu disk?
Regards,
John

Revision history for this message
Jim Hutchinson (jphutch) said :
#14

I don't think I know the answer to that. Windows "numbers" drives starting at C for the drives it can read. It almost always names the windows drive C. If it didn't then I'm not sure why. I don't think grub cares about the windows drive names. It goes by device names from the hardware level. If you make changes and break grub we can troubleshoot it. I'm not sure what to tell you though before hand. My guess is changing E to C won't break grub.

Revision history for this message
John Wilson (jwilsondmartin) said :
#15

Hi Jim
I disconnected my slave drive with Ubuntu on it and then reinstalled Windows XP which is now on Drive C: but when I boot up I do not see grub.
I tried changing the second boot device from HDD-0 to HDD-1 but then I could not load an operating system.
How do I reinstall grub from the Ubuntu CD?
John

Revision history for this message
Best Jim Hutchinson (jphutch) said :
#16

Try these directions.

http://nococomp.com/?p=8

Revision history for this message
John Wilson (jwilsondmartin) said :
#17

Thank you Jim. It worked perfectly.
John

Revision history for this message
Jim Hutchinson (jphutch) said :
#18

Glad I could help...eventually. :)