Thread: How do I completely remove Linux?

  1. #1
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545

    How do I completely remove Linux?

    I just installed Linux to try to have a Windows/Linux dual boot system, but Grub is getting an error #21 when it loads, so I can't boot into anything.
    I tried doing a Ghost restore, but the damn thing doesn't let me restore the MBR!
    I tried using the Vista startup repair, but it says it can't find anything wrong.

    How do I fix my MBR so I can boot back into Windows?
    Back in the Windows 2000 & XP days I could run "FDISK /MBR" but I couldn't find fdisk on the Vista DVD.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  2. #2
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    Did the Linux installer change your active partition? Sometimes, they install grub to the Linux partition and leave your mbr alone. Try changing the boot partition back to C:
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    I'm not sure what Linux did to my system.
    I think it probably has something to do with my ICH9R RAID 5 which Linux sees as 3 separate drives, so it probably installed grub to the MBR of the first hard drive in the RAID set causing the ICH9R BIOS to get totally confused about what's going on.

    Anyways, Linux is gone now and I found out that on Vista I need to run bootrec /fixmbr
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Hmmm. Here's what you should have done.

    The MBR is 512b. Before the install:
    dd if=/dev/hda of=mbr.copy bs=512 count=1

    Dunno if there is a dos equivalent so you could do this from Windows, anyway, notice that's "hda" not "hda1", etc. You know where it is. Now you copy that to a usb or floppy or something and keep track of it.

    To restore to the former state:
    dd if=mbr.copy of=/dev/hda bs=512 count=1
    You can do this from a cdrom rescue disk, swapping in another hd, etc.

    I have done this quite a number of times with both windows and linux. If it was a windows only drive before, restoring the mbr will mean you skip grub and go straight to windows as if linux did not exist.

    New linux installs always seem to overwrite the mbr and reference the grub they installed. I am too lazy to figure out how to prevent this for every distro (if it's even possible), but I usually prefer to keep using the grub that's already there and manually add new entries, so I back up the mbr first and then replace the new one afterward.
    Last edited by MK27; 04-18-2010 at 07:52 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by MK27 View Post
    The MBR is 512kb. Before the install:
    dd if=/dev/hda of=mbr.copy bs=512 count=1
    An MBR is 512 bytes, not kb. But I think you know that, as you do copy the right number of bytes. But just for whoever reads it; the MBR is NOT 512kB but 512B.

  6. #6
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Yeah, sorry, will edit that. The dd command was correct (bs = block size and it's in bytes).
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  7. #7
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    Quote Originally Posted by MK27 View Post
    New linux installs always seem to overwrite the mbr and reference the grub they installed. I am too lazy to figure out how to prevent this for every distro (if it's even possible), but I usually prefer to keep using the grub that's already there and manually add new entries, so I back up the mbr first and then replace the new one afterward.
    Most Linux installers I've used have an option (usually just prior to the final step) that allows you to choose where to install grub, or to not install it at all. You might have to look into advanced options or something, but it's usually available.

    I've also installed a couple of distributions that left the mbr alone, and just changed the boot partition to the one where grub was installed. In that case, all you have to do is change the active partition back to what it was previously.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  8. #8
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by NeonBlack View Post
    Most Linux installers I've used have an option (usually just prior to the final step) that allows you to choose where to install grub, or to not install it at all. You might have to look into advanced options or something, but it's usually available.

    I've also installed a couple of distributions that left the mbr alone, and just changed the boot partition to the one where grub was installed. In that case, all you have to do is change the active partition back to what it was previously.
    Is there any way to get Linux to insert itself into the list of OS's in the Windows boot loader instead of installing Grub or Lilo, which either loads Linux or goes to the Windows boot loader...? I imagine it would be pretty simple to do.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  9. #9
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    I also prefer to use Windows's boot loader instead of grub, but there is no way for it to boot Linux directly. So what I do instead is have the Windows boot loader boot grub4dos, which is configured to boot Linux instantly. I find that this works pretty well as long as you don't have more than 1 Linux installation. You can get it to work with multiple Linux installs, but it requires a bit more effort.

    Be sure to read the documentation before doing anything:
    Grub4dos tutorial - Grub4Dos Wiki
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  10. #10
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Isn't there a way to get rid of the Windows boot loader (as in the menu), and add one entry for every Windows installation in grub?

    I'm pretty sure the Windows boot loader can't boot Linux, though.

  11. #11
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by cyberfish View Post
    I'm pretty sure the Windows boot loader can't boot Linux, though.
    Why not? Does it need to do more than go to a certain location of the hard drive and start executing what's there? I would imagine that's how it works, but I know nothing about boot loaders.

    Either way, I'm not going to try installing Linux on my good machine again. The partition manager thought one of my RAID disks was a Linux swap partition, and I don't trust it enough to not start swapping stuff onto my RAID drive and totally screw up my data.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  12. #12
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    It needs to go into the filesystem (it has filesystem drivers) and find the right kernel, and pass it the right options to start it.

    Unlike Windows, Linux installations can and most do have multiple kernels.

  13. #13
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by cpjust View Post
    Either way, I'm not going to try installing Linux on my good machine again. The partition manager thought one of my RAID disks was a Linux swap partition, and I don't trust it enough to not start swapping stuff onto my RAID drive and totally screw up my data.
    Don't use the installer partition manager, they're all gimpy GUI things to simply things for newbies. Set up the partitions yourself with windows (if possible) or use a cdrom and run fdisk.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  14. #14
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    gparted (a frontend to parted) is pretty good. You can launch it from most Live-CDs (I know ubuntu has it).

  15. #15
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Sure, but can you guarantee that Linux won't see my RAID drive and say "Oh look, a big swap partition. Lets start using it"?
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 03-10-2008, 12:08 PM
  2. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 05:15 AM
  3. command line alias remove for linux
    By iain in forum Tech Board
    Replies: 6
    Last Post: 11-22-2004, 01:39 PM
  4. Linux for Windows!
    By Strut in forum Linux Programming
    Replies: 2
    Last Post: 12-25-2002, 11:36 AM
  5. linux vs linux?
    By Dreamerv3 in forum Linux Programming
    Replies: 5
    Last Post: 01-22-2002, 09:39 AM