Uninstalling Linux

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Calum

Uninstalling Linux

Post by Calum »

Well I got sick of Red Hat Linux the other day, and I made the mistake of using Partition Magic 7, from Windows, to erase the Linux partition.

When I rebooted after wiping the partition and merging the partition into my Windows one, I got hit with a nasty shock. Because my bootloader couldn't find any other partitions to boot into, it completely stopped me from booting up at all.

To fix this, I re-installed Red Hat using the little disk partitioner that comes with it. THe thing is, I don't want Linux any more but I can't see any way of getting rid of it :'( :P

I did go onto the Red Hat Linux website and got a help document that told me to type: "fdisk /mbr" at the Terminal to uninstall the boot loader. Well when I did, it couldn't find the file or directory "/mbr" and when I did it without a space ("fdisk/mbr") it didn't like that either.

Does anyone out there know what I should do, short of reinstalling Windows XP?

Any help would be greatly appreciated, Cheers

Calum

By the way, I'm using LILO as a bootloader, if that helps
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Uninstalling Linux

Post by Solar »

The fdisk command is meant to be issued from the XP terminal, not the Linux one.

The problem is that most bootloaders are two-stage bootloaders, i.e. the MBR boots a little program which shows the boot menu, accepts the selection, and only then boots the selected OS. When removing RedHat from your system, you removed that second stage, which leaves the bootloader brainless.

If you cannot get access to your XP at all ATM, you could install GRUB from the RedHat installation, making sure all files involved reside on the Windows partition. You should then be able to remove the Linux partition from the system without problems.
Every good solution is obvious once you've found it.
AR

Re:Uninstalling Linux

Post by AR »

Edit: Solar posted first so I've reworded to just include the bits he didn't say...

You can use Linux's FDISK to "set active partition" and set it to the Windows partition which will hopefully still have the Windows Bootloader installed there.

The "FDISK /MBR" is probably only from the DOS FDISK tool not Linux, for Linux's you go "fdisk /dev/hda" (/dev/hda is the first harddrive, b is the second, etc). If you have the windows CD you can boot that then do a "Recovery Console" there is a crappy fdisk which will take a "fdisk /mbr" which will do it for you, however, the Recovery Console will demand the Administrator password [I MEAN the "Administrator" account NOT an account with Admin priviledge, if you don't remember the password for that account and can't get the Linux tool to fix it then you will have to reinstall])
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Uninstalling Linux

Post by Solar »

AR wrote: You can use Linux's FDISK to "set active partition" and set it to the Windows partition which will hopefully still have the Windows Bootloader installed there.
Most likely not, from what Calum wrote I'd suspect that it's LILO installed in the MBR which couldn't find its second stage. Usually Linux bootloaders don't change the "active" flag at all since Linux doesn't require its partition to be "active".
The "FDISK /MBR" is probably only from the DOS FDISK tool not Linux, for Linux's you go "fdisk /dev/hda" (/dev/hda is the first harddrive, b is the second, etc).
Doing two very different things - fdisk /mbr installs the standard Windows bootloader to MBR, fdisk /dev/hda starts the partitioning dialog for the drive.


ACK on the recovery CD, though.
Every good solution is obvious once you've found it.
AR

Re:Uninstalling Linux

Post by AR »

Solar wrote:
AR wrote: You can use Linux's FDISK to "set active partition" and set it to the Windows partition which will hopefully still have the Windows Bootloader installed there.
Most likely not, from what Calum wrote I'd suspect that it's LILO installed in the MBR which couldn't find its second stage. Usually Linux bootloaders don't change the "active" flag at all since Linux doesn't require its partition to be "active".
The "FDISK /MBR" is probably only from the DOS FDISK tool not Linux, for Linux's you go "fdisk /dev/hda" (/dev/hda is the first harddrive, b is the second, etc).
Doing two very different things - fdisk /mbr installs the standard Windows bootloader to MBR, fdisk /dev/hda starts the partitioning dialog for the drive.
Yes I am aware of the difference, I was hoping that the Linux loader wouldn't have been that stupid (ie. that it left the MBR be, or at least only replaced it with something that did the same as the DOS/Windows version and just installed itself in the partition's bootsector), must have picked up some un-neighbourly habits from Windows.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Uninstalling Linux

Post by Candy »

AR wrote: Yes I am aware of the difference, I was hoping that the Linux loader wouldn't have been that stupid (ie. that it left the MBR be, or at least only replaced it with something that did the same as the DOS/Windows version and just installed itself in the partition's bootsector), must have picked up some un-neighbourly habits from Windows.
No.

LILO upon installation is configurable as to what you want it to do. Put itself in the partition boot sector, putting itself on a floppy disk or putting itself in the MBR, which is an option that is in Slackware at least labeled with "Potentially dangerous".

Considering that slackware is a distro that is for the people that should know, I would say that you've been warned. Don't say a program is malfunctioning when it does exactly what you ask it to do.
AR

Re:Uninstalling Linux

Post by AR »

Certainly makes me glad that I use Gentoo then, I got to configure exactly how GRUB was installed.

It is entirely probable that Calum installed LILO incorrectly of course (Never used it, only used GRUB).
JoeKayzA

Re:Uninstalling Linux

Post by JoeKayzA »

<rant victim="some-linux-distros">
I don't know why they actually started with this 'install bootloader in MBR' BS. Maybe to avoid further collisions with the windows bootloader, I guess. But all in all, it is a dirty and dangerous option, IMO. The bootloader code simply doesn't belong into the MBR, it belongs into a partitions boot sector. The MBR's boot code should do nothing more than interpret the partition table, check for the active one, and load it's boot sector. And I believe this code is standardized for the PC-arch.
</rant>

As for the problem - the easiest is probably really the recovery option of the XP setup CD. If you have access to a linux system on the machine (live cd or something), you *could* also use dd to extract the mbr from some other (working) machine, and insert it into your (broken) hd. But make sure to back up the broken MBR, because of the partition table info.

According to this paper (search for keyword 'fdisk'), overwriting the MBR with dd does not overwrite the partition table, but I have _not_ yet tried this.

cheers Joe
Calum

Re:Uninstalling Linux

Post by Calum »

It is F8 at startup that gets you into the Terminal in XP isn't it?

As for the GRUB/LILO thing, I originally used GRUB, but when I reinstalled Linux so that I could get into XP I changed it to LILO...

I chose to say that i entered the command in Linux because that's where I got the most response from the computer :P
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Uninstalling Linux

Post by Solar »

@ AR / JoeKayzA:

Sorry but that doesn't work. The Windows bootloader does not provide a boot menu, and chainloads the active primary partition. AFAIK, it is utterly unable to boot an installed Linux at all. Thus, leaving the MBR as-is is not an option.

And if you install a boot menu on partition X, then delete that partition, not having the boot menu available anymore is hardly Linux' fault. The same would have happened if you had installed a Windows based boot menu, then removed the WinXP partition...
Every good solution is obvious once you've found it.
AR

Re:Uninstalling Linux

Post by AR »

Solar wrote:Sorry but that doesn't work. The Windows bootloader does not provide a boot menu, and chainloads the active primary partition.
You mean the bootsector chainloads the active partitions bootsector which can then load GRUB/LILO/XOSL/whatever. And no, Windows does have a bootmenu but it only allows dual booting multiple versions of Windows.
AFAIK, it is utterly unable to boot an installed Linux at all. Thus, leaving the MBR as-is is not an option.
The Windows bootloader won't boot Linux, but the bootsector is entirely capable of loading the GRUB bootsector from any partition to display a boot menu (in which you could chainload Windows, I do not mean that Windows' bootloader should be the primary, just that the loader shouldn't compromise the way the MBR works for situations such as this). And trust me that leaving the MBR as the one put there by Windows with GRUB on a partition works fine as that is my current setup.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Uninstalling Linux

Post by Solar »

AR wrote: The Windows bootloader won't boot Linux, but the bootsector is entirely capable of loading the GRUB bootsector from any partition to display a boot menu (in which you could chainload Windows...
No, you couldn't chainload Windows. The Windows partition bootsector you'd want to chainload is the very one you - in your concept above - have configured to load the GRUB bootsector from "any partition". You'd be stuck in a boot circle. ;)
And trust me that leaving the MBR as the one put there by Windows with GRUB on a partition works fine as that is my current setup.
I'm curious as to how that would work. Let's say Windows is /dev/hda1, Linux is /dev/hda2. /dev/hda has the Windows bootsector, which chainloads the active partition's bootsector - /dev/hda1. That would load GRUB and present the menu to boot Linux from /dev/hda2, or chainload /dev/hda1 - which would give you the GRUB menu again.

Or you have set /dev/hda2 as active, and have the Windows MBR boot that partition bootsector. Then, GRUB would have to set /dev/hda1 as active before chainloading /dev/hda1 - but how do you reset the active flag to /dev/hda2 for the next boot?

I just don't see how it could work.
Every good solution is obvious once you've found it.
AR

Re:Uninstalling Linux

Post by AR »

Ok, my current setup is this (not in Linux so I can't just dump the FDISK at the moment):
/dev/sda (Windows MBR)
/dev/sda1 (Windows Bootsector and Loader [WinXP x64])
/dev/sda2 (GRUB, FAT [Haven't bothered to reformat as EXT2FS yet])
/dev/sda3 (Unformatted, reserved for FreeBSD at a later date)
/dev/sda4 (Extended)
/dev/sda5 (Linux Root)
/dev/sda6 (Linux /var/tmp)
/dev/sda7 (Linux Swap)
/dev/sda8 (Linux /home)

The boot process from the BIOS goes: BIOS > Windows MBR (/dev/sda) > GRUB Partition Bootsector (Active Partition [/dev/sda2]) > GRUB > Chainload Windows Bootsector (/dev/sda1) > Windows Bootloader > Windows. You don't seem to have recognised the MBR as being seperate from Partition 1, the MBR is sector 0, Partition 1's Bootsector is sector 1 (give or take Cylinder alignment or whatever happens in between the two)
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Uninstalling Linux

Post by Candy »

Solar wrote: Sorry but that doesn't work. The Windows bootloader does not provide a boot menu, and chainloads the active primary partition. AFAIK, it is utterly unable to boot an installed Linux at all. Thus, leaving the MBR as-is is not an option.

And if you install a boot menu on partition X, then delete that partition, not having the boot menu available anymore is hardly Linux' fault. The same would have happened if you had installed a Windows based boot menu, then removed the WinXP partition...
The default MBR chainloads the active partition, and if (and only if) that's a known windows type does it use the information stored there. The windows boot loader CAN boot Linux, but through chainloading.

GRUB can also be installed on /dev/hda1 and then still boot Windows, since it then boots a file that's a backup of the boot sector instead.

You should not blame the program for doing something that's entirely to be expected, since iirc it's documented in the documentation of the program itself.

Solution: boot a DOS/Windows boot disk and run fdisk /mbr.

Don't expect DD to copy the partition table over for you. If you partition using DD you should be smart enough to not screw that up. Try copying the partition table from your disk into the bootsector in the file (using

Code: Select all

dd if=/dev/hda of=bootsector skip=446 count=64 bs=1 seek=446 conv=notrunc
which copies 64 bytes from offset 446 in the input to offset 446 in the output and doesn't truncate the output).
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Uninstalling Linux

Post by Solar »

Last time I tried, Windows gave me hell about it's C: partition not being the one flagged active. That's why I was confused about the setup. Seems like it works with XP...
Every good solution is obvious once you've found it.
Post Reply