don't be as dumb as me

Discuss Applications
Post Reply
worker201
guru
guru
Posts: 668
Joined: Sun Jun 13, 2004 6:38 pm
Location: Hawaii

don't be as dumb as me

Post by worker201 » Wed Nov 10, 2004 9:00 pm

I nearly had a cerebral hemmorhage and/or suicide today. You know how it is when it comes to data/computer loss... Anyway, I thought I would share my story, so the same thing doesn't happen to you.

At the office, I have a 120GB hd, and 1/3 of that is reserved for Fedora, while the rest goes toward Windows XP. Grub lets me choose between them at boot time. Today, while making a backup to prepare for FC3 installation, I noticed that my free space was only like 2gig. All the postgresql stuff required by Grass, and 15gig of sonar data adds up pretty fast. So I decided that I would get a new 2nd hard drive, and let Windows have back the space I took for Linux.

Loaded up Partition Magic, the NTFS resizer, and removed my Linux root and swap partitions. Then extended NTFS to cover the whole drive, except for the 20gig I left as Fat32, for data transfers. Reboot, and there ya go.

Except I forgot about grub! It was still there in the MBR. And when it couldn't find Linux anywhere, it started to get angry. I could not boot into Windows to save my life. All the Linux stuff was backed up on an external hd, but the Wincrap hadn't been backed up in months. All I could get was a boot menu that said "grub>", and I didn't have any clue what to do with it. "help" gave a list of fun commands, but since all of them required some sort of device string, which I didn't know, I was pretty much screwed.

So I broke out the windows installation disk. After it loads all the setup files, it asks you if you would like to install or repair. If you choose repair, and know the administrator password, it will give you a limited prompt. You can't do everything dos or windows from there, but Thank God there is a "fixmbr" command. Windows (not surprisingly) found something strange in my MBR, and was only too happy to replace it. After that, I was able to boot into windows and start a fresh backup with no problems.

The moral of the story (without bashing Microsoft) is that you should always remember grub when adjusting your partition table. I'm sure there is a way to remove grub painlessly, but I sure as heck didn't find it today. Fortunately, MS is aware that this sort of thing happens, and includes the tools you need on the install cd.

agent007
administrator
administrator
Posts: 254
Joined: Wed Feb 12, 2003 11:26 pm

Post by agent007 » Thu Nov 11, 2004 4:41 am

Wouldnt Knoppix do the trick?

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Thu Nov 11, 2004 7:36 am

You actually shouldn't have had to do any of that. Here's what I would have done:

1) Install second drive
2) Install Linux on second drive and tell it to install GRUB on /dev/hda (replacing the grub boot sector that pointed to GRUB on the Linux partition on the first HD)
3) Make sure booting worked between Linux on disk2 and "that other OS".
4) Remove the linux partitions from the first disk and resize your NTFS appropriately. Done

Even still, when you got to where your system wouldn't boot because you deleted the GRUB boot loader when you removed the Linux partition all you should have to do is install Linux on the second disk and tell it to install GRUB on /dev/hda (just like when you originally set up the dual boot).

The MBR is the first 512 bytes of your hard drive (and on floppy drives). The first 446 bytes of that is where a small amount of code can be put along with a pointer that will redirect execution to a selected partition. In your case that would be a pointer to the GRUB boot loader on the 1st Linux partition. When you ran your repair it just fixed that 1st 446 bytes which even "FDISK /MBR" would have done if you had an old DOS disk lying around. Linux also comes with tools for this, in fact you could just use the trusty old "dd" command with appropriate params. "qtparted" could have been used to do all the partition work including resizing the NTFS partition (Knoppix works good for all of this).

Most distros (including Knoppix) also come with tools for saving and restoring the MBR and for backing up and manipulating partitions (qtparted, partimage, dd, etc. There is a tool specifically for backing up and restoring the MBR but I can't remember the name of it). You did figure out 1 of the several ways to get done what you needed. At least you didn't reinstall the OS as then we would have had reason to agree with the title of the thread. :)

caveman
programmer
programmer
Posts: 130
Joined: Sun Feb 09, 2003 1:08 pm
Location: Midrand Gauteng, South Africa

Post by caveman » Thu Nov 11, 2004 4:06 pm

In a similiar fashion - let me share my headaches.

Have a small SMD mobo - 850mhz running only the server part of FC1.
I use this as a fire-wall and the modems are connected to it.
Only installed ipkungfu to share the internet connection.

Last Friday got hit by lightning - which fried 2 of my machines, including
the SMB. The other server wasn't to big a hassle as only one of the disk drives
promptly died. Replaced it - restored backups (two months old) and away we go.

BUT - the SMB panicked - sometimes when booting, other times after running
a few hours. Then I had to fsck the root partition - and this thing moaned
about lost links etc. etc. etc. with massive numbers!! As it would not fix -
removed the drive and did a fsck on my other machine and no problem.

After many, many retries - and trying to reinstall FC1 ( by now everything was stuffed)
I discovered the memory was fried (what a wild goose chase).
So I replaced the memory - reinstalled FC1 from scratch.
After naking sure all was fine...... in my wisdom I decided to image the root partion on
hda2 to hda6 as a backup "just for incase".
AND THEN I tried to reboot.... *&%^*&^%$#@#$ thing keeps on saying
"LABEL=/" is duplicated and tries to load root as a read only filesystem...
booted Knoppix and man I checked the fstab and any bloody file I could find with
"LABEL=" anywhere in it and all was fine.

Eventually the bell rang, the light went on and got a big kick up the behind.....
the partition copy also copied the ext2 label and I was sitting with two partions
with the label "/".... :(
Had to use e2label to change the label on hda6 and presto everything was fine.

SO BEWARE of copying ext2 partitions on the same drive - the label goes with it...
as does an incredible amount of frustration in trying to find the fault.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Thu Nov 11, 2004 4:10 pm

caveman, another thing you could have done is changed the "root=LABEL=/" in your /etc/grub.conf to "root=/dev/hda2". Of course you also want to use the real "/dev/hdxx" path in your /etc/fstab as well but you said that was already good so just changing the grub.conf should have fixed it.

worker201
guru
guru
Posts: 668
Joined: Sun Jun 13, 2004 6:38 pm
Location: Hawaii

Post by worker201 » Thu Nov 11, 2004 6:37 pm

I probably would have installed the new hard drive first, then installed Linux, then dealt with the NTFS resize, as you recommended. But I didn't have a screwdriver! So I decided to get as much of the process done as I could, and bring in a screwdriver the next day. Bad idea.

You may be happy to know that XP is on hda and Fedora Core 3 now has full control of new Seagate Barracuda hdb. Grub still plays nicely between them.

Whoever thought we would actually need more than 120GB hard drive space???

Post Reply